Class: Bio::Alignment::MultiFastaFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/bio/appl/mafft/report.rb

Overview

Data class for fasta-formatted multiple sequence alignment data, which is simply multiple entiries of fasta formatted sequences.

Direct Known Subclasses

MAFFT::Report

Constant Summary collapse

DELIMITER =

delimiter for flatfile

RS = nil

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ MultiFastaFormat

Creates a new data object. str should be a (multi-)fasta formatted string.



46
47
48
49
50
51
# File 'lib/bio/appl/mafft/report.rb', line 46

def initialize(str)
  ff = Bio::FlatFile.new(Bio::FastaFormat, StringIO.new(str))
  @data = ff.to_a
  @alignment = nil
  @seq_method = nil
end

Instance Method Details

#alignment(method = nil) ⇒ Object

Gets an multiple alignment. Returns a Bio::Alignment object. method should be one of :naseq, :aaseq, :seq, or nil (default). nil means to automatically determine nucleotide or amino acid.

This method returns previously parsed object if the same method is given (or guessed method is the same).



60
61
62
63
64
65
66
67
# File 'lib/bio/appl/mafft/report.rb', line 60

def alignment(method = nil)
  m = determine_seq_method(@data, method)
  if !@alignment or m != @seq_method then
    @seq_method = m
    @alignment = do_parse(@data, @seq_method)
  end
  @alignment
end

#entriesObject

Gets an array of the fasta formatted sequence objects. Returns an array of Bio::FastaFormat objects.



71
72
73
# File 'lib/bio/appl/mafft/report.rb', line 71

def entries
  @data
end