Class: Bio::GFFbrowser::Digest::InMemory

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

Instance Attribute Summary collapse

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) ⇒ InMemory

Returns a new instance of InMemory.



20
21
22
23
24
# File 'lib/bio/db/gff/gffinmemory.rb', line 20

def initialize filename, options
  @options = options
  # Invoke the BioRuby in memory parser
  @gff = Bio::GFF::GFF3.new(File.read(filename))
end

Instance Attribute Details

#sequencelistObject (readonly)

Returns the value of attribute sequencelist.



18
19
20
# File 'lib/bio/db/gff/gffinmemory.rb', line 18

def sequencelist
  @sequencelist
end

Instance Method Details

#each_item(list) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/bio/db/gff/gffinmemory.rb', line 52

def each_item list
  list.each do | id, recs |
    seqid = recs[0].seqname
    component = find_component(recs[0])
    yield id, recs, component
  end
end

#parseObject

Digest mRNA from the GFFdb and store in Hash Next yield(id, seq) from Hash



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/bio/db/gff/gffinmemory.rb', line 28

def parse 
  info "---- Digest DB and store data in mRNA Hash"
  @count_ids          = Counter.new   # Count ids
  @count_seqnames     = Counter.new   # Count seqnames
  @componentlist      = {} # Store containers, like genes, contigs
  @mrnalist           = LinkedRecs.new   # Store linked mRNA records
  @cdslist            = LinkedRecs.new
  @exonlist           = LinkedRecs.new
  @sequencelist       = {}
  @unrecognized_features = {}
  @gff.records.each do | rec |
    store_record(rec)
  end
  @gff.sequences.each do | bioseq |
    id = bioseq.entry_id
    @sequencelist[id] = bioseq.to_s # in Bio::Sequence with contained Bio::FastaFormat
  end
  validate_mrnas
  validate_cdss 
  show_unrecognized_features 
  @genelist      = @count_ids.keys 
  read_fasta
end