Class | Bio::Phylip::PhylipFormat
In: | lib/bio/appl/phylip/alignment.rb
Parent: | Object

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

### Methods

alignment interleaved? new

### Attributes

alignment_length | [R] | alignment length
number_of_sequences | [R] | number of sequences

### Public Class methods

new(str)

create a new object from a string

[Source]

        # File lib/bio/appl/phylip/alignment.rb, line 26
    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()

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

[Source]

        # File lib/bio/appl/phylip/alignment.rb, line 54
    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?()

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

[Source]

        # File lib/bio/appl/phylip/alignment.rb, line 42
    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

[Validate]