Class: Bio::FlatFileIndex::Indexer::Parser::BlastDefaultParser
- Inherits:
-
TemplateParser
- Object
- TemplateParser
- Bio::FlatFileIndex::Indexer::Parser::BlastDefaultParser
- Defined in:
- lib/bio/io/flatfile/indexer.rb
Overview
class MaXMLSequenceParser
Constant Summary collapse
- NAMESTYLE =
NameSpaces.new( NameSpace.new( 'QUERY', Proc.new { |x| x.query_def } ), NameSpace.new( 'query_id', Proc.new { |x| a = Bio::FastaDefline.new(x.query_def.to_s).id_strings a << x.query_def.to_s.split(/\s+/,2)[0] a } ), NameSpace.new( 'hit', Proc.new { |x| a = x.hits.collect { |y| b = Bio::FastaDefline.new(y.definition.to_s).id_strings b << y.definition b << y.definition.to_s.split(/\s+/,2)[0] b } a.flatten! a } ) )
- PRIMARY =
'QUERY'
- SECONDARY =
[ 'query_id', 'hit' ]
Instance Attribute Summary
Attributes inherited from TemplateParser
#dbclass, #errorlog, #fileid, #format, #primary, #secondary
Instance Method Summary collapse
-
#initialize(klass, pri_name = nil, sec_names = nil) ⇒ BlastDefaultParser
constructor
A new instance of BlastDefaultParser.
- #open_flatfile(fileid, file) ⇒ Object
Methods inherited from TemplateParser
#add_secondary_namespaces, #close_flatfile, #each, #parse_primary, #parse_secondary, #set_primary_namespace
Constructor Details
#initialize(klass, pri_name = nil, sec_names = nil) ⇒ BlastDefaultParser
Returns a new instance of BlastDefaultParser.
392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/bio/io/flatfile/indexer.rb', line 392 def initialize(klass, pri_name = nil, sec_names = nil) super() self.format = 'raw' self.dbclass = klass self.set_primary_namespace((pri_name or PRIMARY)) unless sec_names then sec_names = [] @namestyle.each_value do |x| sec_names << x.name if x.name != self.primary.name end end self.add_secondary_namespaces(*sec_names) end |
Instance Method Details
#open_flatfile(fileid, file) ⇒ Object
405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/bio/io/flatfile/indexer.rb', line 405 def open_flatfile(fileid, file) super @flatfile.rewind @flatfile.dbclass = nil @flatfile.autodetect @flatfile.dbclass = self.dbclass unless @flatfile.dbclass @flatfile.rewind begin pos = @flatfile.pos line = @flatfile.gets end until (!line or line =~ /^T?BLAST/) @flatfile.pos = pos end |