| Class | Bio::GenBank |
| In: |
lib/bio/db/genbank/genbank.rb
|
| Parent: | NCBIDB |
Parses a GenBank formatted database entry
# entry is a string containing only one entry contents gb = Bio::GenBank.new(entry)
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).
# File lib/bio/db/genbank/genbank.rb, line 99
99: def basecount(base = nil)
100: unless @data['BASE COUNT']
101: hash = Hash.new(0)
102: get('BASE COUNT').scan(/(\d+) (\w)/).each do |c, b|
103: hash[b] = c.to_i
104: end
105: @data['BASE COUNT'] = hash
106: end
107:
108: if base
109: base.downcase!
110: @data['BASE COUNT'][base]
111: else
112: @data['BASE COUNT']
113: end
114: end
Taxonomy classfication. Returns an array of strings.
# File lib/bio/db/genbank/genbank.rb, line 142
142: def classification
143: self.taxonomy.to_s.sub(/\.\z/, '').split(/\s*\;\s*/)
144: end
FEATURES — Iterate only for the ‘CDS’ portion of the Bio::Features.
# File lib/bio/db/genbank/genbank.rb, line 77
77: def each_cds
78: features.each do |feature|
79: if feature.feature == 'CDS'
80: yield(feature)
81: end
82: end
83: end
FEATURES — Iterate only for the ‘gene’ portion of the Bio::Features.
# File lib/bio/db/genbank/genbank.rb, line 86
86: def each_gene
87: features.each do |feature|
88: if feature.feature == 'gene'
89: yield(feature)
90: end
91: end
92: end
Accessor methods for the contents of the LOCUS record.
# File lib/bio/db/genbank/genbank.rb, line 62
62: def locus
63: @data['LOCUS'] ||= Locus.new(get('LOCUS'))
64: end
ORIGIN — Returns DNA sequence in the ORIGIN record as a Bio::Sequence::NA object.
# File lib/bio/db/genbank/genbank.rb, line 118
118: def seq
119: unless @data['SEQUENCE']
120: origin
121: end
122: Bio::Sequence::NA.new(@data['SEQUENCE'])
123: end
Strandedness. Returns one of ‘single’, ‘double’, ‘mixed’, or nil.
# File lib/bio/db/genbank/genbank.rb, line 147
147: def strandedness
148: case self.strand.to_s.downcase
149: when 'ss-'; 'single'
150: when 'ds-'; 'double'
151: when 'ms-'; 'mixed'
152: else nil; end
153: end
converts Bio::GenBank to Bio::Sequence
Arguments:
| Returns: | Bio::Sequence object |
# File lib/bio/db/genbank/genbank.rb, line 159
159: def to_biosequence
160: Bio::Sequence.adapter(self, Bio::Sequence::Adapter::GenBank)
161: end