Skip to content

Commit

Permalink
Merge pull request #499 from NBISweden/develop
Browse files Browse the repository at this point in the history
Changes for v21
  • Loading branch information
viklund committed Dec 19, 2018
2 parents 28dfbcc + b2d9e73 commit 8103c39
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
7 changes: 5 additions & 2 deletions backend/modules/browser/browser_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,12 @@ def get(self, dataset, variant):
'datasets':{},
'total':{}}
for item in ['ans', 'acs', 'freq', 'homs']:
for _dataset, value in variant['pop_' + item].items():
key = 'pop_' + item
if key not in variant:
continue
for _dataset, value in variant[key].items():
if _dataset not in frequencies['datasets']:
frequencies['datasets'][dataset] = {'pop':_dataset}
frequencies['datasets'][_dataset] = {'pop':_dataset}
frequencies['datasets'][_dataset][item] = value
if item not in frequencies['total']:
frequencies['total'][item] = 0
Expand Down
16 changes: 13 additions & 3 deletions backend/modules/browser/lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def get_variant(db, sdb, xpos, ref, alt):
return variant


def add_rsid_to_variant(sdb, variant):
if variant['rsid'] == '.' or variant['rsid'] is None:
rsid = sdb.dbsnp.find_one({'xpos': variant['xpos']})
if rsid:
variant['rsid'] = 'rs%s' % rsid['rsid']


def get_variants_by_rsid(db, rsid):
if not rsid.startswith('rs'):
return None
Expand Down Expand Up @@ -214,7 +221,7 @@ def get_genes_in_region(sdb, chrom, start, stop):
return list(genes)


def get_variants_in_region(db, chrom, start, stop):
def get_variants_in_region(db, sdb, chrom, start, stop):
"""
Variants that overlap a region
Unclear if this will include CNVs
Expand All @@ -226,6 +233,7 @@ def get_variants_in_region(db, chrom, start, stop):
}, projection={'_id': False}, limit=SEARCH_LIMIT))
add_consequence_to_variants(variants)
for variant in variants:
add_rsid_to_variant(sdb, variant)
remove_extraneous_information(variant)
return list(variants)

Expand Down Expand Up @@ -265,10 +273,11 @@ def remove_extraneous_information(variant):
del variant['vep_annotations']


def get_variants_in_gene(db, gene_id):
def get_variants_in_gene(db, sdb, gene_id):
variants = []
for variant in db.variants.find({'genes': gene_id}, projection={'_id': False}):
variant['vep_annotations'] = [x for x in variant['vep_annotations'] if x['Gene'] == gene_id]
add_rsid_to_variant(sdb, variant)
add_consequence_to_variant(variant)
remove_extraneous_information(variant)
variants.append(variant)
Expand All @@ -285,10 +294,11 @@ def get_number_of_variants_in_transcript(db, transcript_id):
return {'filtered': filtered, 'total': total}


def get_variants_in_transcript(db, transcript_id):
def get_variants_in_transcript(db, sdb, transcript_id):
variants = []
for variant in db.variants.find({'transcripts': transcript_id}, projection={'_id': False}):
variant['vep_annotations'] = [x for x in variant['vep_annotations'] if x['Feature'] == transcript_id]
add_rsid_to_variant(sdb, variant)
add_consequence_to_variant(variant)
remove_extraneous_information(variant)
variants.append(variant)
Expand Down
7 changes: 4 additions & 3 deletions backend/modules/browser/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ def get_variant_list(dataset, datatype, item):

try:
db = connect_db(dataset, False)
db_shared = connect_db(dataset, True)

if datatype == 'gene':
variants = lookups.get_variants_in_gene(db, item)
variants = lookups.get_variants_in_gene(db, db_shared, item)
elif datatype == 'region':
chrom, start, stop = item.split('-')
variants = lookups.get_variants_in_region(db, chrom, start, stop)
variants = lookups.get_variants_in_region(db, db_shared, chrom, start, stop)
elif datatype == 'transcript':
variants = lookups.get_variants_in_transcript(db, item)
variants = lookups.get_variants_in_transcript(db, db_shared, item)

# Format output
def format_variant(variant):
Expand Down
2 changes: 1 addition & 1 deletion frontend/templates/ng-templates/dataset-download.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h3>Request access to summary files</h3>
<div class="col-md-1 column"></div>
<div class="col-md-8 column">
<p>By submitting the application for registration you confirm that the information provided in the application is accurate.</p>
<p>By submitting the application for registration you also agree to have the information that you submit (Name, affiliation, country and email) handled in accordance with the Swedish Personal Data Act (Personuppgiftslagen, 1998:204). The stored information will only be used for internal administrative purposes and not shared with other parties.</p>
<p>By submitting the application for registration you also agree to have the information that you submit (Name, affiliation, country and email) handled in accordance with the General Data Protection Regulation ((EU) 2016/679). The stored information will only be used for internal administrative purposes and not shared with other parties.</p>
</div>
</div>
</div>
Expand Down

0 comments on commit 8103c39

Please sign in to comment.