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

basecount(base = nil) click to toggle source

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
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() click to toggle source
# File lib/bio/db/genbank/genbank.rb, line 68
def circular;  locus.circular;  end
classification() click to toggle source

Taxonomy classfication. Returns an array of strings.

# File lib/bio/db/genbank/genbank.rb, line 142
def classification
  self.taxonomy.to_s.sub(/\.\z/, '').split(/\s*\;\s*/)
end
date() click to toggle source
# File lib/bio/db/genbank/genbank.rb, line 70
def date;      locus.date;      end
date_modified() click to toggle source

modified date. Returns Date object, String or nil.

# 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() click to toggle source
# File lib/bio/db/genbank/genbank.rb, line 69
def division;  locus.division;  end
each_cds() { |feature| ... } click to toggle source

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

# 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() { |feature| ... } click to toggle source

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

# 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() click to toggle source
# File lib/bio/db/genbank/genbank.rb, line 66
def entry_id;  locus.entry_id;  end
length() click to toggle source
# File lib/bio/db/genbank/genbank.rb, line 67
def length;    locus.length;    end
Also aliased as: nalen
locus() click to toggle source

Accessor methods for the contents of the LOCUS record.

# File lib/bio/db/genbank/genbank.rb, line 62
def locus
  @data['LOCUS'] ||= Locus.new(get('LOCUS'))
end
nalen()
Alias for: length
naseq()
Alias for: seq
natype() click to toggle source
# File lib/bio/db/genbank/genbank.rb, line 73
def natype;    locus.natype;    end
seq() click to toggle source

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

# File lib/bio/db/genbank/genbank.rb, line 118
def seq
  unless @data['SEQUENCE']
    origin
  end
  Bio::Sequence::NA.new(@data['SEQUENCE'])
end
Also aliased as: naseq
seq_len() click to toggle source

(obsolete???) length of the sequence

# File lib/bio/db/genbank/genbank.rb, line 128
def seq_len
  seq.length
end
strand() click to toggle source
# File lib/bio/db/genbank/genbank.rb, line 72
def strand;    locus.strand;    end
strandedness() click to toggle source

Strandedness. Returns one of 'single', 'double', 'mixed', or nil.

# 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
to_biosequence() click to toggle source

converts Bio::GenBank to Bio::Sequence


Arguments:

Returns

Bio::Sequence object

# File lib/bio/db/genbank/genbank.rb, line 159
def to_biosequence
  Bio::Sequence.adapter(self, Bio::Sequence::Adapter::GenBank)
end