Entering edit mode
3.0 years ago
ThePlaintiff
▴
90
Is there a tool that maps rsids to their corresponding location on the chromosome based on a genome build? I wrote a function that extracts chromosomal position from ensembl REST API output but I strongly feel that there is an easier way. Here is a function that I wrote in Python
def map_rsid(rsid):
global EnsemblServer
ext = f"/variant_recoder/human/{rsid}?"
r = requests.get(EnsemblServer+ext, headers={ "Content-Type" : "application/json"})
if not r.ok:
r.raise_for_status()
sys.exit()
decoded = r.json()
pos_cmplx = decoded[0]['T'].get('hgvsg')[0].split('.')[1:]
chrom = pos_cmplx[0].split(':')[0]
pos = pos_cmplx[1].split('>')[0][:-1]
merged_id = f'{chrom}:{pos}'
return merged_id
This function does what I need but I feel that there must be a simpler way than parsing the json output of a REST request. What I need is a way of passing an rsid and getting back the genomic position based on a given genome assembly.