Sha256: 9b8d5861e443d0e1ce9b038c747a7c85cfaa8b41c300d505c9c469a1f9790ebd

Contents?: true

Size: 1.83 KB

Versions: 4

Compression:

Stored size: 1.83 KB

Contents

#
# = bio/db/gff/gffinmemory.rb - Assemble mRNA and CDS from GFF in RAM
#
# Copyright::  Copyright (C) 2010
#              Pjotr Prins <pjotr.prins@thebird.nl>
# License::    The Ruby License
#
# Fetch information from a GFF file

module Bio
  module GFFbrowser

    module Digest

      class InMemory
        include Parser
        include Gff3Sequence
        attr_reader :sequencelist

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

        # Digest mRNA from the GFFdb and store in Hash
        # Next yield(id, seq) from Hash
        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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
bio-gff3-0.8.3 lib/bio/db/gff/gffinmemory.rb
bio-gff3-0.8.2 lib/bio/db/gff/gffinmemory.rb
bio-gff3-0.8.0 lib/bio/db/gff/gffinmemory.rb
bio-gff3-0.6.0 lib/bio/db/gff/gffinmemory.rb