class Bio::GFFbrowser::Digest::NoCache

Public Class Methods

new(filename, options) click to toggle source
# File lib/bio/db/gff/digest/gffnocache.rb, line 88
def initialize filename, options
  @filename = filename
  @options = options
  @iter = Bio::GFF::GFF3::FileIterator.new(@filename)
end

Public Instance Methods

each_item(list) { |id, [rec], component| ... } click to toggle source
# File lib/bio/db/gff/digest/gffnocache.rb, line 128
def each_item list
  # p list.class
  fh = @iter.fh
  list.each do | id, io_seeklist |
    recs = []
    io_seeklist.each do | fpos |
      recs << SeekRec::fetch(fh,fpos,@options[:parser])
    end
    seqid = recs[0].seqname
    component = find_component(recs[0])
    if @options[:no_assemble]
      recs.each do | rec |
        yield id, [rec], component
      end
    else
      yield id, recs, component
    end
  end
end
parse() click to toggle source

parse the whole file once and store all seek locations, rather than the records themselves

# File lib/bio/db/gff/digest/gffnocache.rb, line 96
def parse
  info "---- Digest DB and store data in mRNA Hash (NoCache)"
  @count_ids          = Counter.new   # Count ids
  @count_seqnames     = Counter.new   # Count seqnames
  @componentlist      = SeekRecList.new(@iter.fh,@options[:parser]) # Store containers, like genes, contigs
  @orflist            = SeekLinkedRecs.new   # Store linked gene records
  @mrnalist           = SeekLinkedRecs.new   # Store linked mRNA records
  @cdslist            = SeekLinkedRecs.new
  @exonlist           = SeekLinkedRecs.new
  @sequencelist       = {}
  @unrecognized_features = {}
  @iter.each_rec do |fpos, line|
    rec = case @options[:parser]
      when :bioruby
        Bio::GFF::GFF3::BioRubyFileRecord.new(fpos, line)
      when :line
        Bio::GFF::GFF3::FastParserFileRecord.new(fpos, line)
      else
        raise 'Unknown parser'
    end
    store_record(rec)
  end
  @iter.each_sequence do | id, bioseq |
    @sequencelist[id] = bioseq.to_s
  end
  validate_mrnas 
  validate_cdss
  show_unrecognized_features
  @genelist      = @count_ids.keys 
  read_fasta
end