Module: Bio::NCBI::REST::ESearch::Methods

Included in:
Bio::NCBI::REST::ESearch, Bio::NCBI::REST::ESearch
Defined in:
lib/bio/io/ncbirest.rb

Overview

Search database entries by given keywords using E-Utils (esearch).

sequences = gene + genome + nucleotide + protein + popset + snp
nucleotide = nuccore + nucest + nucgss
pubmed protein nucleotide nuccore nucgss nucest structure genome
books cancerchromosomes cdd gap domains gene genomeprj gensat geo
gds homologene journals mesh ncbisearch nlmcatalog omia omim pmc
popset probe proteinclusters pcassay pccompound pcsubstance snp
taxonomy toolkit unigene unists

Usage

Bio::NCBI::REST::ESearch.search("nucleotide", "tardigrada")
Bio::NCBI::REST::ESearch.count("nucleotide", "tardigrada")

Bio::NCBI::REST::ESearch.nucleotide("tardigrada")
Bio::NCBI::REST::ESearch.popset("aldh2")
Bio::NCBI::REST::ESearch.taxonomy("tardigrada")
Bio::NCBI::REST::ESearch.pubmed("tardigrada", "reldate" => 365)
Bio::NCBI::REST::ESearch.pubmed("mammoth mitochondrial genome")
Bio::NCBI::REST::ESearch.pmc("Indonesian coelacanth genome Latimeria menadoensis")
Bio::NCBI::REST::ESearch.journal("bmc bioinformatics")

ncbi = Bio::NCBI::REST::ESearch.new
ncbi.search("nucleotide", "tardigrada")
ncbi.count("nucleotide", "tardigrada")

ncbi.nucleotide("tardigrada")
ncbi.popset("aldh2")
ncbi.taxonomy("tardigrada")
ncbi.pubmed("tardigrada", "reldate" => 365)
ncbi.pubmed("mammoth mitochondrial genome")
ncbi.pmc("Indonesian coelacanth genome Latimeria menadoensis")
ncbi.journal("bmc bioinformatics")

Arguments:

  • term: search keywords (required)

  • limit: maximum number of entries to be returned (0 for unlimited)

  • hash: hash of E-Utils option

Returns

array of entry IDs or a number of results

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object

nucleotide(“tardigrada”) nucleotide(“tardigrada”, 0) pubmed(“tardigrada”) pubmed(“tardigrada”, 5) pubmed(“tardigrada”, “reldate” => 365) pubmed(“tardigrada”, 5, “reldate” => 365) pubmed(“tardigrada”, => 365, 5)



449
450
451
# File 'lib/bio/io/ncbirest.rb', line 449

def method_missing(*args)
  self.search(*args)
end

Instance Method Details

#count(db, term, hash = {}) ⇒ Object

count(“nucleotide”, “tardigrada”) count(“pubmed”, “tardigrada”) count(“journals”, “bmc”)



436
437
438
439
440
# File 'lib/bio/io/ncbirest.rb', line 436

def count(db, term, hash = {})
  opts = { "db" => db }
  opts.update(hash)
  Bio::NCBI::REST.esearch_count(term, opts)
end

#est(*args) ⇒ Object

alias for “nucest”



459
460
461
# File 'lib/bio/io/ncbirest.rb', line 459

def est(*args)
  self.search("nucest", *args)
end

#gss(*args) ⇒ Object

alias for “nucgss”



464
465
466
# File 'lib/bio/io/ncbirest.rb', line 464

def gss(*args)
  self.search("nucgss", *args)
end

#journal(*args) ⇒ Object

alias for journals



454
455
456
# File 'lib/bio/io/ncbirest.rb', line 454

def journal(*args)
  self.search("journals", *args)
end

#search(db, term, *args) ⇒ Object

search(“nucleotide”, “tardigrada”) search(“nucleotide”, “tardigrada”, 0) # unlimited search(“pubmed”, “tardigrada”) search(“pubmed”, “tardigrada”, 5) # first five search(“pubmed”, “tardigrada”, “reldate” => 365) # within a year search(“pubmed”, “tardigrada”, 5, “reldate” => 365) # combination search(“pubmed”, “tardigrada”, => 365, 5) # combination 2 search(“journals”, “bmc”, 10)



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/bio/io/ncbirest.rb', line 417

def search(db, term, *args)
  limit = 100
  hash = {}
  args.each do |arg|
    case arg
    when Hash
      hash.update(arg)
    else
      limit = arg.to_i
    end
  end
  opts = { "db" => db }
  opts.update(hash)
  Bio::NCBI::REST.esearch(term, opts, limit)
end