Skip to content

Commit 8e7abc5

Browse files
antgonzawasademcmk3ElDeveloper
authored
Version 092020 (#3034)
* inject study_type in EBI and improvements to current automatic processing pipeline (#3023) * inject study_type in ebi and improvements to current automatic proecssing pipeline * addressing @ElDeveloper comments * some general fixes/additions for next release (#3026) * some general fixes/additions for next release * adding test for not None job.release_validator_job * fix #2839 * fix #2868 (#3028) * fix #2868 * 2nd round * fix errors * more changes * fix errors * fix ProcessingJobTest * fix PY_PATCH * add missing TRN.add * encapsulated_query -> perform_as_transaction * fix #3022 (#3030) * fix #3022 * adding tests * fix #2320 (#3031) * fix #2320 * adding prints to debug * children -> 1 * APIArtifactHandlerTest -> APIArtifactHandlerTests * configure_biom * qdb.util.activate_or_update_plugins * improving code * almost there * add values.template * fix filepaths * filepaths -> files * fixing errors * add prep.artifact insertion * addressing @ElDeveloper comments * fix artifact_definition active command * != -> == * Added three tutorial sections to the Qiita documentation (#3032) * Added three tutorial sections to the Qiita documentation: 'Retrieving Public Data for Own Analysis' and 'Processing public data retrieved with redbiom' to the redbiom tab, and 'Statistical Analysis to Justify Clinical Trial Sample Size Tutorial' to the analyzing samples tab. * Update redbiom.rst * Update redbiom.rst * Update redbiom.rst * Further updates to redbiom.rst and the Stats tutorial. * update redbiom.rst * Finished proof-reading * Placed all three tutorials/sections together under Introduction to the download and analysis of public Qiita data * added a new introduction, with links to the three sections * Added figures to stats tutorial and contexts explanation * Added figures to stats tutorial and contexts explanation * Apply suggestions from code review [skip ci] Co-authored-by: Yoshiki Vázquez Baeza <[email protected]> Co-authored-by: Antonio Gonzalez <[email protected]> Co-authored-by: Yoshiki Vázquez Baeza <[email protected]> * 092020 (#3033) * 092020 * connect artifact with job * rm INSERT qiita.artifact_processing_job * Apply suggestions from code review [skip ci] Co-authored-by: Yoshiki Vázquez Baeza <[email protected]> Co-authored-by: Yoshiki Vázquez Baeza <[email protected]> Co-authored-by: Daniel McDonald <[email protected]> Co-authored-by: Mirte Kuijpers <[email protected]> Co-authored-by: Yoshiki Vázquez Baeza <[email protected]>
1 parent d9275b7 commit 8e7abc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1953
-431
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ install:
6464
- pip install https://github.com/qiita-spots/qiita_client/archive/master.zip
6565
- pip install https://github.com/qiita-spots/qtp-biom/archive/master.zip
6666
- export QIITA_SERVER_CERT=`pwd`/qiita_core/support_files/server.crt
67-
- configure_biom --env-script "source ~/virtualenv/python2.7/bin/activate; export PATH=$HOME/miniconda3/bin/:$PATH; . activate qtp-biom" --server-cert $QIITA_SERVER_CERT
67+
- configure_biom --env-script "export PATH=$HOME/miniconda3/bin/:$PATH; source activate qtp-biom" --server-cert $QIITA_SERVER_CERT
6868
- source deactivate
6969
- source activate qiita
7070
before_script:

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Qiita changelog
22

3+
Version 092020
4+
--------------
5+
6+
* Added a new endpoint to inject artifacts to existing preparations or jobs: `/qiita_db/artifact/`
7+
* Outdated commands with the exact same name than newer commands will be marked as not outdated. This is helpful for cases where the commands haven't changed between version
8+
* Added the `add_ebi_accessions` to the `to_dataframe()` method of the information files so it can be used to `redbiom`. This will allow searching via sample or experiment accessions
9+
* Added the `release_validator_job` method to `ProcessingJob` method to easily retrieve the `release_validator` job of a `processing_job`
10+
* Re-added `STUDY_TYPE` to the EBI-ENA submission as they are required but deprecated so just adding as Other
11+
* Added qiime2.2020.08 to the system; which updated these plugins: qp-qiime2, qtp-biom, qtp-diversity, qtp-visualization
12+
* Shogun processing using Woltka will now produce 2 extra artifacts: a per genome and per gene artifacts
13+
314
Version 072020
415
--------------
516

README.rst

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ compute resources to the global community, alleviating the technical burdens,
1717
such as familiarity with the command line or access to compute power, that are
1818
typically limiting for researchers studying microbial ecology.
1919

20-
Qiita is currently in alpha status. We are very open to community
20+
Qiita is currently in beta status. We are very open to community
2121
contributions and feedback. If you're interested in contributing to Qiita,
2222
see `CONTRIBUTING.md <https://github.com/biocore/qiita/blob/master/CONTRIBUTING.md>`__.
2323
If you'd like to report bugs or request features, you can do that in the
@@ -43,9 +43,7 @@ Current features
4343

4444
* Target gene data: we support deblur against GreenGenes (13_8) and close
4545
reference picking against GreenGenes (13_8) and Silva.
46-
* Metagenoic/Shotgun data: we support Shogun processing. Note that this data
47-
is suitable for download and further down stream analyses but we don't recommend
48-
meta-analysis within Qiita (only single study).
46+
* Metagenomic and Metatranscriptomic data: we support Shogun processing.
4947
* biom files can be added as new preparation templates for downstream
5048
analyses; however, this cannot be made public.
5149

qiita_core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# The full license is in the file LICENSE, distributed with this software.
77
# -----------------------------------------------------------------------------
88

9-
__version__ = "052020"
9+
__version__ = "092020"

qiita_db/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from . import user
2828
from . import processing_job
2929

30-
__version__ = "052020"
30+
__version__ = "092020"
3131

3232
__all__ = ["analysis", "artifact", "archive", "base", "commands",
3333
"environment_manager", "exceptions", "investigation", "logger",

qiita_db/analysis.py

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -355,11 +355,9 @@ def description(self, description):
355355
QiitaDBStatusError
356356
Analysis is public
357357
"""
358-
with qdb.sql_connection.TRN:
359-
sql = """UPDATE qiita.{0} SET description = %s
360-
WHERE analysis_id = %s""".format(self._table)
361-
qdb.sql_connection.TRN.add(sql, [description, self._id])
362-
qdb.sql_connection.TRN.execute()
358+
sql = """UPDATE qiita.{0} SET description = %s
359+
WHERE analysis_id = %s""".format(self._table)
360+
qdb.sql_connection.perform_as_transaction(sql, [description, self._id])
363361

364362
@property
365363
def samples(self):
@@ -513,11 +511,9 @@ def pmid(self, pmid):
513511
-----
514512
An analysis should only ever have one PMID attached to it.
515513
"""
516-
with qdb.sql_connection.TRN:
517-
sql = """UPDATE qiita.{0} SET pmid = %s
518-
WHERE analysis_id = %s""".format(self._table)
519-
qdb.sql_connection.TRN.add(sql, [pmid, self._id])
520-
qdb.sql_connection.TRN.execute()
514+
sql = """UPDATE qiita.{0} SET pmid = %s
515+
WHERE analysis_id = %s""".format(self._table)
516+
qdb.sql_connection.perform_as_transaction(sql, [pmid, self._id])
521517

522518
@property
523519
def can_be_publicized(self):
@@ -618,13 +614,11 @@ def set_error(self, error_msg):
618614
error_msg : str
619615
The error message
620616
"""
621-
with qdb.sql_connection.TRN:
622-
le = qdb.logger.LogEntry.create('Runtime', error_msg)
623-
sql = """UPDATE qiita.analysis
624-
SET logging_id = %s
625-
WHERE analysis_id = %s"""
626-
qdb.sql_connection.TRN.add(sql, [le.id, self.id])
627-
qdb.sql_connection.TRN.execute()
617+
le = qdb.logger.LogEntry.create('Runtime', error_msg)
618+
sql = """UPDATE qiita.analysis
619+
SET logging_id = %s
620+
WHERE analysis_id = %s"""
621+
qdb.sql_connection.perform_as_transaction(sql, [le.id, self.id])
628622

629623
def has_access(self, user):
630624
"""Returns whether the given user has access to the analysis
@@ -696,11 +690,9 @@ def share(self, user):
696690
if user.id == self.owner or user.id in self.shared_with:
697691
return
698692

699-
with qdb.sql_connection.TRN:
700-
sql = """INSERT INTO qiita.analysis_users (analysis_id, email)
701-
VALUES (%s, %s)"""
702-
qdb.sql_connection.TRN.add(sql, [self._id, user.id])
703-
qdb.sql_connection.TRN.execute()
693+
sql = """INSERT INTO qiita.analysis_users (analysis_id, email)
694+
VALUES (%s, %s)"""
695+
qdb.sql_connection.perform_as_transaction(sql, [self._id, user.id])
704696

705697
def unshare(self, user):
706698
"""Unshare the analysis with another user
@@ -710,11 +702,9 @@ def unshare(self, user):
710702
user: User object
711703
The user to unshare the analysis with
712704
"""
713-
with qdb.sql_connection.TRN:
714-
sql = """DELETE FROM qiita.analysis_users
715-
WHERE analysis_id = %s AND email = %s"""
716-
qdb.sql_connection.TRN.add(sql, [self._id, user.id])
717-
qdb.sql_connection.TRN.execute()
705+
sql = """DELETE FROM qiita.analysis_users
706+
WHERE analysis_id = %s AND email = %s"""
707+
qdb.sql_connection.perform_as_transaction(sql, [self._id, user.id])
718708

719709
def _lock_samples(self):
720710
"""Only dflt analyses can have samples added/removed

qiita_db/artifact.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,7 @@ def _associate_with_analysis(instance, analysis_id):
388388
(analysis_id, artifact_id)
389389
VALUES (%s, %s)"""
390390
sql_args = [analysis_id, instance.id]
391-
qdb.sql_connection.TRN.add(sql, sql_args)
392-
qdb.sql_connection.TRN.execute()
391+
qdb.sql_connection.perform_as_transaction(sql, sql_args)
393392

394393
with qdb.sql_connection.TRN:
395394
if parents:
@@ -673,12 +672,10 @@ def name(self, value):
673672
ValueError
674673
If `value` contains more than 35 chars
675674
"""
676-
with qdb.sql_connection.TRN:
677-
sql = """UPDATE qiita.artifact
678-
SET name = %s
679-
WHERE artifact_id = %s"""
680-
qdb.sql_connection.TRN.add(sql, [value, self.id])
681-
qdb.sql_connection.TRN.execute()
675+
sql = """UPDATE qiita.artifact
676+
SET name = %s
677+
WHERE artifact_id = %s"""
678+
qdb.sql_connection.perform_as_transaction(sql, [value, self.id])
682679

683680
@property
684681
def timestamp(self):
@@ -751,8 +748,7 @@ def _set_visibility(self, value):
751748
sql = """UPDATE qiita.artifact
752749
SET visibility_id = %s
753750
WHERE artifact_id IN %s"""
754-
qdb.sql_connection.TRN.add(sql, [vis_id, tuple(ids)])
755-
qdb.sql_connection.TRN.execute()
751+
qdb.sql_connection.perform_as_transaction(sql, [vis_id, tuple(ids)])
756752

757753
@visibility.setter
758754
def visibility(self, value):
@@ -989,15 +985,13 @@ def is_submitted_to_vamps(self, value):
989985
QiitaDBOperationNotPermittedError
990986
If the artifact cannot be submitted to VAMPS
991987
"""
992-
with qdb.sql_connection.TRN:
993-
if not self.can_be_submitted_to_vamps:
994-
raise qdb.exceptions.QiitaDBOperationNotPermittedError(
995-
"Artifact %s cannot be submitted to VAMPS" % self.id)
996-
sql = """UPDATE qiita.artifact
997-
SET submitted_to_vamps = %s
998-
WHERE artifact_id = %s"""
999-
qdb.sql_connection.TRN.add(sql, [value, self.id])
1000-
qdb.sql_connection.TRN.execute()
988+
if not self.can_be_submitted_to_vamps:
989+
raise qdb.exceptions.QiitaDBOperationNotPermittedError(
990+
"Artifact %s cannot be submitted to VAMPS" % self.id)
991+
sql = """UPDATE qiita.artifact
992+
SET submitted_to_vamps = %s
993+
WHERE artifact_id = %s"""
994+
qdb.sql_connection.perform_as_transaction(sql, [value, self.id])
1001995

1002996
@property
1003997
def filepaths(self):

qiita_db/download_link.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ def delete(cls, jti):
7272
jti : object
7373
The jwt token identifier
7474
"""
75-
with qdb.sql_connection.TRN:
76-
sql = """DELETE FROM qiita.{0} WHERE jti=%s""".format(cls._table)
77-
qdb.sql_connection.TRN.add(sql, [jti])
78-
qdb.sql_connection.TRN.execute()
75+
sql = """DELETE FROM qiita.{0} WHERE jti=%s""".format(cls._table)
76+
qdb.sql_connection.perform_as_transaction(sql, [jti])
7977

8078
@classmethod
8179
def exists(cls, jti):
@@ -98,10 +96,8 @@ def delete_expired(cls):
9896
r"""Deletes all expired download links"""
9997
now = datetime.now(timezone.utc)
10098

101-
with qdb.sql_connection.TRN:
102-
sql = """DELETE FROM qiita.{0} WHERE exp<%s""".format(cls._table)
103-
qdb.sql_connection.TRN.add(sql, [now])
104-
qdb.sql_connection.TRN.execute()
99+
sql = """DELETE FROM qiita.{0} WHERE exp<%s""".format(cls._table)
100+
qdb.sql_connection.perform_as_transaction(sql, [now])
105101

106102
@classmethod
107103
def get(cls, jti):

qiita_db/handlers/artifact.py

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
from tornado.web import HTTPError
1010
from collections import defaultdict
11-
from json import loads
11+
from json import loads, dumps
1212

13+
from qiita_core.qiita_settings import r_client
1314
import qiita_db as qdb
1415
from .oauth2 import OauthBaseHandler, authenticate_oauth
1516

@@ -234,3 +235,69 @@ def post(self):
234235
self.set_status(200, reason="Artifact type already exists")
235236

236237
self.finish()
238+
239+
240+
class APIArtifactHandler(OauthBaseHandler):
241+
@authenticate_oauth
242+
def post(self):
243+
user_email = self.get_argument('user_email')
244+
job_id = self.get_argument('job_id', None)
245+
prep_id = self.get_argument('prep_id', None)
246+
atype = self.get_argument('artifact_type')
247+
aname = self.get_argument('command_artifact_name', 'Name')
248+
files = self.get_argument('files')
249+
250+
if job_id is None and prep_id is None:
251+
raise HTTPError(
252+
400, reason='You need to specify a job_id or a prep_id')
253+
if job_id is not None and prep_id is not None:
254+
raise HTTPError(
255+
400, reason='You need to specify only a job_id or a prep_id')
256+
257+
user = qdb.user.User(user_email)
258+
values = {
259+
'files': files, 'artifact_type': atype, 'name': aname,
260+
# leaving here in case we need to add a way to add an artifact
261+
# directly to an analysis, for more information see
262+
# ProcessingJob._complete_artifact_transformation
263+
'analysis': None}
264+
PJ = qdb.processing_job.ProcessingJob
265+
if job_id is not None:
266+
TN = qdb.sql_connection.TRN
267+
job = PJ(job_id)
268+
with TN:
269+
sql = """SELECT command_output_id
270+
FROM qiita.command_output
271+
WHERE name = %s AND command_id = %s"""
272+
TN.add(sql, [aname, job.command.id])
273+
results = TN.execute_fetchflatten()
274+
if len(results) < 1:
275+
raise HTTPError(400, 'The command_artifact_name does not '
276+
'exist in the command')
277+
cmd_out_id = results[0]
278+
provenance = {'job': job_id,
279+
'cmd_out_id': cmd_out_id,
280+
# direct_creation is a flag to avoid having to wait
281+
# for the complete job to create the new artifact,
282+
# which is normally ran during regular processing.
283+
# Skipping is fine because we are adding an artifact
284+
# to an existing job outside of regular processing
285+
'direct_creation': True,
286+
'name': aname}
287+
values['provenance'] = dumps(provenance)
288+
# inherint the first prep info file from the first input artifact
289+
prep_id = job.input_artifacts[0].prep_templates[0].id
290+
else:
291+
prep_id = int(prep_id)
292+
293+
values['template'] = prep_id
294+
cmd = qdb.software.Command.get_validator(atype)
295+
params = qdb.software.Parameters.load(cmd, values_dict=values)
296+
new_job = PJ.create(user, params, True)
297+
new_job.submit()
298+
299+
r_client.set('prep_template_%d' % prep_id,
300+
dumps({'job_id': new_job.id, 'is_qiita_job': True}))
301+
302+
self.write(new_job.id)
303+
self.finish()

0 commit comments

Comments
 (0)