Skip to main content

Python Client for BioThings API services.

Project description

https://badge.fury.io/py/biothings-client.svg https://img.shields.io/pypi/pyversions/biothings-client.svg https://img.shields.io/pypi/format/biothings-client.svg https://github.com/biothings/biothings_client.py/actions/workflows/build-package.yml/badge.svg https://github.com/biothings/biothings_client.py/actions/workflows/run-tests.yml/badge.svg Codacy Badge Codacy Coverage Badge PyPI Downloads Documentation Status

Intro

biothings_client is an easy-to-use Python wrapper to access any Biothings.api -based backend service. Currently, the following clients are available:

  • gene - The client for MyGene.Info, which provides access to gene objects.

  • variant - The client MyVariant.Info, which provides access to genetic variant objects.

  • chem - The client for MyChem.Info, which provides access to chemical/drug objects.

  • disease - The client for MyDisease.Info, which provides access to disease objects.

  • geneset - The client for MyGeneset.Info, which provides access to geneset/pathway objects.

  • taxon - The client for MyTaxon.Info, which provides access to taxon objects.

Support

Python >=3.7

Optional dependencies

  • dataframe support (install using pip install biothings_client[dataframe])

    pandas is required for returning query results as a DataFrame.

  • caching support (install using pip install biothings_client[caching], requires Python >=3.8)

    Allows local caching of client queries to a SQLite database. Requires:

Installation

  • Option 1. Install from pypi repository using pip:

    pip install biothings_client
  • Option 2. Install the latest commit from the github repository using pip:

    pip install -e git+https://github.com/biothings/biothings_client.py#egg=biothings_client

Version history

CHANGES.txt

Tutorial

See the quick start tutorial at the biothings_client doc page.

Documentation

https://biothings-clientpy.readthedocs.io

