PubMed.py
This module provides code to work with PubMed from the NCBI.
http://www.ncbi.nlm.nih.gov/PubMed/
Online documentation for linking to PubMed is available at:
http://www.ncbi.nlm.nih.gov/PubMed/linking.html
Classes:
Dictionary Access PubMed articles using a dictionary interface.
Functions:
search_for Search PubMed.
find_related Find related articles in PubMed.
download_many Download many articles from PubMed in batch mode.
Imported modules
|
|
from Bio import File, Medline
from Bio.WWW import RequestLimiter, NCBI
import re
import sgmllib
import string
|
Functions
|
|
download_many
find_related
search_for
|
|
download_many
|
download_many (
ids,
callback_fn,
broken_fn=None,
delay=120.0,
faildelay=5.0,
batchsize=500,
parser=None,
)
download_many(ids, callback_fn, broken_fn=None, delay=120.0, batchsize=500)
Download many records from PubMed. ids is a list of either the
Medline Unique ID or the PubMed ID's of the articles. Each time a
record is downloaded, callback_fn is called with the text of the
record. broken_fn is an optional function that is called with the
id of records that were not able to be downloaded. delay is the
number of seconds to wait between requests. batchsize is the
number of records to request each time.
Exceptions
|
|
IOError
ValueError, "batchsize must be between 1 and 500"
|
|
|
find_related
|
find_related ( pmid )
find_related(pmid) -> ids
Search PubMed for a list of citations related to pmid. pmid can
be a PubMed ID, a MEDLINE UID, or a list of those.
Exceptions
|
|
SyntaxError, "I expected an ID, but '%s' doesn't look like one." % repr( data )
|
|
|
search_for
|
search_for (
search,
batchsize=10000,
delay=2,
callback_fn=None,
start_id=0,
max_ids=None,
)
search_for(search[, batchsize][, delay][, callback_fn]
[, start_id][, max_ids]) -> ids Search PubMed and return a list of the PMID's that match the
criteria. search is the search string used to search the
database. batchsize specifies the number of ids to return at one
time. By default, it is set to 10000, the maximum. delay is the
number of seconds to wait between queries (default 2).
callback_fn is an optional callback function that will be called
as passed a PMID as results are retrieved. start_id specifies the
index of the first id to retrieve and max_ids specifies the
maximum number of id's to retrieve.
Exceptions
|
|
SyntaxError, "I expected an ID, but %s doesn't look like one." % repr( data )
|
|
Classes
|
|
Dictionary |
Access PubMed using a read-only dictionary interface.
|
|
|