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

Human reads filter method #3422

Merged
merged 13 commits into from
Jul 2, 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
48 changes: 48 additions & 0 deletions qiita_db/artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -1684,3 +1684,51 @@ def get_commands(self):
cids = cmds & cids

return [qdb.software.Command(cid) for cid in cids]

@property
def human_reads_filter_method(self):
"""The human_reads_filter_method of the artifact

Returns
-------
str
The human_reads_filter_method name
"""
with qdb.sql_connection.TRN:
sql = """SELECT human_reads_filter_method
FROM qiita.artifact
LEFT JOIN qiita.human_reads_filter_method
USING (human_reads_filter_method_id)
WHERE artifact_id = %s"""
qdb.sql_connection.TRN.add(sql, [self.id])
return qdb.sql_connection.TRN.execute_fetchlast()

@human_reads_filter_method.setter
def human_reads_filter_method(self, value):
"""Set the human_reads_filter_method of the artifact

Parameters
----------
value : str
The new artifact's human_reads_filter_method

Raises
------
ValueError
If `value` doesn't exist in the database
"""
with qdb.sql_connection.TRN:
sql = """SELECT human_reads_filter_method_id
FROM qiita.human_reads_filter_method
WHERE human_reads_filter_method = %s"""
qdb.sql_connection.TRN.add(sql, [value])
idx = qdb.sql_connection.TRN.execute_fetchflatten()

if len(idx) == 0:
raise ValueError(
f'"{value}" is not a valid human_reads_filter_method')

sql = """UPDATE qiita.artifact
SET human_reads_filter_method_id = %s
WHERE artifact_id = %s"""
qdb.sql_connection.TRN.add(sql, [idx[0], self.id])
15 changes: 7 additions & 8 deletions qiita_db/support_files/patches/92.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,18 @@ ALTER TABLE qiita.qiita_user ADD social_orcid character varying DEFAULT NULL;
ALTER TABLE qiita.qiita_user ADD social_researchgate character varying DEFAULT NULL;
ALTER TABLE qiita.qiita_user ADD social_googlescholar character varying DEFAULT NULL;

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

CREATE TABLE qiita.human_reads_filter_method (
human_reads_filter_method_id bigint NOT NULL,
human_reads_filter_method_method character varying NOT NULL,
CONSTRAINT pk_human_reads_filter_method_id PRIMARY KEY (
human_reads_filter_method_id )
);
CREATE TABLE qiita.human_reads_filter_method (
human_reads_filter_method_id SERIAL PRIMARY KEY,
human_reads_filter_method character varying NOT NULL
);

ALTER TABLE qiita.prep_template
ALTER TABLE qiita.artifact
ADD human_reads_filter_method_id bigint DEFAULT NULL;
ALTER TABLE qiita.prep_template
ALTER TABLE qiita.artifact
ADD CONSTRAINT fk_human_reads_filter_method
FOREIGN KEY ( human_reads_filter_method_id )
REFERENCES qiita.human_reads_filter_method ( human_reads_filter_method_id );
10 changes: 10 additions & 0 deletions qiita_db/support_files/patches/test_db_sql/92.sql
Original file line number Diff line number Diff line change
Expand Up @@ -942,3 +942,13 @@ WHERE email = '[email protected]';
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);
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);
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);

-- Jul 1, 2024
-- Inserting a human_reads_filter_method and assigning it to the raw data in prep/artifact 1
INSERT INTO qiita.human_reads_filter_method (
human_reads_filter_method)
VALUES (
'The greatest human filtering method');
charles-cowart marked this conversation as resolved.
Show resolved Hide resolved
UPDATE qiita.artifact
SET human_reads_filter_method_id = 1
WHERE artifact_id = 1;
191 changes: 97 additions & 94 deletions qiita_db/support_files/qiita-db.dbs

Large diffs are not rendered by default.

2,760 changes: 1,388 additions & 1,372 deletions qiita_db/support_files/qiita-db.html

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions qiita_db/test/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,7 @@ def test_name_setter(self):
def test_visibility_setter(self):
a = qdb.artifact.Artifact.create(
self.filepaths_root, "FASTQ", prep_template=self.prep_template)

self.assertEqual(a.visibility, "sandbox")
a.visibility = "awaiting_approval"
self.assertEqual(a.visibility, "awaiting_approval")
Expand Down Expand Up @@ -1285,6 +1286,24 @@ def test_visibility_setter(self):
self.assertEqual(a5.visibility, "private")
self.assertEqual(a6.visibility, "private")

# testing human_reads_filter_method here as in the future we might
# want to check that this property is inherited as visibility is;
# however, for the time being we don't need to do that and there is
# no downside on adding it here.
mtd = 'The greatest human filtering method'
self.assertEqual(mtd, a1.human_reads_filter_method)
self.assertIsNone(a2.human_reads_filter_method)
self.assertIsNone(a3.human_reads_filter_method)

# let's change some values
with self.assertRaisesRegex(ValueError, '"This should fail" is not a '
'valid human_reads_filter_method'):
a2.human_reads_filter_method = 'This should fail'
self.assertIsNone(a2.human_reads_filter_method)
a2.human_reads_filter_method = mtd
self.assertEqual(mtd, a2.human_reads_filter_method)
self.assertIsNone(a3.human_reads_filter_method)

def test_ebi_run_accessions_setter(self):
a = qdb.artifact.Artifact(3)
self.assertEqual(a.ebi_run_accessions, dict())
Expand Down
7 changes: 7 additions & 0 deletions qiita_pet/handlers/study_handlers/prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ def get(self):
'output'].html_summary_fp[1]
summary = relpath(_file, qiita_config.base_data_dir)
res['creation_job_artifact_summary'] = summary
# res['']
res['human_reads_filter_method'] = None
a = PrepTemplate(prep_id).artifact
if a is not None:
hrfm = a.human_reads_filter_method
if hrfm is not None:
res['human_reads_filter_method'] = hrfm

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

Expand Down
4 changes: 4 additions & 0 deletions qiita_pet/templates/study_ajax/prep_summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ <h5>

<div class="row">
<div class="col-md-12">
{% if human_reads_filter_method is not None %}
<h7> The raw data of this preparation was pre-processed via: <b>{{ human_reads_filter_method }}</b></h7>
{% end %}

<ul class="nav nav-pills">
<li style="border: 1px solid #428bca; border-radius: 5px"><a data-toggle="tab" href="#sample-listing-tab-div">Sample Listing</a></li>
<li style="border: 1px solid #428bca; border-radius: 5px"><a data-toggle="tab" href="#summary-tab-div">Summary</a></li>
Expand Down
Loading