Class: Bio::GFFbrowser::Digest::NoCache

Inherits:
Object
  • Object
show all
Includes:
NoCacheHelpers, Parser, Gff3Sequence
Defined in:
lib/bio/db/gff/gffnocache.rb

Instance Method Summary collapse

Methods included from Parser

#each_CDS, #each_CDS_seq, #each_exon, #each_exon_seq, #each_mRNA, #each_mRNA_seq, #read_fasta, #show_unrecognized_features, #store_record, #validate_cdss, #validate_mrnas

Methods included from Helpers::Error

#error, #info, #warn

Constructor Details

#initialize(filename, options) ⇒ NoCache

Returns a new instance of NoCache.



80
81
82
83
84
# File 'lib/bio/db/gff/gffnocache.rb', line 80

def initialize filename, options
  @filename = filename
  @options = options
  @iter = Bio::GFF::GFF3::FileIterator.new(@filename)
end

Instance Method Details

#each_item(list) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/bio/db/gff/gffnocache.rb', line 111

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)
    end
    seqid = recs[0].seqname
    component = find_component(recs[0])
    yield id, recs, component
  end
end

#parseObject

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



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/bio/db/gff/gffnocache.rb', line 88

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) # Store containers, like genes, contigs
  @mrnalist           = SeekLinkedRecs.new   # Store linked mRNA records
  @cdslist            = SeekLinkedRecs.new
  @exonlist           = SeekLinkedRecs.new
  @sequencelist       = {}
  @unrecognized_features = {}
  @iter.each_rec do | id, rec |
    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