Method: Bio::Blast.reports_xml
- Defined in:
- lib/bio/appl/blast.rb
.reports_xml(input, parser = nil) ⇒ Object
Note that this is the old implementation of Bio::Blast.reports. The aim of this method is keeping compatibility for older BLAST XML documents which might not be parsed by the new Bio::Blast.reports nor Bio::FlatFile. (Though we are not sure whether such documents exist or not.)
Bio::Blast.reports_xml parses given data, and returns an array of Bio::Blast::Report objects, or yields each Bio::Blast::Report object when a block is given.
It can be used only for XML format. For default (-m 0) format, consider using Bio::FlatFile, or Bio::Blast.reports.
Arguments:
-
input (required): input data
-
parser: type of parser. see Bio::Blast::Report.new
- Returns
-
Undefiend when a block is given. Otherwise, an Array containing Bio::Blast::Report objects.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/bio/appl/blast.rb', line 220 def self.reports_xml(input, parser = nil) ary = [] input.each_line("</BlastOutput>\n") do |xml| xml.sub!(/[^<]*(<?)/, '\1') # skip before <?xml> tag next if xml.empty? # skip trailing no hits rep = Report.new(xml, parser) if rep.reports then if block_given? rep.reports.each { |r| yield r } else ary.concat rep.reports end else if block_given? yield rep else ary.push rep end end end return ary end |