Skip to main content

Metapub is a Python library that provides python objects fetched via eutils that represent papers and concepts found within the NLM.

These objects abstract some interactions with pubmed, and intends to encompass as many types of database lookups and summaries as can be provided via Eutils / Entrez.

PubMedArticle / PubMedFetcher

Basic usage:

fetch = PubMedFetcher()
article = fetch.article_by_pmid('123456')
print article.title
print article.journal, article.year, article.volume, article.issue
print article.authors

PubMedFetcher also includes the following special methods.

article_by_doi: (attempt to) fetch an article by looking up the DOI first.

article_by_pmcid: fetch an article by looking up the PMCID first.

pmids_from_citation: produces a list of possible PMIDs for the submitted

citation, where the citation is submitted as a collection of keyword arguments. At least 3 of the 5, preferably 4 or 5 for best results, must be included:

aulast or author_last_fm1
year
volume
first_page or spage
journal or jtitle

(Note this function is still very “alpha”. Citation lookups prefer Medline XML style journal strings, so use those when possible.)

metapub.pubmedcentral.*

The PubMedCentral functions are a loose collection of conversion methods for academic publishing IDs, allowing conversion (where possible) between the following ID types:

doi (Digital object identifier)
pmid (PubMed ID)
pmcid (Pubmed Central ID (including versioned document ID)

The following methods are supplied, returning a string (if found) or None:

get_pmid_for_otherid(string)
get_doi_for_otherid(string)
get_pmcid_for_otherid(string)

As implied by the function names, you can supply any valid ID type (“otherid”) to acquire the desired ID type.

MedGenConcept / MedGenFetcher

Basic usage:

fetch = MedGenFetcher()
concept = fetch.concept_by_uid('336867')
print concept.name
print concept.description
print concept.associated_genes
print concept.modes_of_inheritance

CrossRef

The CrossRef object provides an object layer into search.crossref.org’s API. See http://search.crossref.org

CrossRef excels at resolving DOIs into article citation details.

CrossRef can also be used to resolve a DOI /from/ article citation details, with a bit of finagling. The “get_top_result” function was built to do some light interpretation of the json-based results of a CrossRef lookup.

Result scores under 2.0 are usually False matches. Result scores over 3.0 are always (?) True. Between 2.0 and 3.0 is a grey area: be wary and check results against any known info you may have.

Current testing (as of 1/23/2015) indicates that a cleverly-formed CrossRef query can return results 99% correct about 90% of the time.

The more params submitted with the query, the more accurate the results may be.

Basic usage:

CR = CrossRef()       # starts the query cache engine
results = CR(search_string, params)
top_result = CR.get_top_result(results)

Example starting from a known pubmed ID:

pma = PubMedFetcher().article_by_pmid(known_pmid)
results = CR.query_from_PubMedArticle(pma)
top_result = CR.get_top_result(results, CR.last_params, use_best_guess=True)

NOTE: if you don’t supply “CR.last_params”, you can’t use the “use_best_guess” operator. In cases where all results have scores under 2, no results will be returned unless use_best_guess=True. That’s often desired behavior, since results with scores under 2 are usually pretty bad.

About, and a Disclaimer

Metapub relies on the very neat eutils package created by Reece Hart, which you can check out here:

http://bitbucket.org/biocommons/eutils

This library is in its very early stages and there’s a lot that may change, and quite a bit planned for implementation in 2015.

Feel free to use the library with confidence that each released version is well tested – and in a couple of cases, some of its code is already in production – but until (say) version 0.5, don’t expect consistency between versions.

YMMV, At your own risk, etc.

–Naomi Most (@nthmost)

Release files for metapub 0.3.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for metapub 0.3.2.2
File Size Uploaded
metapub-0.3.2.2.tar.gz 24.9 kB Details

Release files / metapub-0.3.2.2.tar.gz

Download URL metapub-0.3.2.2.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
09ec0f31f1a8ef0468219fac427ceadc310853659798dea346d431d8059a985f
BLAKE2b-256 checksum
How to use checksums
d5b999c0957ad3ab05ef3db9f0ffbd81e48fa39c677498c4d568be963832e30b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.12

2 release files

0.5.9

1 release file

0.5.8

1 release file

0.5.7

2 release files

0.5.6

1 release file

0.5.5

1 release file

0.5.3

1 release file

0.5.1

1 release file

0.5

1 release file

0.4.3.6

1 release file

0.4.3.5

1 release file

0.4.3.1

1 release file

0.4.3

1 release file

0.4.1

1 release file

0.4.0.1

1 release file

0.4.0

1 release file

0.3.17

1 release file

0.3.15

1 release file

0.3.14

1 release file

0.3.13

1 release file

0.3.12

1 release file

0.3.10

1 release file

0.3.8.9

1 release file

0.3.8.8

1 release file

0.3.8.7

1 release file

0.3.8.5

1 release file

0.3.8.4

1 release file

0.3.8.3

1 release file

0.3.8.2

1 release file

0.3.7

1 release file

0.3.6

1 release file

0.3.5.1

1 release file

0.3.5

1 release file

0.3.4.6

1 release file

0.3.4.5

1 release file

0.3.4.4

1 release file

0.3.4

1 release file

0.3.3.5

1 release file

0.3.3.4

1 release file

0.3.3

1 release file

This release

0.3.2.2 This release

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3.1

1 release file

0.2.3

1 release file

0.2.2.1

1 release file

0.2.2

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5.4

1 release file

0.0.5.3

1 release file

0.0.5.1

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page