class Bio::GenBank
Description¶ ↑
Parses a GenBank
formatted database entry
Example¶ ↑
# entry is a string containing only one entry contents gb = Bio::GenBank.new(entry)
Public Instance Methods
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 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
# File lib/bio/db/genbank/genbank.rb 68 def circular; locus.circular; end
Taxonomy classfication. Returns an array of strings.
# File lib/bio/db/genbank/genbank.rb 142 def classification 143 self.taxonomy.to_s.sub(/\.\z/, '').split(/\s*\;\s*/) 144 end
# File lib/bio/db/genbank/genbank.rb 70 def date; locus.date; end
modified date. Returns Date object, String or nil.
# File lib/bio/db/genbank/genbank.rb 133 def date_modified 134 begin 135 Date.parse(self.date) 136 rescue ArgumentError, TypeError, NoMethodError, NameError 137 self.date 138 end 139 end
# File lib/bio/db/genbank/genbank.rb 69 def division; locus.division; end
FEATURES – Iterate only for the ‘CDS’ portion of the Bio::Features
.
# File lib/bio/db/genbank/genbank.rb 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 86 def each_gene 87 features.each do |feature| 88 if feature.feature == 'gene' 89 yield(feature) 90 end 91 end 92 end
# File lib/bio/db/genbank/genbank.rb 66 def entry_id; locus.entry_id; end
# File lib/bio/db/genbank/genbank.rb 67 def length; locus.length; end
Accessor methods for the contents of the LOCUS record.
# File lib/bio/db/genbank/genbank.rb 62 def locus 63 @data['LOCUS'] ||= Locus.new(get('LOCUS')) 64 end
# File lib/bio/db/genbank/genbank.rb 73 def natype; locus.natype; end
ORIGIN – Returns DNA sequence in the ORIGIN record as a Bio::Sequence::NA
object.
# File lib/bio/db/genbank/genbank.rb 118 def seq 119 unless @data['SEQUENCE'] 120 origin 121 end 122 Bio::Sequence::NA.new(@data['SEQUENCE']) 123 end
(obsolete???) length of the sequence
# File lib/bio/db/genbank/genbank.rb 128 def seq_len 129 seq.length 130 end
# File lib/bio/db/genbank/genbank.rb 72 def strand; locus.strand; end
Strandedness. Returns one of ‘single’, ‘double’, ‘mixed’, or nil.
# File lib/bio/db/genbank/genbank.rb 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 159 def to_biosequence 160 Bio::Sequence.adapter(self, Bio::Sequence::Adapter::GenBank) 161 end