Skip to main content

A library for accessing NCBI Entrez databases.

Project description

entrez_utils

This library allows you to access information in remote Entrez databases from Python.

Examples

Creating an EntrezManager

An EntrezManager controls communication with the Entrez databases via HTTP requests. The class is aware of the methods supported by the Entrez API and ensures that the rate limits are not exceeded.

NCBI requests that the email address of the user be sent with requests, so an email is required to construct an EntrezManager.

from entrez_utils import EntrezManager

man = EntrezManager("foo@example.com")

Accessing a record

Most objects can be constructed with either an accession or an Entrez ID.

from entrez_utils import BioProject, BioSample, SRAExperiment, SRARun

project = BioProject(man, accession="PRJNA293777")
sample = BioSample(man, entrez_id="4009779")
experiment = SRAExperiment(man, accession="SRX4958339")
run = SRARun(man, accession="SRR8137396	")

Getting linked records

Properties of a record can be used to get other linked records. For example, this code gets the samples associated with a project.

samples = project.samples

Accessing raw XML

The Python objects representing Entrez records do not expose all possible data from the XML through their properties. The xml attribute give access to a parsed version of the raw XML associated with the record.

xml = project.xml

Batch fetching objects

The XML for a record is ordinarily retrieved lazily, but separately fetching XML for many records can be time consuming. To speed up the process, you can use fetch_all to fetch many records' XML at once.

samples = project.samples
fetch_all(samples)

The fetched function runs fetch_all on its argument and returns the argument, so it can be used to make the code above more concise.

samples = fetched(project.sample)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entrez_utils-0.0.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

entrez_utils-0.0.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file entrez_utils-0.0.1.tar.gz.

File metadata

  • Download URL: entrez_utils-0.0.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for entrez_utils-0.0.1.tar.gz
Algorithm Hash digest
SHA256 c4ea103d2361f9232cbe57a734eb71e7658d4f4b90a9ec453d4b33984cfc27c6
MD5 064d79cdb34878aa41af11b4c120cfbb
BLAKE2b-256 8d3d7ef50b6bf8db40f1e9b808432e93afd5612eefdd654491c3b434ab4141a0

See more details on using hashes here.

File details

Details for the file entrez_utils-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for entrez_utils-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 10dc2b31a9e5cb5ba5e2b6e80e8984b2f82aba214f5baf918138169bdac9d267
MD5 b1b3a399a308415b203b7734a5989491
BLAKE2b-256 b32138c2f21e1003a763a7369d43935dbafd75a986a6da32da379e043f153a72

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page