From b3e58be3344b02853749120a3cd2aa0b2e497d93 Mon Sep 17 00:00:00 2001 From: MarvinDo Date: Fri, 3 Nov 2023 12:53:46 +0100 Subject: [PATCH] improved range search & fixed a bug in classification search when searching for heredicare variants --- src/common/db_IO.py | 18 ++--- .../webapp/templates/index.html | 2 + .../webapp/templates/macros.html | 7 ++ .../templates/variant/variant_base.html | 19 ++++- .../webapp/utils/search_utils.py | 78 +++++++++++++------ 5 files changed, 86 insertions(+), 38 deletions(-) diff --git a/src/common/db_IO.py b/src/common/db_IO.py index 40cae85b..8aeb4c92 100644 --- a/src/common/db_IO.py +++ b/src/common/db_IO.py @@ -444,15 +444,12 @@ def add_constraints_to_command(self, command, constraints, operator = 'AND'): # return command def preprocess_range(self, range_constraint): - parts = range_constraint.split(':') - if len(parts) != 2: + parts = range_constraint.split('-') + if len(parts) != 3: return None, None, None chr = parts[0] - positions = parts[1].split('-') - if len(positions) != 2: - return None, None, None - start = int(positions[0]) - end = int(positions[1]) + start = int(parts[1]) + end = int(parts[2]) return chr, start, end def convert_to_gene_id(self, string): @@ -663,7 +660,8 @@ def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, use new_constraints_inner = new_constraints_inner + "SELECT variant_id FROM consensus_classification WHERE classification IN " + placeholders + " AND is_recent = 1" actual_information += tuple(consensus_without_dash) new_constraints = "variant.id IN (" + new_constraints_inner + ")" - postfix = self.add_constraints_to_command(postfix, new_constraints) + #postfix = self.add_constraints_to_command(postfix, new_constraints) + constraints_complete = new_constraints if include_heredicare_consensus and len(consensus_without_dash) > 0: heredicare_consensus = [] @@ -674,7 +672,9 @@ def get_variants_page_merged(self, page, page_size, sort_by, include_hidden, use new_constraints = "variant.id IN (SELECT variant_id FROM variant_heredicare_annotation WHERE consensus_class IN " + placeholders1 + " AND variant_id NOT IN (SELECT variant_id FROM consensus_classification WHERE classification NOT IN " + placeholders2 + " AND is_recent = 1))" actual_information += tuple(heredicare_consensus) actual_information += tuple(consensus_without_dash) - postfix = self.add_constraints_to_command(postfix, new_constraints, 'OR') + constraints_complete = functions.enbrace(constraints_complete + " OR " + new_constraints) + + postfix = self.add_constraints_to_command(postfix, constraints_complete) if user is not None and len(user) > 0: new_constraints_inner = '' diff --git a/src/frontend_celery/webapp/templates/index.html b/src/frontend_celery/webapp/templates/index.html index 0c3bfb35..2eed9ff2 100644 --- a/src/frontend_celery/webapp/templates/index.html +++ b/src/frontend_celery/webapp/templates/index.html @@ -98,6 +98,8 @@

Changelog

Bugfixes: