Class: Bio::GenBank

Inherits:
NCBIDB show all
Includes:
NCBIDB::Common
Defined in:
lib/bio/db/genbank/genbank.rb

Overview

Description

Parses a GenBank formatted database entry

Example

# entry is a string containing only one entry contents
gb = Bio::GenBank.new(entry)

Direct Known Subclasses

DDBJ, RefSeq

Defined Under Namespace

Classes: Locus

Constant Summary

Constants included from NCBIDB::Common

NCBIDB::Common::DELIMITER, NCBIDB::Common::TAGSIZE

Instance Method Summary collapse

Methods included from NCBIDB::Common

#acc_version, #accession, #accessions, #comment, #common_name, #definition, #features, #gi, #initialize, #keywords, #nid, #organism, #origin, #references, #segment, #source, #taxonomy, #version, #versions

Methods inherited from NCBIDB

#initialize

Methods inherited from DB

#exists?, #fetch, #get, open, #tags

Instance Method Details

#basecount(base = nil) ⇒ Object

BASE COUNT (this field is obsoleted after GenBank release 138.0) – Returns the BASE COUNT as a Hash. When the base is specified, returns count of the base as a Fixnum. The base can be one of ‘a’, ‘t’, ‘g’, ‘c’, and ‘o’ (others).



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/bio/db/genbank/genbank.rb', line 96

def basecount(base = nil)
  unless @data['BASE COUNT']
    hash = Hash.new(0)
    get('BASE COUNT').scan(/(\d+) (\w)/).each do |c, b|
      hash[b] = c.to_i
    end
    @data['BASE COUNT'] = hash
  end

  if base
    base.downcase!
    @data['BASE COUNT'][base]
  else
    @data['BASE COUNT']
  end
end

#circularObject



65
# File 'lib/bio/db/genbank/genbank.rb', line 65

def circular;  locus.circular;  end

#dateObject



67
# File 'lib/bio/db/genbank/genbank.rb', line 67

def date;      locus.date;      end

#divisionObject



66
# File 'lib/bio/db/genbank/genbank.rb', line 66

def division;  locus.division;  end

#each_cdsObject

FEATURES – Iterate only for the ‘CDS’ portion of the Bio::Features.



74
75
76
77
78
79
80
# File 'lib/bio/db/genbank/genbank.rb', line 74

def each_cds
  features.each do |feature|
    if feature.feature == 'CDS'
      yield(feature)
    end
  end
end

#each_geneObject

FEATURES – Iterate only for the ‘gene’ portion of the Bio::Features.



83
84
85
86
87
88
89
# File 'lib/bio/db/genbank/genbank.rb', line 83

def each_gene
  features.each do |feature|
    if feature.feature == 'gene'
      yield(feature)
    end
  end
end

#entry_idObject



63
# File 'lib/bio/db/genbank/genbank.rb', line 63

def entry_id;  locus.entry_id;  end

#lengthObject Also known as: nalen



64
# File 'lib/bio/db/genbank/genbank.rb', line 64

def length;    locus.length;    end

#locusObject

Accessor methods for the contents of the LOCUS record.



59
60
61
# File 'lib/bio/db/genbank/genbank.rb', line 59

def locus
  @data['LOCUS'] ||= Locus.new(get('LOCUS'))
end

#natypeObject



70
# File 'lib/bio/db/genbank/genbank.rb', line 70

def natype;    locus.natype;    end

#seqObject Also known as: naseq

ORIGIN – Returns DNA sequence in the ORIGIN record as a Bio::Sequence::NA object.



115
116
117
118
119
120
# File 'lib/bio/db/genbank/genbank.rb', line 115

def seq
  unless @data['SEQUENCE']
    origin
  end
  Bio::Sequence::NA.new(@data['SEQUENCE'])
end

#seq_lenObject



124
125
126
# File 'lib/bio/db/genbank/genbank.rb', line 124

def seq_len
  seq.length
end

#strandObject



69
# File 'lib/bio/db/genbank/genbank.rb', line 69

def strand;    locus.strand;    end