Commit 97d7a703 authored by Mihai's avatar Mihai
Browse files

Update HGVS descriptions retrieval for SNP converter (#482)

parent bffd1999
......@@ -394,7 +394,7 @@ def rsid_to_descriptions(rsid, output):
try:
# Parse the output.
doc = minidom.parseString(response_text)
rs = doc.getElementsByTagName('Rs')[0]
docsum = doc.getElementsByTagName('DOCSUM')[0].childNodes[0].data
except expat.ExpatError:
# TODO: Log error.
raise ServiceError()
......@@ -402,7 +402,11 @@ def rsid_to_descriptions(rsid, output):
# The expected root element is not present, this has also been
# observed as a response for non-existing rs#.
output.addMessage(__file__, 2, 'EENTREZ',
'Non existing %s in the DB or no root element.' % rsid)
'Non existing %s in the DB or no root element.'
% rsid)
return []
return [hgvs.lastChild.data for hgvs in rs.getElementsByTagName('hgvs')]
for part in docsum.split('|'):
if part.startswith('HGVS='):
return part.split('=')[1].split(',')
return []
......@@ -76,18 +76,17 @@ def test_snp_converter():
"""
snps = ['rs9919552']
expected = [['rs9919552',
'|'.join(['NC_000011.9:g.111959625C>T',
'NG_012337.2:g.7055C>T',
'NG_033145.1:g.2898G>A',
'NM_001276503.1:c.169+928C>T',
'NM_001276504.1:c.87C>T',
'NM_001276506.1:c.204C>T',
'|'.join(['NC_000011.10:g.112088901C>T',
'NC_000011.9:g.111959625C>T',
'NG_012337.3:g.7055C>T',
'NM_003002.4:c.204C>T',
'NM_003002.3:c.204C>T',
'NP_001263433.1:p.Ser29=',
'NP_001263435.1:p.Ser68=',
'NP_002993.1:p.Ser68=',
'NM_001276506.2:c.204C>T',
'NM_001276506.1:c.204C>T',
'NM_001276504.2:c.87C>T',
'NM_001276504.1:c.87C>T',
'NR_077060.1:n.288C>T',
'NT_033899.8:g.15522041C>T'])]]
'NG_033145.1:g.2898G>A'])]]
# Patch Bio.Entrez.efetch to return dbSNP record for rs9919552.
def mock_efetch(*args, **kwargs):
......
......@@ -445,9 +445,8 @@ def test_getdbsnpdescriptions(api):
r = api('getdbSNPDescriptions', 'rs9919552')
assert 'NC_000011.9:g.111959625C>T' in r.string
assert 'NG_012337.2:g.7055C>T' in r.string
assert 'NG_012337.3:g.7055C>T' in r.string
assert 'NM_003002.3:c.204C>T' in r.string
assert 'NP_002993.1:p.Ser68=' in r.string
@pytest.mark.usefixtures('hg19_transcript_mappings')
......
......@@ -364,9 +364,8 @@ def test_snp_converter_valid(website):
assert '0 Errors' in r.data
assert '0 Warnings' in r.data
assert 'NC_000011.9:g.111959625C>T' in r.data
assert 'NG_012337.2:g.7055C>T' in r.data
assert 'NG_012337.3:g.7055C>T' in r.data
assert 'NM_003002.3:c.204C>T' in r.data
assert 'NP_002993.1:p.Ser68=' in r.data
def test_snp_converter_invalid(website):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment