Class Genes (NCBI Entrez API)¶
Get gene’s info from NCBI entrez API (PubMed).
Downloads only necessary part of Entrez response, just enough to get all the tags you interested in (parameter fields, values from GeneFields). So we do not wait for full 2Mb entrez response but only for first 5-6Kb.
The easiest way to use - global genes object pre-created globally in this module:
entrez.genes[‘ppara’][GeneFields.summary]
If we use genes[] it searches for gene name case-insensitive (see canonical_gene_name). On other hand, all methods in the class search for gene name case-sensitive.
Caches results inside the class instance.
- class http_stream_xml.entrez.Genes(fields: List[str] | None = None, timeout: int = 30, max_bytes_to_fetch: int = 10240, api_key: str | None = None)¶
Genes class.
- api_key_query_param() str ¶
Get query parameter for Entrez API key.
- canonical_gene_name(gene_name: str) str ¶
Convert gene name to lower case to be case-insensitive when we search for gene name in the cache.
- clear_cache() None ¶
Clear all previously cached genes data so all information from this moment will be requested from NCBI server.
- get_details_url(gene_id: str) str ¶
Get URL to get gene details by gene ID.
- get_gene_details(gene_name: str) Dict[str, Any] ¶
Get gene details by gene name.
- get_gene_details_by_id(gene_id: str) Dict[str, Any] ¶
Download gene’s details from NCBI entrez API, using gene’s ID - see get_gene_id to obtain it.
- get_gene_id(gene_name: str) str | None ¶
Get gene ID by gene name.
- search_id_url(gene_name: str) str ¶
Get URL to search for gene ID by gene name.
- class http_stream_xml.entrez.GeneFields¶
Map gene fields to tag names in entrez’s result XML.
Usage example¶
from http_stream_xml import entrez
print(entrez.genes['myo5b'][entrez.GeneFields.description])