Skip to content

Adding current human filtering flag to prep_template #3395

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

Merged
merged 5 commits into from
Apr 22, 2024
Merged
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
10 changes: 9 additions & 1 deletion qiita_db/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,15 @@ def being_deleted_by(self):
@property
def has_human(self):
has_human = False
if self.artifact_type == 'per_sample_FASTQ':
# we are going to check the metadata if:
# - the prep data_type is _not_ target gene
# - the prep is not current_human_filtering
# - if the artifact_type is 'per_sample_FASTQ'
pts = self.prep_templates
tgs = qdb.metadata_template.constants.TARGET_GENE_DATA_TYPES
ntg = any([pt.data_type() not in tgs for pt in pts])
chf = any([not pt.current_human_filtering for pt in pts])
if ntg and chf and self.artifact_type == 'per_sample_FASTQ':
st = self.study.sample_template
if 'env_package' in st.categories:
sql = f"""SELECT DISTINCT sample_values->>'env_package'
Expand Down
25 changes: 25 additions & 0 deletions qiita_db/metadata_template/prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1082,3 +1082,28 @@ def creation_job_id(self, creation_job_id):
WHERE prep_template_id = %s"""
qdb.sql_connection.TRN.add(sql, [creation_job_id, self.id])
qdb.sql_connection.TRN.execute()

@property
def current_human_filtering(self):
"""If the preparation is current with human filtering

Returns
-------
bool
The current_human_filtering of the prep information
"""
with qdb.sql_connection.TRN:
sql = """SELECT current_human_filtering
FROM qiita.prep_template
WHERE prep_template_id = %s"""
qdb.sql_connection.TRN.add(sql, [self.id])
return qdb.sql_connection.TRN.execute_fetchlast()

@current_human_filtering.setter
def current_human_filtering(self, current_human_filtering):
with qdb.sql_connection.TRN:
sql = """UPDATE qiita.prep_template
SET current_human_filtering = %s
WHERE prep_template_id = %s"""
qdb.sql_connection.TRN.add(sql, [current_human_filtering, self.id])
qdb.sql_connection.TRN.execute()
9 changes: 9 additions & 0 deletions qiita_db/metadata_template/test/test_prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1905,6 +1905,15 @@ def test_name_setter(self):
pt.name = 'Prep information 1'
self.assertEqual(pt.name, 'Prep information 1')

def test_current_human_filtering(self):
pt = qdb.metadata_template.prep_template.PrepTemplate(1)
# by default it should be false
self.assertFalse(pt.current_human_filtering)
pt.current_human_filtering = True
self.assertTrue(pt.current_human_filtering)
pt.current_human_filtering = False
self.assertFalse(pt.current_human_filtering)


EXP_PREP_TEMPLATE = (
'sample_name\tbarcode\tcenter_name\tcenter_project_name\t'
Expand Down
4 changes: 4 additions & 0 deletions qiita_db/support_files/patches/92.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ ALTER TABLE qiita.slurm_resource_allocations
ADD CONSTRAINT fk_slurm_resource_allocations
FOREIGN KEY ( processing_job_id )
REFERENCES qiita.processing_job ( processing_job_id );

-- Apr 21, 2024
-- Adding a new column: current_human_filtering to qiita.prep_template
ALTER TABLE qiita.prep_template ADD current_human_filtering boolean DEFAULT False;
7 changes: 5 additions & 2 deletions qiita_db/support_files/qiita-db.dbs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,9 @@
<column name="creation_job_id" type="uuid" jt="1111" >
<defo><![CDATA[NULL]]></defo>
</column>
<column name="current_human_filtering" type="boolean" jt="1111" >
<defo><![CDATA[false]]></defo>
</column>
<index name="pk_prep_template" unique="PRIMARY_KEY" >
<column name="prep_template_id" />
</index>
Expand Down Expand Up @@ -2148,10 +2151,10 @@ $function$
<entity schema="qiita" name="user_level" color="D1BEF4" x="64" y="1520" />
<entity schema="qiita" name="visibility" color="BED3F4" x="2160" y="880" />
<script name="Sample SQL Editor" id="Editor_19ad" language="SQL" >
<string><![CDATA[SELECT artifact_id, generated_timestamp, command_id, command_parameters, visibility_id, artifact_type_id, data_type_id, submitted_to_vamps,
<string><![CDATA[SELECT artifact_id, generated_timestamp, command_id, command_parameters, visibility_id, artifact_type_id, data_type_id, submitted_to_vamps,
name
FROM
qiita.artifact t;]]></string>
</script>
</layout>
</project>
</project>
Loading
Loading