Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flu download fix #654

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions docker-compose.cloudsql.prod.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.cloudsql.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.flu.genbank.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# docker compose -f docker-compose.flu.genbank.yml up -d
name: pathmut-flu-genbank
version: "3.7"

services:
server:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.flu.gisaid.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# docker compose -f docker-compose.flu.gisaid.yml up -d
name: pathmut-flu-gisaid
version: "3.7"

services:
server:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.rsv.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# docker compose -f docker-compose.rsv.yml up -d
name: pathmut-rsv
version: "3.7"

services:
server:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.sars2.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# docker compose -f docker-compose.sars2.yml up -d
name: pathmut-sars2
version: "3.7"

services:
server:
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: pathmut-all
version: "3.7"

services:
cg-frontend:
Expand Down
8 changes: 4 additions & 4 deletions services/server/cg_server/download/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,7 +45,7 @@ def download_metadata(conn, req):
)

sequence_cols = [
"Accession ID",
"isolate_id",
"collection_date",
"submission_date",
]
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions services/server/cg_server/query/group_mutation_frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions services/server/cg_server/query/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 9 additions & 7 deletions services/server/cg_server/query/variant_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand All @@ -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",
]
Expand Down Expand Up @@ -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")
Expand All @@ -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),
Expand All @@ -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"]:
Expand Down Expand Up @@ -208,7 +210,7 @@ def build_variant_table(conn, req):
.fillna("N/A")
)
),
index=["Accession ID"],
index=["isolate_id"],
columns="mutations",
values="val",
)
Expand Down
18 changes: 18 additions & 0 deletions src/stores/dataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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,
}),
})
Expand Down Expand Up @@ -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) => {
Expand Down
Loading