Skip to content

Biocommons HGVS example code

Dave Lawrence edited this page Mar 21, 2023 · 4 revisions

If you get HGVSDataNotAvailableError meaning sequences are not available - you may also want to look into using FastaSeqFetcher to provide transcripts

Convert transcript (c.) to genomic (g.)

import hgvs
from hgvs.assemblymapper import AssemblyMapper
from cdot.hgvs.dataproviders import JSONDataProvider, RESTDataProvider

hdp = RESTDataProvider()  # Uses API server at cdot.cc
# hdp = JSONDataProvider(["./cdot-0.2.14.refseq.grch37.json.gz"])  # Uses local JSON file

am = AssemblyMapper(hdp,
                    assembly_name='GRCh37',
                    alt_aln_method='splign', replace_reference=True)

hp = hgvs.parser.Parser()
var_c = hp.parse_hgvs_variant('NM_001637.3:c.1582G>A')
am.c_to_g(var_c)

Convert genomic (g.) to transcript (c.)

from cdot.hgvs.dataproviders import JSONDataProvider, RESTDataProvider
import hgvs.parser
import hgvs.assemblymapper

hp = hgvs.parser.Parser()
hdp = RESTDataProvider()
am = hgvs.assemblymapper.AssemblyMapper(hdp,
					assembly_name='GRCh37', alt_aln_method='splign',
					replace_reference=True)

var_g = hp.parse_hgvs_variant('NC_000007.13:g.36561662C>T')
am.g_to_c(var_g, 'NM_001637.3')