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
In : import myvariant In : mv = myvariant.MyVariantInfo()
which provides four methods:
- getvariant to retrieve the annotations for a given variant by its HGVS-based variant id:
- getvariants to retrieve the annotations for a list of variants by their HGVS ids:
- query to query matching variants with rich and flexible query syntax:
- 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 : myvariant.format_hgvs("1", 35366, "C", "T") Out: 'chr1:g.35366C>T' In : myvariant.format_hgvs('2', 17142, "G", "GA") Out: 'chr2:g.17142_17143insA' In : myvariant.format_hgvs("MT", 8270, "CACCCCCTCT", "C") Out: 'chrMT:g.8271_8279del' In : myvariant.format_hgvs("X", 107930849, "GGA", "C") Out: '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.