Just in time for the holidays--a brand new BioThings python client

biothings mygene.py mygene myvariant.py myvariant.info mygene.info python mychem.info

The BioThings python client is an easy-to-use Python wrapper to access any of the Biothings.api -based backend services including those for MyGene.info, MyVariant.info, MyChem.info and more! It was built from abstracting and unifying a lot of code from across the different APIs making it both the descendent and eventual replacement of existing BioThings API python clients like MyGene.py and MyVariant.py. With extensibility in mind, this new biothings_client can be the universal python client for future BioThings APIs or any other user APIs built with the BioThings SDK!

biothings-ring-1692713_640

For ease of installation, the client can be obtained from PyPI and installed like any other PyPI package.

pip install biothings_client

Other installation methods are also available, and you can get the latest release from the github repo

Once installed, you can use it to pull different annotions from the different biothings APIs. For example, you could pull gene annotations by first calling the gene client within biothings: mg = biothings_client.get_client("gene") and then using the client as you would the MyGene python client.

To clarify, here's a side-by-side comparison for pulling gene and variant annotations using the BioThings python client vs using both the MyGene and MyVariant python clients.

  BioThings client MyGene and MyVariant client
Installation pip install biothings_client pip install mygene
pip install myvariant
Import import biothings_client
mg = biothings_client.get_client("gene")
mv = biothings_client.get_client("variant")
import mygene
import mvariant
mg = mygene.MyGeneInfo()
mv = myvariant.MyVariantInfo()
Use mg.getgene(1017, 'name,symbol,refseq') mg.getgene(1017, 'name,symbol,refseq')

One key difference is that the BioThings client allows pythonic access to APIs that do not currently have standalone python clients. For example, drug or chemical annotations from the MyChem.info API can be pulled by calling the chem client within the BioThings client.

For ease, you can call the chem client either using the term chem or drug as so:
chem_client = biothings_client.get_client("chem") or
drug_client = biothings_client.get_client("drug").

Additionally, you can use the disease or taxon clients in a similar fashion. Learn more about the BioThings client from the documentation.

Lastly, data for MyGene.info, MyVariant.info, and MyChem.info was updated earlier this week. For more details, visit the data update histories for MyGene, MyVariant, or MyChem.

Now go forth and query!