Commit 8b895c49 authored by David Hoksza's avatar David Hoksza
Browse files

fix wrong number of reported removed snps

parent 96764ee7
......@@ -25,7 +25,15 @@ def get_dbsnp(ids: List[str]) -> List[Dict]:
logging.info("Retrieved data from myvariant API")
if res.status_code == requests.codes.ok:
content = json.loads(res.text)
cnt = 0
for res in content:
genes = res["dbsnp"]["gene"]
if not isinstance(genes, list):
genes = [genes]
cnt += len(genes)
if "dbnsfp" not in res \
or "uniprot" not in res["dbnsfp"] \
or "aa" not in res["dbnsfp"] :
......@@ -48,7 +56,6 @@ def get_dbsnp(ids: List[str]) -> List[Dict]:
# uniprot_acc = uniprot_ids.pop()
uniprot_acc = uniprot_ids.pop()
aa = res["dbnsfp"]["aa"]
aas = aa if isinstance(aa, list) else [aa] #we can hav multiple aa mappings if there is a splice site
......@@ -57,11 +64,6 @@ def get_dbsnp(ids: List[str]) -> List[Dict]:
if "ref" not in aa:
continue
genes = res["dbsnp"]["gene"]
if not isinstance(genes, list):
genes = [genes]
for gene in genes:
position = str(res["hg19"]["start"])
......@@ -118,7 +120,7 @@ def get_dbsnp(ids: List[str]) -> List[Dict]:
"uniprot_acc": uniprot_acc
})
logging.info("Skipped {} variants out of {}".format(len(content) - len(snps), len(content)))
logging.info("Skipped {} variants out of {}".format(cnt - len(snps), cnt))
return snps
......
Markdown is supported
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