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

75 too high freqs #76

Merged
merged 6 commits into from
Jan 5, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
make sure variants are only counted when they belong to a finished sa…
…mple again
  • Loading branch information
priesgo committed Jan 3, 2023
commit 001d8faa9f57e3f46071a48ec9f2bae035d762ce
5 changes: 4 additions & 1 deletion covigator/database/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,16 @@ def get_last_update(self, data_source: DataSource) -> date:
def get_variant_counts_by_month(self, variant_id, source: str) -> pd.DataFrame:

klass = self.get_variant_observation_klass(source=source)
sample_klass = self.get_sample_klass(source=source)
sql_query_ds_ena = """
select count(*) as count, variant_id, date_trunc('month', date::timestamp) as month
from {variant_observation_table}
where variant_id='{variant_id}'
where variant_id='{variant_id}'
and sample in (select run_accession from {sample_table} where status='FINISHED')
group by variant_id, date_trunc('month', date::timestamp);
""".format(
variant_observation_table=klass.__tablename__,
sample_table=sample_klass.__tablename__,
variant_id=variant_id
)
data = pd.read_sql_query(sql_query_ds_ena, self.session.bind)
Expand Down