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:
-
searching for
PubMed
IDs given a query string:-
Bio::PubMed#esearch
(recommended) -
Bio::PubMed#search
(only retrieves top 20 hits; will be deprecated)
-
-
retrieving the
MEDLINE
text (i.e. authors, journal, abstract, …) given aPubMed
ID-
Bio::PubMed#efetch
(recommended) -
Bio::PubMed#query
(will be deprecated) -
Bio::PubMed#pmfetch
(will be deprecated)
-
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:
-
PubMed
Tutorial: www.nlm.nih.gov/bsd/disted/pubmedtutorial/index.html -
E-utilities Quick Start: www.ncbi.nlm.nih.gov/books/NBK25500/
-
Creating a Web Link to PubMed: www.ncbi.nlm.nih.gov/books/NBK3862/
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
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
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
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
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
This method will be DEPRECATED. Use esearch method.
The same as Bio::PubMed.new.search(*args).
# File lib/bio/io/pubmed.rb 197 def self.search(*args) 198 self.new.search(*args) 199 end
Public Instance Methods
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
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
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
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
This method will be DEPRECATED in the future.
Retrieve PubMed
entry by PMID and returns MEDLINE
formatted string.
Arguments:
-
id:
PubMed
ID (required)
- 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
This method will be DEPRECATED in the future.
Retrieve PubMed
entry by PMID and returns MEDLINE
formatted string using entrez query.
Arguments:
-
id:
PubMed
ID (required)
- 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
This method will be DEPRECATED in the future.
Search the PubMed
database by given keywords using entrez query and returns an array of PubMed
IDs.
Caution: this method returns the first 20 hits only,
Instead, use of the ‘esearch’ method is strongly recomended.
Implementation details: Since BioRuby 1.5, this method internally uses NCBI
EUtils with retmax=20 by using Bio::PubMed#efetch
method.
Arguments:
-
id: query string (required)
- Returns
-
array of
PubMed
IDs
# File lib/bio/io/pubmed.rb 142 def search(str) 143 warn "Bio::PubMed#search is now a subset of Bio::PubMed#esearch. Using Bio::PubMed#esearch is recommended." if $VERBOSE 144 esearch(str, { "retmax" => 20 }) 145 end