diff --git a/docker-compose.cloudsql.prod.yml b/docker-compose.cloudsql.prod.yml index 0327d212..8292dd71 100644 --- a/docker-compose.cloudsql.prod.yml +++ b/docker-compose.cloudsql.prod.yml @@ -1,8 +1,6 @@ # docker compose --env-file .cloudsql_env -f docker-compose.cloudsql.yml -p cgcloudsql build # docker compose --env-file .cloudsql_env -f docker-compose.cloudsql.yml -p cgcloudsql up -d -version: "3.7" - services: server: build: diff --git a/docker-compose.cloudsql.yml b/docker-compose.cloudsql.yml index fb35425c..ebd8f55b 100644 --- a/docker-compose.cloudsql.yml +++ b/docker-compose.cloudsql.yml @@ -1,8 +1,6 @@ # docker compose --env-file .cloudsql_env -f docker-compose.cloudsql.yml -p cgcloudsql build # docker compose --env-file .cloudsql_env -f docker-compose.cloudsql.yml -p cgcloudsql up -d -version: "3.7" - services: server: build: diff --git a/docker-compose.flu.genbank.yml b/docker-compose.flu.genbank.yml index f142475f..66887b65 100644 --- a/docker-compose.flu.genbank.yml +++ b/docker-compose.flu.genbank.yml @@ -1,6 +1,5 @@ # docker compose -f docker-compose.flu.genbank.yml up -d name: pathmut-flu-genbank -version: "3.7" services: server: diff --git a/docker-compose.flu.gisaid.yml b/docker-compose.flu.gisaid.yml index 984f20be..e1fece17 100644 --- a/docker-compose.flu.gisaid.yml +++ b/docker-compose.flu.gisaid.yml @@ -1,6 +1,5 @@ # docker compose -f docker-compose.flu.gisaid.yml up -d name: pathmut-flu-gisaid -version: "3.7" services: server: diff --git a/docker-compose.rsv.yml b/docker-compose.rsv.yml index 5eefc195..b949914d 100644 --- a/docker-compose.rsv.yml +++ b/docker-compose.rsv.yml @@ -1,6 +1,5 @@ # docker compose -f docker-compose.rsv.yml up -d name: pathmut-rsv -version: "3.7" services: server: diff --git a/docker-compose.sars2.yml b/docker-compose.sars2.yml index b9a8a516..60689980 100644 --- a/docker-compose.sars2.yml +++ b/docker-compose.sars2.yml @@ -1,6 +1,5 @@ # docker compose -f docker-compose.sars2.yml up -d name: pathmut-sars2 -version: "3.7" services: server: diff --git a/docker-compose.yml b/docker-compose.yml index 2bd7902d..02fc7f9f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,4 @@ name: pathmut-all -version: "3.7" services: cg-frontend: diff --git a/services/server/cg_server/download/metadata.py b/services/server/cg_server/download/metadata.py index 241a8016..aa778612 100644 --- a/services/server/cg_server/download/metadata.py +++ b/services/server/cg_server/download/metadata.py @@ -33,9 +33,9 @@ def download_metadata(conn, req): req.get("subm_end_date", None), req.get("selected_metadata_fields", None), req.get("selected_group_fields", None), + selected_reference, req.get("sequence_length", None), req.get("percent_ambiguous", None), - selected_reference, ) # Fields that the user wants @@ -45,7 +45,7 @@ def download_metadata(conn, req): ) sequence_cols = [ - "Accession ID", + "isolate_id", "collection_date", "submission_date", ] @@ -122,10 +122,10 @@ def download_metadata(conn, req): sql.SQL( """ INNER JOIN ( - SELECT "sequence_id", "reference", "mutations" + SELECT "isolate_id", "reference", "mutations" FROM {mutation_table} ) {mutation_table_short} ON - {mutation_table_short}."sequence_id" = m."sequence_id" AND + {mutation_table_short}."isolate_id" = m."isolate_id" AND {mutation_table_short}."reference" = {reference_name} """ ).format( diff --git a/services/server/cg_server/query/group_mutation_frequencies.py b/services/server/cg_server/query/group_mutation_frequencies.py index fa199f66..486e401a 100644 --- a/services/server/cg_server/query/group_mutation_frequencies.py +++ b/services/server/cg_server/query/group_mutation_frequencies.py @@ -114,9 +114,9 @@ def query_group_mutation_frequencies_dynamic(conn, req): req.get("subm_end_date", None), req.get("selected_metadata_fields", None), req.get("selected_group_fields", None), + selected_reference, req.get("sequence_length", None), req.get("percent_ambiguous", None), - selected_reference, ) sequence_mutation_table = "sequence_" + mutation_table @@ -129,16 +129,16 @@ def query_group_mutation_frequencies_dynamic(conn, req): sql.SQL( """ WITH "group_counts" AS ( - SELECT {group_col}, COUNT("sequence_id") + SELECT {group_col}, COUNT("isolate_id") FROM {sequence_mutation_table} WHERE {sequence_where_filter} GROUP BY {group_col} ), "group_muts" AS ( SELECT - {group_col}, "mutation", COUNT("sequence_id") + {group_col}, "mutation", COUNT("isolate_id") FROM ( - SELECT "sequence_id", {group_col}, UNNEST("mutations") as "mutation" + SELECT "isolate_id", {group_col}, UNNEST("mutations") as "mutation" FROM {sequence_mutation_table} WHERE {sequence_where_filter} ) "group_muts" diff --git a/services/server/cg_server/query/report.py b/services/server/cg_server/query/report.py index df277095..7bb62171 100644 --- a/services/server/cg_server/query/report.py +++ b/services/server/cg_server/query/report.py @@ -91,7 +91,7 @@ def generate_report(conn, req): GROUP BY "region", "mutation_id" ), region_counts AS ( - SELECT "region", COUNT("sequence_id") + SELECT "region", COUNT("isolate_id") FROM "metadata" m WHERE "collection_date" >= %(start_date)s AND @@ -195,7 +195,7 @@ def generate_report(conn, req): """ WITH seq_cooc AS ( SELECT - seq_mut."sequence_id", + seq_mut."isolate_id", seq_mut."region", ("mutations" & ( SELECT ARRAY_AGG("id") @@ -204,7 +204,7 @@ def generate_report(conn, req): )) as "mutations", m.{group} FROM "sequence_gene_aa_mutation" seq_mut - INNER JOIN "metadata" m ON seq_mut."sequence_id" = m."sequence_id" + INNER JOIN "metadata" m ON seq_mut."isolate_id" = m."isolate_id" WHERE seq_mut."collection_date" >= %(start_date)s AND seq_mut."collection_date" <= %(end_date)s @@ -218,7 +218,7 @@ def generate_report(conn, req): SELECT "mutations", {group}, - COUNT("sequence_id") as "count" + COUNT("isolate_id") as "count" FROM seq_cooc GROUP BY "mutations", {group} ) cooc_group @@ -228,14 +228,14 @@ def generate_report(conn, req): SELECT seq_cooc."region", "mutations", - COUNT(seq_cooc."sequence_id") AS "count" + COUNT(seq_cooc."isolate_id") AS "count" FROM seq_cooc GROUP BY seq_cooc."mutations", seq_cooc."region" ), region_counts AS ( SELECT seq_cooc."region", - COUNT(seq_cooc."sequence_id") as "count" + COUNT(seq_cooc."isolate_id") as "count" FROM seq_cooc GROUP BY seq_cooc."region" ) @@ -321,7 +321,7 @@ def generate_report(conn, req): WITH region_counts AS ( SELECT m."region", - COUNT(m."sequence_id") as "count" + COUNT(m."isolate_id") as "count" FROM "metadata" m WHERE m."collection_date" >= %(start_date)s AND @@ -332,7 +332,7 @@ def generate_report(conn, req): SELECT m."region", m.{group}, - COUNT(m."sequence_id") AS "count" + COUNT(m."isolate_id") AS "count" FROM "metadata" m WHERE m."collection_date" >= %(start_date)s AND diff --git a/services/server/cg_server/query/variant_table.py b/services/server/cg_server/query/variant_table.py index 0f97a602..b13f82ed 100644 --- a/services/server/cg_server/query/variant_table.py +++ b/services/server/cg_server/query/variant_table.py @@ -41,6 +41,7 @@ def build_variant_table(conn, req): raise Exception("No reference specified") with conn.cursor() as cur: + sequence_where_filter = build_sequence_location_where_filter( constants["GROUP_MUTATION"], get_loc_level_ids(req), @@ -50,10 +51,11 @@ def build_variant_table(conn, req): req.get("subm_end_date", None), req.get("selected_metadata_fields", None), req.get("selected_group_fields", None), + selected_reference, req.get("sequence_length", None), req.get("percent_ambiguous", None), - selected_reference, ) + (mutation_filter, mutation_table) = build_coordinate_filters( conn, @@ -73,7 +75,7 @@ def build_variant_table(conn, req): # Get grouping columns, metadata columns metadata_cols = [ - "Accession ID", + "isolate_id", "collection_date", "submission_date", ] @@ -126,7 +128,7 @@ def build_variant_table(conn, req): sm."mutations" FROM ( SELECT - sst."sequence_id", + sst."isolate_id", sst."reference", (sst.mutations & ( SELECT ARRAY_AGG("id") @@ -136,9 +138,9 @@ def build_variant_table(conn, req): FROM {sequence_mutation_table} sst WHERE {sequence_where_filter} ) sm - INNER JOIN "metadata" m ON sm."sequence_id" = m."sequence_id" + INNER JOIN "metadata" m ON sm."isolate_id" = m."isolate_id" {joins} - ORDER BY m."Accession ID" ASC + ORDER BY m."isolate_id" ASC """ ).format( metadata_cols_expr=sql.SQL(",").join(metadata_cols_expr), @@ -155,7 +157,7 @@ def build_variant_table(conn, req): # cur.fetchall(), columns=metadata_cols + ["mutation_name", "pos"] cur.fetchall(), columns=metadata_cols + ["reference", "mutations"], - ).set_index("Accession ID") + ).set_index("isolate_id") mutation_name_field = "mutation_str" if mutation_format == constants["MUTATION_FORMAT"]["POS_REF_ALT"]: @@ -208,7 +210,7 @@ def build_variant_table(conn, req): .fillna("N/A") ) ), - index=["Accession ID"], + index=["isolate_id"], columns="mutations", values="val", ) diff --git a/src/stores/dataStore.js b/src/stores/dataStore.js index c1fa2d2d..2d7e9e32 100644 --- a/src/stores/dataStore.js +++ b/src/stores/dataStore.js @@ -317,6 +317,12 @@ export class DataStore { (field) => selectedFields[field] ), mutation_format: mutationFormat, + sequence_length: toJS( + rootStoreInstance.configStore.sequenceLengthRange + ), + percent_ambiguous: toJS( + rootStoreInstance.configStore.percentAmbiguousRange + ), }), }) .then((res) => { @@ -372,6 +378,12 @@ export class DataStore { end_date: toJS(rootStoreInstance.configStore.endDate), subm_start_date: toJS(rootStoreInstance.configStore.submStartDate), subm_end_date: toJS(rootStoreInstance.configStore.submEndDate), + sequence_length: toJS( + rootStoreInstance.configStore.sequenceLengthRange + ), + percent_ambiguous: toJS( + rootStoreInstance.configStore.percentAmbiguousRange + ), compress, }), }) @@ -734,6 +746,12 @@ export class DataStore { (field) => selectedFields[field] ), mutation_format: mutationFormat, + sequence_length: toJS( + rootStoreInstance.configStore.sequenceLengthRange + ), + percent_ambiguous: toJS( + rootStoreInstance.configStore.percentAmbiguousRange + ), }), }) .then((res) => {