class Bio::ClustalW::Report
CLUSTAL W result data (*.aln file) parser class.
Constants
- DELIMITER
Delimiter of each entry.
Bio::FlatFile
uses it. InBio::ClustalW::Report
, it it nil (1 entry 1 file).
Attributes
string of whole result
sequence class (one of Bio::Sequence
, Bio::Sequence::NA
, Bio::Sequence::AA
, …)
Public Class Methods
Creates new instance. str
should be a CLUSTAL format string. seqclass
should on of following:
-
Class:
Bio::Sequence::AA
,Bio::Sequence::NA
, … -
String: 'PROTEIN', 'DNA', …
# File lib/bio/appl/clustalw/report.rb 45 def initialize(str, seqclass = nil) 46 @raw = str 47 @align = nil 48 @match_line = nil 49 @header = nil 50 case seqclass 51 when /PROTEIN/i 52 @seqclass = Bio::Sequence::AA 53 when /[DR]NA/i 54 @seqclass = Bio::Sequence::NA 55 else 56 if seqclass.is_a?(Module) then 57 @seqclass = seqclass 58 else 59 @seqclass = Bio::Sequence 60 end 61 end 62 end
Public Instance Methods
This will be deprecated. Instead, please use alignment.
Gets an multiple alignment. Returns a Bio::Alignment
object.
# File lib/bio/appl/clustalw/report.rb 111 def align 112 warn "Bio::ClustalW#align will be deprecated. Please use \'alignment\'." 113 alignment 114 end
Gets an multiple alignment. Returns a Bio::Alignment
object.
# File lib/bio/appl/clustalw/report.rb 102 def alignment 103 do_parse() unless @align 104 @align 105 end
Returns the Bio::Sequence
in the matrix at row 'row' as Bio::Sequence
object. When row is out of range a nil is returned.
Arguments:
-
(required) row: Integer
- Returns
# File lib/bio/appl/clustalw/report.rb 83 def get_sequence(row) 84 a = alignment 85 return nil if row < 0 or row >= a.keys.size 86 id = a.keys[row] 87 seq = a.to_hash[id] 88 s = Bio::Sequence.new(seq.seq) 89 s.definition = id 90 s 91 end
Shows first line of the result data, for example, 'CLUSTAL W (1.82) multiple sequence alignment'. Returns a string.
# File lib/bio/appl/clustalw/report.rb 73 def header 74 @header or (do_parse or @header) 75 end
Shows “match line” of CLUSTAL's alignment result, for example, ':* :* .* * .::. ** :* . * . '. Returns a string.
# File lib/bio/appl/clustalw/report.rb 96 def match_line 97 @match_line or (do_parse or @match_line) 98 end
Compatibility note: Behavior of the method will be changed in the future.
Gets an array of the sequences. Returns an array of Bio::FastaFormat
objects.
# File lib/bio/appl/clustalw/report.rb 130 def to_a 131 alignment.to_fastaformat_array 132 end
This will be deprecated. Instead, please use alignment.output_fasta.
Gets an fasta-format string of the sequences. Returns a string.
# File lib/bio/appl/clustalw/report.rb 120 def to_fasta(*arg) 121 warn "Bio::ClustalW::report#to_fasta is deprecated. Please use \'alignment.output_fasta\'" 122 alignment.output_fasta(*arg) 123 end
Private Instance Methods
Parses Clustal W result text.
# File lib/bio/appl/clustalw/report.rb 136 def do_parse 137 return nil if @align 138 a = @raw.split(/\r?\n\r?\n/) 139 @header = a.shift.to_s 140 xalign = Bio::Alignment.new 141 @match_line = '' 142 if a.size > 0 then 143 a[0].gsub!(/\A(\r?\n)+/, '') 144 a.collect! { |x| x.split(/\r?\n/) } 145 a.each { |x| 146 x.each { |y| y.sub!(/ +\d+\s*\z/, '') if /\d\s*\z/ =~ y } 147 # The above "if /\d\s*\z/ =~ y" is for optimization only. 148 } #for -SEQNOS=on option 149 @tagsize = ( a[0][0].rindex(/\s/) or -1 ) + 1 150 a.each do |x| 151 @match_line << x.pop.to_s[@tagsize..-1] 152 end 153 a[0].each do |y| 154 xalign.store(y[0, @tagsize].sub(/\s+\z/, ''), '') 155 end 156 a.each do |x| 157 x.each do |y| 158 name = y[0, @tagsize].sub(/\s+\z/, '') 159 seq = y[@tagsize..-1] 160 xalign[name] << seq 161 end 162 end 163 xalign.collect! { |x| @seqclass.new(x) } 164 end 165 @align = xalign 166 nil 167 end