Module: Bio::Alignment::PropertyMethods

Included in:
EnumerableExtension, SiteMethods
Defined in:
lib/bio/alignment.rb

Overview

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

Constant Summary

GAP_REGEXP =

regular expression for detecting gaps.

/[^a-zA-Z]/
GAP_CHAR =

gap character

'-'.freeze
MISSING_CHAR =

missing character

'?'.freeze

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) gap_char

Gap character.



102
103
104
# File 'lib/bio/alignment.rb', line 102

def gap_char
  ((defined? @gap_char) ? @gap_char : nil) or GAP_CHAR
end

- (Object) gap_regexp

Returns regular expression for checking gap.



95
96
97
# File 'lib/bio/alignment.rb', line 95

def gap_regexp
  ((defined? @gap_regexp) ? @gap_regexp : nil) or GAP_REGEXP
end

- (Object) missing_char

Character if the site is missing or unknown.



109
110
111
# File 'lib/bio/alignment.rb', line 109

def missing_char
  ((defined? @missing_char) ? @missing_char : nil) or MISSING_CHAR
end

- (Object) seqclass

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.



120
121
122
# File 'lib/bio/alignment.rb', line 120

def seqclass
  ((defined? @seqclass) ? @seqclass : nil) or String
end

Instance Method Details

- (Object) get_all_property

Returns properties defined in the object as an hash.



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# 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

- (Boolean) is_gap?(s)

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



90
91
92
# File 'lib/bio/alignment.rb', line 90

def is_gap?(s)
  (gap_regexp =~ s) ? true : false
end

- (Object) set_all_property(hash)

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



148
149
150
151
152
153
154
# 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