class Bio::PubMed

Description

The Bio::PubMed class provides several ways to retrieve bibliographic information from the PubMed database at NCBI.

Basically, two types of queries are possible:

Since BioRuby 1.5, all implementations uses NCBI E-Utilities services. The different methods within the same group still remain because specifications of arguments and/or return values are different. The search, query, and pmfetch will be obsoleted in the future.

Additional information about the MEDLINE format and PubMed programmable APIs can be found on the following websites:

Usage

require 'bio'

# If you don't know the pubmed ID:
Bio::PubMed.esearch("(genome AND analysis) OR bioinformatics").each do |x|
  p x
end

Bio::PubMed.search("(genome AND analysis) OR bioinformatics").each do |x|
  p x
end

# To retrieve the MEDLINE entry for a given PubMed ID:
Bio::PubMed.efetch("10592173").each { |x| puts x }
puts Bio::PubMed.query("10592173")
puts Bio::PubMed.pmfetch("10592173")

# To retrieve MEDLINE entries for given PubMed IDs:
Bio::PubMed.efetch([ "10592173", "14693808" ]).each { |x| puts x }
puts Bio::PubMed.query("10592173", "14693808") # returns a String

# This can be converted into a Bio::MEDLINE object:
manuscript = Bio::PubMed.query("10592173")
medline = Bio::MEDLINE.new(manuscript)

Public Class Methods

efetch(*args) click to toggle source

The same as Bio::PubMed.new.efetch(*args).

    # File lib/bio/io/pubmed.rb
190 def self.efetch(*args)
191   self.new.efetch(*args)
192 end
esearch(*args) click to toggle source

The same as Bio::PubMed.new.esearch(*args).

    # File lib/bio/io/pubmed.rb
185 def self.esearch(*args)
186   self.new.esearch(*args)
187 end
pmfetch(*args) click to toggle source

This method will be DEPRECATED. Use efetch method.

The same as Bio::PubMed.new.pmfetch(*args).

    # File lib/bio/io/pubmed.rb
211 def self.pmfetch(*args)
212   self.new.pmfetch(*args)
213 end
query(*args) click to toggle source

This method will be DEPRECATED. Use efetch method.

The same as Bio::PubMed.new.query(*args).

    # File lib/bio/io/pubmed.rb
204 def self.query(*args)
205   self.new.query(*args)
206 end

Public Instance Methods

efetch(ids, hash = {}) click to toggle source

Retrieve PubMed entry by PMID and returns MEDLINE formatted string using entrez efetch. Multiple PubMed IDs can be provided:

Bio::PubMed.efetch(123)
Bio::PubMed.efetch([123,456,789])

Arguments:

  • ids: list of PubMed IDs (required)

  • hash: hash of E-Utils options

    • _“retmode”_: “xml”, “html”, …

    • _“rettype”_: “medline”, …

    • _“retmax”_: integer (default 100)

    • _“retstart”_: integer

    • _“field”_

    • _“reldate”_

    • _“mindate”_

    • _“maxdate”_

    • _“datetype”_

Returns

Array of MEDLINE formatted String

Calls superclass method Bio::NCBI::REST#efetch
    # File lib/bio/io/pubmed.rb
116 def efetch(ids, hash = {})
117   opts = { "db" => "pubmed", "rettype"  => "medline" }
118   opts.update(hash)
119   result = super(ids, opts)
120   if !opts["retmode"] or opts["retmode"] == "text"
121     result = result.split(/\n\n+/)
122   end
123   result
124 end
esearch(str, hash = {}) click to toggle source

Search the PubMed database by given keywords using E-Utils and returns an array of PubMed IDs.

For information on the possible arguments, see eutils.ncbi.nlm.nih.gov/entrez/query/static/esearch_help.html#PubMed


Arguments:

  • str: query string (required)

  • hash: hash of E-Utils options

    • _“retmode”_: “xml”, “html”, …

    • _“rettype”_: “medline”, …

    • _“retmax”_: integer (default 100)

    • _“retstart”_: integer

    • _“field”_

    • _“reldate”_

    • _“mindate”_

    • _“maxdate”_

    • _“datetype”_

Returns

array of PubMed IDs or a number of results

Calls superclass method Bio::NCBI::REST#esearch
   # File lib/bio/io/pubmed.rb
92 def esearch(str, hash = {})
93   opts = { "db" => "pubmed" }
94   opts.update(hash)
95   super(str, opts)
96 end
pmfetch(id) click to toggle source

This method will be DEPRECATED in the future.

Retrieve PubMed entry by PMID and returns MEDLINE formatted string.


Arguments:

Returns

MEDLINE formatted String

    # File lib/bio/io/pubmed.rb
173 def pmfetch(id)
174   warn "Bio::PubMed#pmfetch internally use Bio::PubMed#efetch. Using Bio::PubMed#efetch is recommended." if $VERBOSE
175 
176   ret = efetch(id)
177   if ret && ret.size > 0 then
178     ret.join("\n\n") + "\n"
179   else
180     ""
181   end
182 end
query(*ids) click to toggle source

This method will be DEPRECATED in the future.

Retrieve PubMed entry by PMID and returns MEDLINE formatted string using entrez query.


Arguments:

Returns

MEDLINE formatted String

    # File lib/bio/io/pubmed.rb
155 def query(*ids)
156   warn "Bio::PubMed#query internally uses Bio::PubMed#efetch. Using Bio::PubMed#efetch is recommended." if $VERBOSE
157   ret = efetch(ids)
158   if ret && ret.size > 0 then
159     ret.join("\n\n") + "\n"
160   else
161     ""
162   end
163 end