module Bio::Alignment::PropertyMethods

Bio::Alignment::PropertyMethods is a set of methods to treat the gap character and so on.

Constants

GAP_CHAR

gap character

GAP_REGEXP

regular expression for detecting gaps.

MISSING_CHAR

missing character

Attributes

gap_char[W]

gap character

gap_regexp[W]

regular expression for checking gap

missing_char[W]

Character if the site is missing or unknown.

seqclass[W]

The class of the sequence. The value must be String or its derivatives.

Public Instance Methods

gap_char() click to toggle source

Gap character.

# File lib/bio/alignment.rb, line 102
def gap_char
  ((defined? @gap_char) ? @gap_char : nil) or GAP_CHAR
end
gap_regexp() click to toggle source

Returns regular expression for checking gap.

# File lib/bio/alignment.rb, line 95
def gap_regexp
  ((defined? @gap_regexp) ? @gap_regexp : nil) or GAP_REGEXP
end
get_all_property() click to toggle source

Returns properties defined in the object as an hash.

# File lib/bio/alignment.rb, line 129
def get_all_property
  ret = {}
  if defined? @gap_regexp
    ret[:gap_regexp] = @gap_regexp
  end
  if defined? @gap_char
    ret[:gap_char] = @gap_char
  end
  if defined? @missing_char
    ret[:missing_char] = @missing_char
  end
  if defined? @seqclass
    ret[:seqclass] = @seqclass
  end
  ret
end
is_gap?(s) click to toggle source

If given character is a gap, returns true. Otherwise, return false. Note that s must be a String which contain a single character.

# File lib/bio/alignment.rb, line 90
def is_gap?(s)
  (gap_regexp =~ s) ? true : false
end
missing_char() click to toggle source

Character if the site is missing or unknown.

# File lib/bio/alignment.rb, line 109
def missing_char
  ((defined? @missing_char) ? @missing_char : nil) or MISSING_CHAR
end
seqclass() click to toggle source

Returns class of the sequence. If instance variable @seqclass (which can be set by 'seqclass=' method) is set, simply returns the value. Otherwise, returns the first sequence's class. If no sequences are found, returns nil.

# File lib/bio/alignment.rb, line 120
def seqclass
  ((defined? @seqclass) ? @seqclass : nil) or String
end
set_all_property(hash) click to toggle source

Sets properties from given hash. hash would be a return value of get_character method.

# File lib/bio/alignment.rb, line 148
def set_all_property(hash)
  @gap_regexp   = hash[:gap_regexp]   if hash.has_key?(:gap_regexp)
  @gap_char     = hash[:gap_char]     if hash.has_key?(:gap_char)
  @missing_char = hash[:missing_char] if hash.has_key?(:missing_char)
  @seqclass     = hash[:seqclass]     if hash.has_key?(:seqclass)
  self
end