Skip to content

Commit 6767990

Browse files
committed
Merge branch 'dev' of github.com:biocore/qiita into dev
2 parents c3ce6a4 + 28d7191 commit 6767990

File tree

7 files changed

+210
-143
lines changed

7 files changed

+210
-143
lines changed

qiita_db/artifact.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,15 @@ def being_deleted_by(self):
15741574
@property
15751575
def has_human(self):
15761576
has_human = False
1577-
if self.artifact_type == 'per_sample_FASTQ':
1577+
# we are going to check the metadata if:
1578+
# - the prep data_type is _not_ target gene
1579+
# - the prep is not current_human_filtering
1580+
# - if the artifact_type is 'per_sample_FASTQ'
1581+
pts = self.prep_templates
1582+
tgs = qdb.metadata_template.constants.TARGET_GENE_DATA_TYPES
1583+
ntg = any([pt.data_type() not in tgs for pt in pts])
1584+
chf = any([not pt.current_human_filtering for pt in pts])
1585+
if ntg and chf and self.artifact_type == 'per_sample_FASTQ':
15781586
st = self.study.sample_template
15791587
if 'env_package' in st.categories:
15801588
sql = f"""SELECT DISTINCT sample_values->>'env_package'

qiita_db/metadata_template/prep_template.py

+25
Original file line numberDiff line numberDiff line change
@@ -1082,3 +1082,28 @@ def creation_job_id(self, creation_job_id):
10821082
WHERE prep_template_id = %s"""
10831083
qdb.sql_connection.TRN.add(sql, [creation_job_id, self.id])
10841084
qdb.sql_connection.TRN.execute()
1085+
1086+
@property
1087+
def current_human_filtering(self):
1088+
"""If the preparation is current with human filtering
1089+
1090+
Returns
1091+
-------
1092+
bool
1093+
The current_human_filtering of the prep information
1094+
"""
1095+
with qdb.sql_connection.TRN:
1096+
sql = """SELECT current_human_filtering
1097+
FROM qiita.prep_template
1098+
WHERE prep_template_id = %s"""
1099+
qdb.sql_connection.TRN.add(sql, [self.id])
1100+
return qdb.sql_connection.TRN.execute_fetchlast()
1101+
1102+
@current_human_filtering.setter
1103+
def current_human_filtering(self, current_human_filtering):
1104+
with qdb.sql_connection.TRN:
1105+
sql = """UPDATE qiita.prep_template
1106+
SET current_human_filtering = %s
1107+
WHERE prep_template_id = %s"""
1108+
qdb.sql_connection.TRN.add(sql, [current_human_filtering, self.id])
1109+
qdb.sql_connection.TRN.execute()

qiita_db/metadata_template/test/test_prep_template.py

+9
Original file line numberDiff line numberDiff line change
@@ -1905,6 +1905,15 @@ def test_name_setter(self):
19051905
pt.name = 'Prep information 1'
19061906
self.assertEqual(pt.name, 'Prep information 1')
19071907

1908+
def test_current_human_filtering(self):
1909+
pt = qdb.metadata_template.prep_template.PrepTemplate(1)
1910+
# by default it should be false
1911+
self.assertFalse(pt.current_human_filtering)
1912+
pt.current_human_filtering = True
1913+
self.assertTrue(pt.current_human_filtering)
1914+
pt.current_human_filtering = False
1915+
self.assertFalse(pt.current_human_filtering)
1916+
19081917

19091918
EXP_PREP_TEMPLATE = (
19101919
'sample_name\tbarcode\tcenter_name\tcenter_project_name\t'

qiita_db/support_files/patches/92.sql

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ ALTER TABLE qiita.slurm_resource_allocations
1818
ADD CONSTRAINT fk_slurm_resource_allocations
1919
FOREIGN KEY ( processing_job_id )
2020
REFERENCES qiita.processing_job ( processing_job_id );
21+
22+
-- Apr 21, 2024
23+
-- Adding a new column: current_human_filtering to qiita.prep_template
24+
ALTER TABLE qiita.prep_template ADD current_human_filtering boolean DEFAULT False;

qiita_db/support_files/qiita-db.dbs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,9 @@
10011001
<column name="creation_job_id" type="uuid" jt="1111" >
10021002
<defo><![CDATA[NULL]]></defo>
10031003
</column>
1004+
<column name="current_human_filtering" type="boolean" jt="1111" >
1005+
<defo><![CDATA[false]]></defo>
1006+
</column>
10041007
<index name="pk_prep_template" unique="PRIMARY_KEY" >
10051008
<column name="prep_template_id" />
10061009
</index>
@@ -2148,10 +2151,10 @@ $function$
21482151
<entity schema="qiita" name="user_level" color="D1BEF4" x="64" y="1520" />
21492152
<entity schema="qiita" name="visibility" color="BED3F4" x="2160" y="880" />
21502153
<script name="Sample SQL Editor" id="Editor_19ad" language="SQL" >
2151-
<string><![CDATA[SELECT artifact_id, generated_timestamp, command_id, command_parameters, visibility_id, artifact_type_id, data_type_id, submitted_to_vamps,
2154+
<string><![CDATA[SELECT artifact_id, generated_timestamp, command_id, command_parameters, visibility_id, artifact_type_id, data_type_id, submitted_to_vamps,
21522155
name
21532156
FROM
21542157
qiita.artifact t;]]></string>
21552158
</script>
21562159
</layout>
2157-
</project>
2160+
</project>

0 commit comments

Comments
 (0)