class Bio::Phylip::PhylipFormat
This is phylip multiple alignment format parser. The two formats, interleaved and non-interleaved, are automatically determined.
Attributes
alignment length
number of sequences
Public Class Methods
Source
# File lib/bio/appl/phylip/alignment.rb 26 def initialize(str) 27 @data = str.strip.split(/(?:\r\n|\r|\n)/) 28 @first_line = @data.shift 29 @number_of_sequences, @alignment_length = 30 @first_line.to_s.strip.split(/\s+/).collect { |x| x.to_i } 31 end
create a new object from a string
Public Instance Methods
Source
# File lib/bio/appl/phylip/alignment.rb 54 def alignment 55 unless defined? @alignment then 56 do_parse 57 a = Bio::Alignment.new 58 (0...@number_of_sequences).each do |i| 59 a.add_seq(@sequences[i], @sequence_names[i]) 60 end 61 @alignment = a 62 end 63 @alignment 64 end
Gets the alignment. Returns a Bio::Alignment
object.
Source
# File lib/bio/appl/phylip/alignment.rb 42 def interleaved? 43 unless defined? @interleaved_flag then 44 if /\A +/ =~ @data[1].to_s then 45 @interleaved_flag = false 46 else 47 @interleaved_flag = true 48 end 49 end 50 @interleaved_flag 51 end
If the alignment format is “interleaved”, returns true. If not, returns false. It would mistake to determine if the alignment is very short.