Usage

  • Synchronous client.

    from biothings_client import get_client
    
    # get a client for variant objects
    mv = get_client("variant")
    
    mv.getvariant("chr7:g.140453134T>C")
    
    # output below is collapsed
    {"_id": "chr7:g.140453134T>C",
     "_version": 1,
     "chrom": "7",
     "cadd": {...},
     "clinvar": {...},
     "cosmic": {...},
     "dbnsfp": {...},
     "dbsnp": {...},
     "docm": {...},
     "hg19": {'end': 140453134, 'start': 140453134},
     "mutdb": {...},
     "snpeff": {...},
     "vcf": {
        "alt": "C",
        "position": "140453134",
        "ref": "T"
     }}
    
    # get a client for gene objects
    mg = get_client("gene")
    
    mg.getgene(1017, 'name,symbol,refseq')
    
    {'_id': '1017',
     '_score': 21.03413,
     'name': 'cyclin dependent kinase 2',
     'refseq': {'genomic': ['NC_000012.12', 'NC_018923.2', 'NG_034014.1'],
      'protein': ['NP_001277159.1',
       'NP_001789.2',
       'NP_439892.2',
       'XP_011536034.1'],
      'rna': ['NM_001290230.1', 'NM_001798.4', 'NM_052827.3', 'XM_011537732.1'],
      'translation': [{'protein': 'NP_001789.2', 'rna': 'NM_001798.4'},
       {'protein': 'NP_439892.2', 'rna': 'NM_052827.3'},
       {'protein': 'NP_001277159.1', 'rna': 'NM_001290230.1'},
       {'protein': 'XP_011536034.1', 'rna': 'XM_011537732.1'}]},
     'symbol': 'CDK2'}
    
    # get a client for chems/drugs
    md = get_client("chem")
    
    md.getchem("ATBDZSAENDYQDW-UHFFFAOYSA-N", fields="pubchem")
    
    {'_id': 'ATBDZSAENDYQDW-UHFFFAOYSA-N',
     '_version': 1,
     'pubchem': {'chiral_atom_count': 0,
      'chiral_bond_count': 0,
      'cid': 'CID4080429',
      'complexity': 250,
      'covalently-bonded_unit_count': 1,
      'defined_atom_stereocenter_count': 0,
      'defined_bond_stereocenter_count': 0,
      'exact_mass': 184.019415,
      'formal_charge': 0,
      'heavy_atom_count': 12,
      'hydrogen_bond_acceptor_count': 3,
      'hydrogen_bond_donor_count': 1,
      'inchi': 'InChI=1S/C8H8O3S/c1-2-7-4-3-5-8(6-7)12(9,10)11/h2-6H,1H2,(H,9,10,11)',
      'inchi_key': 'ATBDZSAENDYQDW-UHFFFAOYSA-N',
      'isotope_atom_count': 0,
      'iupac': {'traditional': '3-vinylbesylic acid'},
      'molecular_formula': 'C8H8O3S',
      'molecular_weight': 184.21232,
      'monoisotopic_weight': 184.019415,
      'rotatable_bond_count': 2,
      'smiles': {'isomeric': 'C=CC1=CC(=CC=C1)S(=O)(=O)O'},
      'tautomers_count': 1,
      'topological_polar_surface_area': 62.8,
      'undefined_atom_stereocenter_count': 0,
      'undefined_bond_stereocenter_count': 0,
      'xlogp': 1.4}}
    
    # get a client for taxa
    mt = get_client("taxon")
    
    mt.gettaxon(9606)
    
    {'_id': '9606',
     '_version': 1,
     'authority': ['homo sapiens linnaeus, 1758'],
     'common_name': 'man',
     'genbank_common_name': 'human',
     'has_gene': True,
     'lineage': [9606,
      9605,
      207598,
      9604,
      314295,
      9526,
      314293,
      376913,
      9443,
      314146,
      1437010,
      9347,
      32525,
      40674,
      32524,
      32523,
      1338369,
      8287,
      117571,
      117570,
      7776,
      7742,
      89593,
      7711,
      33511,
      33213,
      6072,
      33208,
      33154,
      2759,
      131567,
      1],
     'other_names': ['humans'],
     'parent_taxid': 9605,
     'rank': 'species',
     'scientific_name': 'homo sapiens',
     'taxid': 9606,
     'uniprot_name': 'homo sapiens'}
  • Asynchronous client.

    from biothings_client import get_async_client
    
    # get a client for variant objects
    mv = get_async_client("variant")
    await mv.getvariant("chr7:g.140453134T>C")
    
    # get a client for gene objects
    mg = get_async_client("gene")
    await mg.getgene(1017, 'name,symbol,refseq')
    
    # get a client for chems/drugs
    md = get_async_client("chem")
    await md.getchem("ATBDZSAENDYQDW-UHFFFAOYSA-N", fields="pubchem")
    
    # get a client for taxa
    mt = get_async_client("taxon")
    await mt.gettaxon(9606)

Contact

Drop us any feedback @biothingsapi

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

biothings_client-0.5.0.tar.gz (61.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

biothings_client-0.5.0-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file biothings_client-0.5.0.tar.gz.

File metadata

  • Download URL: biothings_client-0.5.0.tar.gz
  • Upload date:
  • Size: 61.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for biothings_client-0.5.0.tar.gz
Algorithm Hash digest
SHA256 f9fddc7436d59bcde4f9a2501431fc744d142062ac4796585470adca29c59ed4
MD5 6a0fe8a1ccb70d7d9ba135feab34e08f
BLAKE2b-256 0d9e35cc3aa9f12ab0c125ce95a0164208ae2519fa899a4e924b95b03b6b82a4

See more details on using hashes here.

File details

Details for the file biothings_client-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for biothings_client-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 733488a5133bb6833a43cc895ad122654d8c72446926301d8607df0a9888c004
MD5 f433f92b04c120d59bb3f7be18c7a1a8
BLAKE2b-256 e21c521a3a0f662ab5484c44895e156964c3f299a564d569d1c96bee112e0c4d

See more details on using hashes here.

Supported by

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