Skip to content

Commit

Permalink
bugfixes & update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinDo committed Oct 25, 2023
1 parent cac6c29 commit 4b5abff
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/common/db_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,6 @@ def sort_consequences(self, a, b):

def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, user_id, ranges = None, genes = None, consensus = None, user = None, hgvs = None, variant_ids_oi = None):
# get one page of variants determined by offset & pagesize
page_size = int(page_size)
offset = (page - 1) * page_size

prefix = "SELECT id, chr, pos, ref, alt FROM variant"
postfix = ""
Expand Down Expand Up @@ -727,6 +725,8 @@ def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, use
elif sort_by == 'recent':
command += " ORDER BY id DESC"
if page_size != 'unlimited':
page_size = int(page_size)
offset = (page - 1) * page_size
command = command + " LIMIT %s, %s"
actual_information += (offset, page_size)
#print(command % actual_information)
Expand Down
24 changes: 23 additions & 1 deletion src/common/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from dotenv import load_dotenv
import json
import uuid
from functools import cmp_to_key


def basedir():
Expand Down Expand Up @@ -624,4 +625,25 @@ def str2datetime(datetime_str, fmt):
if datetime_str is None:
return None
else:
return datetime.datetime.strptime(datetime_str, fmt)
return datetime.datetime.strptime(datetime_str, fmt)



def order_classes( classes):
keyfunc = cmp_to_key(mycmp = sort_classes)
classes = [str(x) for x in classes]
classes.sort(key = keyfunc) # sort by preferred transcript
return classes

def sort_classes(a, b):
# sort by ensembl/refseq
class_sequence = ['1', '2', '3-', '3', '3+', '4', '5', 'M']

a_importance = class_sequence.index(a)
b_importance = class_sequence.index(b)

if a_importance > b_importance:
return 1
elif a_importance < b_importance:
return -1
return 0
3 changes: 1 addition & 2 deletions src/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any
import common.functions as functions
from functools import cmp_to_key
import datetime

@dataclass
class Annotation:
Expand Down Expand Up @@ -875,9 +876,7 @@ def sort_consequences(self, a:Consequence, b:Consequence):
return 1
else:
return 0


import datetime

@dataclass
class import_request:
Expand Down
2 changes: 2 additions & 0 deletions src/frontend_celery/webapp/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ <h4>Changelog</h4>
<li>Fixed a bug where the ClinVar annotation was erroneous which happened when there were missing submissions</li>
<li>Fixed a bug where the consequence annotation was erroneous which happened when the variant was large and spanned multiple exons / introns</li>
<li>Fixed a bug where the user was unable to download variants which are not annotated</li>
<li>Fixed a bug where the user could not search for class 3+</li>
<li>The date is now inserted correctly when classifying variants. Preexisting classifications did not change (this is fixed starting from 24.10.23).</li>
</ul>
Known issues:
<ul>
Expand Down
6 changes: 4 additions & 2 deletions src/frontend_celery/webapp/utils/search_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,20 @@ def extract_consensus_classifications(request_obj, allowed_classes):
consensus_classifications = request_obj.args.getlist('consensus')
consensus_classifications = ';'.join(consensus_classifications)
regex_inner = '|'.join(allowed_classes)
regex_inner = regex_inner.replace('+', '\+')
consensus_classifications = preprocess_query(consensus_classifications, r'(' + regex_inner + r')?')
if consensus_classifications is None:
flash("You have an error in your consensus class query(s). It must consist of a number between 1-5. Results are not filtered by consensus classification.", "alert-danger")
flash("You have an error in your consensus class query(s). It must consist of a number between 1-5, 3+, 3- or M. Results are not filtered by consensus classification.", "alert-danger")
return consensus_classifications

def extract_user_classifications(request_obj, allowed_classes):
user_classifications = request_obj.args.getlist('user')
user_classifications = ';'.join(user_classifications)
regex_inner = '|'.join(allowed_classes)
regex_inner = regex_inner.replace('+', '\+')
user_classifications = preprocess_query(user_classifications, r'(' + regex_inner + r')?')
if user_classifications is None:
flash("You have an error in your consensus class query(s). It must consist of a number between 1-5. Results are not filtered by consensus classification.", "alert-danger")
flash("You have an error in your consensus class query(s). It must consist of a number between 1-5, 3+, 3- or M. Results are not filtered by consensus classification.", "alert-danger")
return user_classifications

def extract_hgvs(request_obj):
Expand Down
6 changes: 3 additions & 3 deletions src/frontend_celery/webapp/variant/variant_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def search():
conn = get_connection()
user_id = session['user']['user_id']

allowed_user_classes = conn.get_enumtypes('user_classification', 'classification')
allowed_consensus_classes = conn.get_enumtypes('consensus_classification', 'classification')
allowed_user_classes = functions.order_classes(conn.get_enumtypes('user_classification', 'classification'))
allowed_consensus_classes = functions.order_classes(conn.get_enumtypes('consensus_classification', 'classification'))

genes = extract_genes(request)
ranges = extract_ranges(request)
Expand Down Expand Up @@ -64,7 +64,7 @@ def search():
else:
num_inserted = 0
if select_all_variants:
variants_for_list, _ = conn.get_variants_page_merged(1, "unlimited", user_id=user_id, ranges=ranges, genes = genes, consensus=consensus_classifications, user=user_classifications, hgvs=hgvs, variant_ids_oi=variant_ids_oi)
variants_for_list, _ = conn.get_variants_page_merged(1, "unlimited", sort_by=selected_sort_by, include_hidden=include_hidden, user_id=user_id, ranges=ranges, genes = genes, consensus=consensus_classifications, user=user_classifications, hgvs=hgvs, variant_ids_oi=variant_ids_oi)
variant_ids = [variant.id for variant in variants_for_list]
for variant_id in variant_ids:
if str(variant_id) not in selected_variants:
Expand Down

0 comments on commit 4b5abff

Please sign in to comment.