Skip to content

Commit ef0edb8

Browse files
committed
Merge branch 'dev' of github.com:biocore/qiita into dev
2 parents 6a93953 + 0387611 commit ef0edb8

File tree

8 files changed

+1580
-1474
lines changed

8 files changed

+1580
-1474
lines changed

qiita_db/artifact.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,3 +1684,51 @@ def get_commands(self):
16841684
cids = cmds & cids
16851685

16861686
return [qdb.software.Command(cid) for cid in cids]
1687+
1688+
@property
1689+
def human_reads_filter_method(self):
1690+
"""The human_reads_filter_method of the artifact
1691+
1692+
Returns
1693+
-------
1694+
str
1695+
The human_reads_filter_method name
1696+
"""
1697+
with qdb.sql_connection.TRN:
1698+
sql = """SELECT human_reads_filter_method
1699+
FROM qiita.artifact
1700+
LEFT JOIN qiita.human_reads_filter_method
1701+
USING (human_reads_filter_method_id)
1702+
WHERE artifact_id = %s"""
1703+
qdb.sql_connection.TRN.add(sql, [self.id])
1704+
return qdb.sql_connection.TRN.execute_fetchlast()
1705+
1706+
@human_reads_filter_method.setter
1707+
def human_reads_filter_method(self, value):
1708+
"""Set the human_reads_filter_method of the artifact
1709+
1710+
Parameters
1711+
----------
1712+
value : str
1713+
The new artifact's human_reads_filter_method
1714+
1715+
Raises
1716+
------
1717+
ValueError
1718+
If `value` doesn't exist in the database
1719+
"""
1720+
with qdb.sql_connection.TRN:
1721+
sql = """SELECT human_reads_filter_method_id
1722+
FROM qiita.human_reads_filter_method
1723+
WHERE human_reads_filter_method = %s"""
1724+
qdb.sql_connection.TRN.add(sql, [value])
1725+
idx = qdb.sql_connection.TRN.execute_fetchflatten()
1726+
1727+
if len(idx) == 0:
1728+
raise ValueError(
1729+
f'"{value}" is not a valid human_reads_filter_method')
1730+
1731+
sql = """UPDATE qiita.artifact
1732+
SET human_reads_filter_method_id = %s
1733+
WHERE artifact_id = %s"""
1734+
qdb.sql_connection.TRN.add(sql, [idx[0], self.id])

qiita_db/support_files/patches/92.sql

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,18 @@ ALTER TABLE qiita.qiita_user ADD social_orcid character varying DEFAULT NULL;
4848
ALTER TABLE qiita.qiita_user ADD social_researchgate character varying DEFAULT NULL;
4949
ALTER TABLE qiita.qiita_user ADD social_googlescholar character varying DEFAULT NULL;
5050

51+
-- Jul 1, 2024
5152
-- Add human_reads_filter_method so we can keep track of the available methods
5253
-- and link them to the preparations
5354

54-
CREATE TABLE qiita.human_reads_filter_method (
55-
human_reads_filter_method_id bigint NOT NULL,
56-
human_reads_filter_method_method character varying NOT NULL,
57-
CONSTRAINT pk_human_reads_filter_method_id PRIMARY KEY (
58-
human_reads_filter_method_id )
59-
);
55+
CREATE TABLE qiita.human_reads_filter_method (
56+
human_reads_filter_method_id SERIAL PRIMARY KEY,
57+
human_reads_filter_method character varying NOT NULL
58+
);
6059

61-
ALTER TABLE qiita.prep_template
60+
ALTER TABLE qiita.artifact
6261
ADD human_reads_filter_method_id bigint DEFAULT NULL;
63-
ALTER TABLE qiita.prep_template
62+
ALTER TABLE qiita.artifact
6463
ADD CONSTRAINT fk_human_reads_filter_method
6564
FOREIGN KEY ( human_reads_filter_method_id )
6665
REFERENCES qiita.human_reads_filter_method ( human_reads_filter_method_id );

