class Bio::Phylip::PhylipFormat

This is phylip multiple alignment format parser. The two formats, interleaved and non-interleaved, are automatically determined.

Attributes

alignment_length[R]

alignment length

number_of_sequences[R]

number of sequences

Public Class Methods

new(str) click to toggle source

create a new object from a string

   # 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

Public Instance Methods

alignment() click to toggle source

Gets the alignment. Returns a Bio::Alignment object.

   # 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
interleaved?() click to toggle source

If the alignment format is “interleaved”, returns true. If not, returns false. It would mistake to determine if the alignment is very short.

   # 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