Sha256: cb5a45ca35fe491e7fed017bdba9ff2aafda05865ae3fa1be79f5d959bf6f669

Contents?: true

Size: 1.55 KB

Versions: 9

Compression:

Stored size: 1.55 KB

Contents

#
# = bio/shell/plugin/ncbirest.rb - plugin for NCBI eUtils
#
# Copyright::   Copyright (C) 2009
#               Naohisa Goto <ng@bioruby.org>
# License::     The Ruby License
#
# $Id:$
#

module Bio::Shell

  private

  # NCBI eUtils EFetch service.
  #
  # With 1 argument, it gets sequence(s) by using
  # Bio::NCBI::REST::EFetch.sequence.
  # Nucleotide or protein database is automatically selected for each id.
  #
  # Example:
  #   efetch('AF237819')
  # 
  # With two or more arguments, and when the 2nd argument is Symbol,
  # it calls the corresponding Bio::NCBI::REST::EFetch class method.
  #
  # Example:
  #   efetch('13054692', :pubmed)
  #   # the same as Bio::NCBI::REST::EFetch.pubmed('13054692')
  #
  # Otherwise, it acts the same as Bio::NCBI::REST.efetch.
  def efetch(ids, *arg)
    if arg.empty? then
      ret = Bio::NCBI::REST::EFetch.nucleotide(ids)
      unless /^LOCUS       / =~ ret.to_s then
        ret = Bio::NCBI::REST::EFetch.protein(ids)
      end
      ret
    elsif arg[0].kind_of?(Symbol)
      meth = arg[0]
      case meth.to_s
      when /\A(journal|omim|pmc|pubmed|sequence|taxonomy)\z/
        Bio::NCBI::REST::EFetch.__send__(meth, ids, *(arg[1..-1]))
      else
        nil
      end
    else
      Bio::NCBI::REST.efetch(ids, *arg)
    end
  end

  # NCBI eUtils EInfo
  def einfo
    Bio::NCBI::REST.einfo
  end

  # NCBI eUtils ESearch
  def esearch(str, *arg)
    Bio::NCBI::REST.esearch(str, *arg)
  end

  # Same as Bio::NCBI::REST.esearch_count
  def esearch_count(str, *arg)
    Bio::NCBI::REST.esearch_count(str, *arg)
  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
bio-shell-1.0.1 lib/bio/shell/plugin/ncbirest.rb
bio-shell-1.0.0 lib/bio/shell/plugin/ncbirest.rb
bio-1.5.2 lib/bio/shell/plugin/ncbirest.rb
bio-shell-0.0.0 lib/bio/shell/plugin/ncbirest.rb
bio-1.5.1 lib/bio/shell/plugin/ncbirest.rb
bio-1.5.0 lib/bio/shell/plugin/ncbirest.rb
bio-1.4.3.0001 lib/bio/shell/plugin/ncbirest.rb
bio-1.4.3 lib/bio/shell/plugin/ncbirest.rb
bio-1.4.2 lib/bio/shell/plugin/ncbirest.rb