MyVariant.py: our Python client for MyVariant.info services

We are happy to announce that the official Python client ("MyVariant.py") for our MyVariant.info web services is now available from PyPI (the Python Package Index).

MyVariant.py allows users to annotate or query for human variants, either a single variant or a list of variants, without making explicit GET or POST web service calls. This is especially convenient for users who are already handling a large number of variants using Python scripts.

Backed by the high-performance MyVariant.info web services, MyVariant.py can access integrated annotations for over 280M variants, including annotations from ClinVar, COSMIC, CADD, ExAC , etc (see here for the complete list of data sources). We always keep the annotations up-to-date and keep expanding the data sources, so that users don't have to download and maintain their own local copy of annotation databases.

To give it a try, simply install it via pip:

pip install myvariant  

The core functionality of MyVariant.py package is encapsulated in its MyVariantInfo class:

In [1]: import myvariant  
In [2]: mv = myvariant.MyVariantInfo()

which provides four methods:

mv.getvariant("chr7:g.140453134T>C")  
  • getvariants to retrieve the annotations for a list of variants by their HGVS ids:
mv.getvariants(['chr1:g.866422C>T', 'chr1:g.876664G>A','chr1:g.69635G>C'])  
mv.query("cosmic.tumor_site:liver", fields='cosmic')  
  • querymany to query matching variants for a list of alternative ids or query terms:
mv.querymany(['RCV000083620', 'RCV000083584'],  
scopes='clinvar.rcv_accession', fields='clinvar')  

To help generate the valid HGVS-ids from popular VCF-style chrom, pos, alt, ref values, a helper function myvariant.format_hgvs is also provided:

In [3]: myvariant.format_hgvs("1", 35366, "C", "T")  
Out[3]: 'chr1:g.35366C>T'

In [4]: myvariant.format_hgvs('2', 17142, "G", "GA")  
Out[4]: 'chr2:g.17142_17143insA'

In [5]: myvariant.format_hgvs("MT", 8270, "CACCCCCTCT", "C")  
Out[5]: 'chrMT:g.8271_8279del'

In [6]: myvariant.format_hgvs("X", 107930849, "GGA", "C")  
Out[6]: 'chrX:g.107930849_107930851delinsC'  

You can find more usage examples from MyVariant.py PyPI page. The detailed API documentation can be found at http://myvariant-py.readthedocs.org . If you dive even deeper, you may find our extensive test code here can also serve as pretty good usage examples.

Feedbacks? We are always available at help@myvariant.info or @myvariantinfo.