qiita_db/support_files/patches/test_db_sql/92.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,3 +942,13 @@ WHERE email = '[email protected]';
942942
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'JustNow', 'NonVeriUser', '1634 Edgemont Avenue', '303-492-1984', NULL, NULL, NULL, false, NOW(), NULL, NULL, NULL);
943943
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'Oldie', 'NonVeriUser', '172 New Lane', '102-111-1984', NULL, NULL, NULL, false, NOW() - INTERVAL '1 YEAR', NULL, NULL, NULL);
944944
INSERT INTO qiita.qiita_user VALUES ('[email protected]', 5, '$2a$12$gnUi8Qg.0tvW243v889BhOBhWLIHyIJjjgaG6dxuRJkUM8nXG9Efe', 'TooLate', 'NonVeriUser', '564 C Street', '508-492-222', NULL, NULL, NULL, false, NOW() - INTERVAL '30 DAY', NULL, NULL, NULL);
945+
946+
-- Jul 1, 2024
947+
-- Inserting a human_reads_filter_method and assigning it to the raw data in prep/artifact 1
948+
INSERT INTO qiita.human_reads_filter_method (
949+
human_reads_filter_method)
950+
VALUES (
951+
'The greatest human filtering method');
952+
UPDATE qiita.artifact
953+
SET human_reads_filter_method_id = 1
954+
WHERE artifact_id = 1;

qiita_db/support_files/qiita-db.dbs

Lines changed: 97 additions & 94 deletions
Large diffs are not rendered by default.

qiita_db/support_files/qiita-db.html

Lines changed: 1388 additions & 1372 deletions
Large diffs are not rendered by default.

qiita_db/test/test_artifact.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ def test_name_setter(self):
12431243
def test_visibility_setter(self):
12441244
a = qdb.artifact.Artifact.create(
12451245
self.filepaths_root, "FASTQ", prep_template=self.prep_template)
1246+
12461247
self.assertEqual(a.visibility, "sandbox")
12471248
a.visibility = "awaiting_approval"
12481249
self.assertEqual(a.visibility, "awaiting_approval")
@@ -1285,6 +1286,24 @@ def test_visibility_setter(self):
12851286
self.assertEqual(a5.visibility, "private")
12861287
self.assertEqual(a6.visibility, "private")
12871288

1289+
# testing human_reads_filter_method here as in the future we might
1290+
# want to check that this property is inherited as visibility is;
1291+
# however, for the time being we don't need to do that and there is
1292+
# no downside on adding it here.
1293+
mtd = 'The greatest human filtering method'
1294+
self.assertEqual(mtd, a1.human_reads_filter_method)
1295+
self.assertIsNone(a2.human_reads_filter_method)
1296+
self.assertIsNone(a3.human_reads_filter_method)
1297+
1298+
# let's change some values
1299+
with self.assertRaisesRegex(ValueError, '"This should fail" is not a '
1300+
'valid human_reads_filter_method'):
1301+
a2.human_reads_filter_method = 'This should fail'
1302+
self.assertIsNone(a2.human_reads_filter_method)
1303+
a2.human_reads_filter_method = mtd
1304+
self.assertEqual(mtd, a2.human_reads_filter_method)
1305+
self.assertIsNone(a3.human_reads_filter_method)
1306+
12881307
def test_ebi_run_accessions_setter(self):
12891308
a = qdb.artifact.Artifact(3)
12901309
self.assertEqual(a.ebi_run_accessions, dict())

qiita_pet/handlers/study_handlers/prep_template.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ def get(self):
8888
'output'].html_summary_fp[1]
8989
summary = relpath(_file, qiita_config.base_data_dir)
9090
res['creation_job_artifact_summary'] = summary
91+
# res['']
92+
res['human_reads_filter_method'] = None
93+
a = PrepTemplate(prep_id).artifact
94+
if a is not None:
95+
hrfm = a.human_reads_filter_method
96+
if hrfm is not None:
97+
res['human_reads_filter_method'] = hrfm
9198

9299
self.render('study_ajax/prep_summary.html', **res)
93100

qiita_pet/templates/study_ajax/prep_summary.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ <h5>
467467

468468
<div class="row">
469469
<div class="col-md-12">
470+
{% if human_reads_filter_method is not None %}
471+
<h7> The raw data of this preparation was pre-processed via: <b>{{ human_reads_filter_method }}</b></h7>
472+
{% end %}
473+
470474
<ul class="nav nav-pills">
471475
<li style="border: 1px solid #428bca; border-radius: 5px"><a data-toggle="tab" href="#sample-listing-tab-div">Sample Listing</a></li>
472476
<li style="border: 1px solid #428bca; border-radius: 5px"><a data-toggle="tab" href="#summary-tab-div">Summary</a></li>

0 commit comments

Comments
 (0)