Class: Bio::GenBank
- Includes:
- NCBIDB::Common
- Defined in:
- lib/bio/db/genbank/genbank.rb
Overview
Defined Under Namespace
Classes: Locus
Constant Summary
Constants included from NCBIDB::Common
NCBIDB::Common::DELIMITER, NCBIDB::Common::TAGSIZE
Instance Method Summary collapse
-
#basecount(base = nil) ⇒ Object
BASE COUNT (this field is obsoleted after GenBank release 138.0) – Returns the BASE COUNT as a Hash.
- #circular ⇒ Object
-
#classification ⇒ Object
Taxonomy classfication.
- #date ⇒ Object
-
#date_modified ⇒ Object
modified date.
- #division ⇒ Object
-
#each_cds ⇒ Object
FEATURES – Iterate only for the ‘CDS’ portion of the Bio::Features.
-
#each_gene ⇒ Object
FEATURES – Iterate only for the ‘gene’ portion of the Bio::Features.
- #entry_id ⇒ Object
- #length ⇒ Object (also: #nalen)
-
#locus ⇒ Object
Accessor methods for the contents of the LOCUS record.
- #natype ⇒ Object
-
#seq ⇒ Object
(also: #naseq)
ORIGIN – Returns DNA sequence in the ORIGIN record as a Bio::Sequence::NA object.
-
#seq_len ⇒ Object
(obsolete???) length of the sequence.
- #strand ⇒ Object
-
#strandedness ⇒ Object
Strandedness.
-
#to_biosequence ⇒ Object
- converts Bio::GenBank to Bio::Sequence — Arguments: Returns
-
Bio::Sequence object.
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
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).
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/bio/db/genbank/genbank.rb', line 99 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 |
#circular ⇒ Object
68 |
# File 'lib/bio/db/genbank/genbank.rb', line 68 def circular; locus.circular; end |
#classification ⇒ Object
Taxonomy classfication. Returns an array of strings.
142 143 144 |
# File 'lib/bio/db/genbank/genbank.rb', line 142 def classification self.taxonomy.to_s.sub(/\.\z/, '').split(/\s*\;\s*/) end |
#date ⇒ Object
70 |
# File 'lib/bio/db/genbank/genbank.rb', line 70 def date; locus.date; end |
#date_modified ⇒ Object
modified date. Returns Date object, String or nil.
133 134 135 136 137 138 139 |
# File 'lib/bio/db/genbank/genbank.rb', line 133 def date_modified begin Date.parse(self.date) rescue ArgumentError, TypeError, NoMethodError, NameError self.date end end |
#division ⇒ Object
69 |
# File 'lib/bio/db/genbank/genbank.rb', line 69 def division; locus.division; end |
#each_cds ⇒ Object
FEATURES – Iterate only for the ‘CDS’ portion of the Bio::Features.
77 78 79 80 81 82 83 |
# File 'lib/bio/db/genbank/genbank.rb', line 77 def each_cds features.each do |feature| if feature.feature == 'CDS' yield(feature) end end end |
#each_gene ⇒ Object
FEATURES – Iterate only for the ‘gene’ portion of the Bio::Features.
86 87 88 89 90 91 92 |
# File 'lib/bio/db/genbank/genbank.rb', line 86 def each_gene features.each do |feature| if feature.feature == 'gene' yield(feature) end end end |
#entry_id ⇒ Object
66 |
# File 'lib/bio/db/genbank/genbank.rb', line 66 def entry_id; locus.entry_id; end |
#length ⇒ Object Also known as: nalen
67 |
# File 'lib/bio/db/genbank/genbank.rb', line 67 def length; locus.length; end |
#locus ⇒ Object
Accessor methods for the contents of the LOCUS record.
62 63 64 |
# File 'lib/bio/db/genbank/genbank.rb', line 62 def locus @data['LOCUS'] ||= Locus.new(get('LOCUS')) end |
#natype ⇒ Object
73 |
# File 'lib/bio/db/genbank/genbank.rb', line 73 def natype; locus.natype; end |
#seq ⇒ Object Also known as: naseq
ORIGIN – Returns DNA sequence in the ORIGIN record as a Bio::Sequence::NA object.
118 119 120 121 122 123 |
# File 'lib/bio/db/genbank/genbank.rb', line 118 def seq unless @data['SEQUENCE'] origin end Bio::Sequence::NA.new(@data['SEQUENCE']) end |
#seq_len ⇒ Object
(obsolete???) length of the sequence
128 129 130 |
# File 'lib/bio/db/genbank/genbank.rb', line 128 def seq_len seq.length end |
#strand ⇒ Object
72 |
# File 'lib/bio/db/genbank/genbank.rb', line 72 def strand; locus.strand; end |
#strandedness ⇒ Object
Strandedness. Returns one of ‘single’, ‘double’, ‘mixed’, or nil.
147 148 149 150 151 152 153 |
# File 'lib/bio/db/genbank/genbank.rb', line 147 def strandedness case self.strand.to_s.downcase when 'ss-'; 'single' when 'ds-'; 'double' when 'ms-'; 'mixed' else nil; end end |