Skip to content

Commit

Permalink
Improved validation widget
Browse files Browse the repository at this point in the history
  • Loading branch information
SteampunkIslande committed Jul 17, 2024
1 parent d80644c commit cfa0b07
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 80 deletions.
119 changes: 103 additions & 16 deletions config_folder/validation_methods/validation_ppi.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
},
"steps": [
{
"title": "Etape 1",
"description": "Première étape de la validation.\nLes filtres appliqués montrent uniquement les variants dont la fréquence allélique en population générale est inférieure à 1%.",
"title": "Presets d'Alix",
"description": "<body>Première étape de la validation.<br>Les filtres appliqués montrent uniquement les variants dont la fréquence allélique en population générale est inférieure à <a style=\"color:red;background:yellow\">1%</a>.</body>",
"query": {
"select": {
"fields": [
Expand Down Expand Up @@ -166,6 +166,105 @@
]
}
}
},
{
"title": "Presets de Pascale",
"description": "<body>Première étape de la validation.\nLes filtres appliqués montrent uniquement les variants dont la fréquence allélique en population générale est inférieure à <a style=\"color:red;background:yellow\">1%</a>.</body>",
"query": {
"select": {
"fields": [
"main_table.run_name",
"main_table.sample_name",
"main_table.snpeff_Gene_Name",
"main_table.snpeff_Feature_ID",
"main_table.chromosome",
"main_table.position",
"main_table.reference",
"main_table.alternate",
"main_table.cv_AF",
"main_table.snpeff_Annotation",
"main_table.cv_GT",
"main_table.snpeff_Annotation_Impact",
"agg.ref_count",
"agg.var_count",
"recur.count",
"clinvar.CLNACC",
"clinvar.CLNSIG",
"main_table.\"snpeff_HGVS.c\" AS 'c. de l anomalie'"
],
"tables": [
{
"expression": "{main_table}",
"alias": "main_table"
},
{
"expression": "read_parquet('{pwd}/aggregates/variants.parquet')",
"alias": "agg",
"on": "main_table.variant_hash = agg.variant_hash",
"how": ""
},
{
"select": {
"fields": [
"variant_hash",
"COUNT(*) as count"
],
"tables": [
{
"select": {
"fields": [
"DISTINCT(sample_name)",
"variant_hash"
],
"tables": [
{
"expression": "{main_table}",
"alias": ""
}
]
},
"alias": ""
}
],
"group_by": [
"variant_hash"
]
},
"alias": "recur",
"on": "main_table.variant_hash = recur.variant_hash",
"how": ""
},
{
"select": {
"fields": [
"variant_hash",
"rcvAcc AS CLNACC",
"clinSign AS CLNSIG"
],
"tables": [
{
"expression": "read_parquet('{pwd}/annotations/clinvarMain.parquet')",
"alias": ""
}
]
},
"alias": "clinvar",
"on": "main_table.variant_hash = clinvar.variant_hash",
"how": ""
}
],
"order_by": [
{
"field": "main_table.chromosome",
"order": "DESC"
},
{
"field": "main_table.position",
"order": "DESC"
}
]
}
}
}
],
"final": {
Expand Down Expand Up @@ -212,25 +311,13 @@
"how": ""
},
{
"expression": "{pwd}/annotations/hgnc.hg19.parquet",
"expression": "read_parquet('{pwd}/annotations/hgnc.hg19.parquet')",
"alias": "hgnc",
"on": "main_table.chromosome = hgnc.chrom AND main_table.position >= hgnc.chromStart AND main_table.position <= hgnc.chromEnd",
"how": ""
},
{
"select": {
"fields": [
"variant_hash",
"rcvAcc AS CLNACC",
"clinSign AS CLNSIG"
],
"tables": [
{
"expression": "read_parquet('{pwd}/clinvarMain.parquet')",
"alias": ""
}
]
},
"expression": "read_parquet('{pwd}/annotations/clinvarMain.parquet')",
"alias": "clinvar",
"on": "main_table.variant_hash = clinvar.variant_hash",
"how": ""
Expand Down
10 changes: 6 additions & 4 deletions query.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,18 @@ def generate_query_template_from_json(self, data: dict) -> "Query":
self.internal_changed.emit()
return self

def select_query(self):
def select_query(self, paginated=True):
"""Generates the select query to run on the database. Set paginated to False if you need a query that returns all rows."""
if not self.readonly_table:
return ""

pagination = f" LIMIT {self.limit} OFFSET {self.offset}" if paginated else ""

additional_where = (
f" WHERE {str(self.filter_model.root)} " if self.filter_model.root else ""
f" WHERE {str(self.filter_model.root)}" if self.filter_model.root else ""
)

return f"SELECT * FROM ({self.query_template}){additional_where}LIMIT {self.limit} OFFSET {self.offset}".format(
return f"SELECT * FROM ({self.query_template}){additional_where}{pagination}".format(
**{
"main_table": self.readonly_table,
"user_table": f'"{self.editable_table_name}"',
Expand Down Expand Up @@ -273,7 +276,6 @@ def to_do(self):
return "Please select a validation table"

def update_data(self):
print("Updating data")
# Empty data before updating
self.header = []
self.data = []
Expand Down
Loading

0 comments on commit cfa0b07

Please sign in to comment.