Module Bio::EMBLDB::Common
In: lib/bio/db/embl/common.rb  (CVS)

Methods

ac   accession   accessions   de   definition   description   dr   keywords   kw   new   oc   og   os   ref   references  

Constants

DELIMITER = "\n//\n"
RS = DELIMITER
TAGSIZE = 5

Public Class methods

[Source]

# File lib/bio/db/embl/common.rb, line 85
  def initialize(entry)
    super(entry, TAGSIZE)
  end

Public Instance methods

returns a Array of accession numbers in the AC lines.

AC Line

  "AC   A12345; B23456;"
  AC [AC1;]+

Accession numbers format:

  1       2     3          4          5          6
  [O,P,Q] [0-9] [A-Z, 0-9] [A-Z, 0-9] [A-Z, 0-9] [0-9]

[Source]

# File lib/bio/db/embl/common.rb, line 98
  def ac
    unless @data['AC']
      tmp = Array.new
      field_fetch('AC').split(/ /).each do |e|
        tmp.push(e.sub(/;/,''))
      end
      @data['AC'] = tmp
    end
    @data['AC']
  end

returns the first accession number in the AC lines

[Source]

# File lib/bio/db/embl/common.rb, line 112
  def accession
    ac[0]
  end
accessions()

Alias for ac

returns a String int the DE line.

DE Line

[Source]

# File lib/bio/db/embl/common.rb, line 120
  def de
    unless @data['DE']
      @data['DE'] = fetch('DE')
    end
    @data['DE']
  end
definition()

Alias for de

description()

Alias for de

returns contents in the DR line.

where <Database cross-reference Hash> is:

DR Line; defabases cross-reference (>=0) a cross_ref pre one line

 "DR  database_identifier; primary_identifier; secondary_identifier."

[Source]

# File lib/bio/db/embl/common.rb, line 313
  def dr
    unless @data['DR']
      tmp = Hash.new
      self.get('DR').split(/\n/).each do |db|
        a = db.sub(/^DR   /,'').sub(/.$/,'').strip.split(/;[ ]/)
        dbname = a.shift
        tmp[dbname] = Array.new unless tmp[dbname]
        tmp[dbname].push(a)
      end
      @data['DR'] = tmp
    end
    if block_given?
      @data['DR'].each do |k,v|
        yield(k, v)
      end
    else
      @data['DR']
    end
  end
keywords()

Alias for kw

returns keywords in the KW line.

KW Line; keyword (>=1)

 KW   [Keyword;]+

[Source]

# File lib/bio/db/embl/common.rb, line 219
  def kw
    unless @data['KW']
      if get('KW').size > 0
        tmp = fetch('KW').sub(/.$/,'')
        @data['KW'] = tmp.split(/;/).map {|e| e.strip }
      else
        @data['KW'] = []
      end
    end
    @data['KW']
  end

returns contents in the OC line.

OC Line; organism classification (>=1)

 OC   Eukaryota; Alveolata; Apicomplexa; Piroplasmida; Theileriidae;
 OC   Theileria.

[Source]

# File lib/bio/db/embl/common.rb, line 202
  def oc
    unless @data['OC']
      begin
        @data['OC'] = fetch('OC').sub(/.$/,'').split(/;/).map {|e|
          e.strip 
        }
      rescue NameError
        nil
      end
    end
    @data['OC']
  end

returns contents in the OG line.

OG Line; organella (0 or 1/entry)

 OG   Plastid; Chloroplast.
 OG   Mitochondrion.
 OG   Plasmid sym pNGR234a.
 OG   Plastid; Cyanelle.
 OG   Plasmid pSymA (megaplasmid 1).
 OG   Plasmid pNRC100, Plasmid pNRC200, and Plasmid pHH1.

[Source]

# File lib/bio/db/embl/common.rb, line 179
  def og
    unless @data['OG']
      og = Array.new
      if get('OG').size > 0
        ogstr = fetch('OG')
        ogstr.sub!(/\.$/,'')
        ogstr.sub!(/ and/,'')
        ogstr.sub!(/;/, ',')
        ogstr.split(',').each do |tmp|
          og.push(tmp.strip)
        end
      end
      @data['OG'] = og
    end
    @data['OG']
  end

returns contents in the OS line.

  • Bio::EMBLDB#os -> Array of <OS Hash>

where <OS Hash> is:

 [{'name'=>'Human', 'os'=>'Homo sapiens'},
  {'name'=>'Rat', 'os'=>'Rattus norveticus'}]
  • Bio::SPTR#os[0][‘name’] => "Human"
  • Bio::SPTR#os[0] => {‘name’=>"Human", ‘os’=>’Homo sapiens’}
  • Bio::STPR#os(0) => "Homo sapiens (Human)"

OS Line; organism species (>=1)

  "OS   Trifolium repens (white clover)"

  OS   Genus species (name).
  OS   Genus species (name0) (name1).
  OS   Genus species (name0) (name1).
  OS   Genus species (name0), G s0 (name0), and G s (name1).

[Source]

# File lib/bio/db/embl/common.rb, line 147
  def os(num = nil)
    unless @data['OS']
      os = Array.new
      fetch('OS').split(/, and|, /).each do |tmp|
        if tmp =~ /([A-Z][a-z]* *[\w\d \:\'\+\-]+[\w\d])/
          org = $1
          tmp =~ /(\(.+\))/ 
          os.push({'name' => $1, 'os' => org})
        else
          raise "Error: OS Line. #{$!}\n#{fetch('OS')}\n"
        end
      end
      @data['OS'] = os
    end
    if num
      # EX. "Trifolium repens (white clover)"
      "#{@data['OS'][num]['os']} {#data['OS'][num]['name']"
    end
    @data['OS']
  end

returns contents in the R lines.

where <reference information Hash> is:

 {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '',
  'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''}

R Lines

  • RN RC RP RX RA RT RL RG

[Source]

# File lib/bio/db/embl/common.rb, line 241
  def ref
    unless @data['R']
      ary = Array.new
      get('R').split(/\nRN   /).each do |str|
        raw = {'RN' => '', 'RC' => '', 'RP' => '', 'RX' => '', 
               'RA' => '', 'RT' => '', 'RL' => '', 'RG' => ''}
        str = 'RN   ' + str unless /^RN   / =~ str
        str.split("\n").each do |line|
          if /^(R[NPXARLCTG])   (.+)/ =~ line
            raw[$1] += $2 + ' '
          else
            raise "Invalid format in R lines, \n[#{line}]\n"
          end
        end
        raw.each_value {|v| 
          v.strip! 
          v.sub!(/^"/,'')
          v.sub!(/;$/,'')
          v.sub!(/"$/,'')
        }
        ary.push(raw)
      end
      @data['R'] = ary
    end
    @data['R']
  end

returns Bio::Reference object from Bio::EMBLDB::Common#ref.

[Source]

# File lib/bio/db/embl/common.rb, line 270
  def references
    unless @data['references']
      ary = self.ref.map {|ent|
        hash = Hash.new('')
        ent.each {|key, value|
          case key
          when 'RA'
            hash['authors'] = value.split(/, /)
          when 'RT'
            hash['title'] = value
          when 'RL'
            if value =~ /(.*) (\d+) \((\d+)\), (\d+-\d+) \((\d+)\)$/
              hash['journal'] = $1
              hash['volume']  = $2
              hash['issue']   = $3
              hash['pages']   = $4
              hash['year']    = $5
            else
              hash['journal'] = value
            end
          when 'RX'  # PUBMED, MEDLINE
            value.split('.').each {|item|
              tag, xref = item.split(/; /).map {|i| i.strip }
              hash[ tag.downcase ]  = xref
            }
          end
        }
        Reference.new(hash)
      }
      @data['references'] = References.new(ary)
    end
    @data['references']
  end

[Validate]