From ce3f1bf999a4fbbeaba6a7bf559eccb3995286ec Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Mon, 7 Aug 2023 15:31:40 -0600 Subject: [PATCH] adding tgz to artifacts --- qp_woltka/tests/test_woltka.py | 4 ++-- qp_woltka/woltka.py | 33 +++++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/qp_woltka/tests/test_woltka.py b/qp_woltka/tests/test_woltka.py index 7b1acc0..8281b47 100644 --- a/qp_woltka/tests/test_woltka.py +++ b/qp_woltka/tests/test_woltka.py @@ -185,7 +185,7 @@ def test_woltka_to_array_rep82(self): 'wait\n', '\n', f'cd {out_dir}; tar -cvf alignment.tar *.sam.xz; ' - 'tar zxvf coverages.tgz coverages\n', + 'tar zxvf coverages.tgz artifact.cov coverages\n', 'fi\n', f'finish_woltka {url} {job_id} {out_dir}\n', 'date\n'] @@ -314,7 +314,7 @@ def test_woltka_to_array_wol(self): 'wait\n', '\n', f'cd {out_dir}; tar -cvf alignment.tar *.sam.xz; ' - 'tar zxvf coverages.tgz coverages\n', + 'tar zxvf coverages.tgz artifact.cov coverages\n', 'fi\n', f'finish_woltka {url} {job_id} {out_dir}\n', 'date\n'] diff --git a/qp_woltka/woltka.py b/qp_woltka/woltka.py index ea87aaa..81b3538 100644 --- a/qp_woltka/woltka.py +++ b/qp_woltka/woltka.py @@ -5,9 +5,10 @@ # # The full license is in the file LICENSE, distributed with this software. # ----------------------------------------------------------------------------- -from os import environ +from os import environ, mkdir from os.path import join, basename, exists, dirname from glob import glob +from shutil import copy2 from qiita_client import ArtifactInfo @@ -141,7 +142,7 @@ def woltka_to_array(files, output, database_bowtie2, prep, url, name): "wait", '\n'.join(fcmds), f'cd {output}; tar -cvf alignment.tar *.sam.xz; ' - 'tar zxvf coverages.tgz coverages\n' + 'tar zxvf coverages.tgz artifact.cov coverages\n' 'fi', f'finish_woltka {url} {name} {output}\n' "date"] # end time @@ -248,13 +249,22 @@ def woltka(qclient, job_id, parameters, out_dir): """ db_files = _process_database_files(parameters['Database']) + def _coverage_copy(dest): + fp_coverages = f'{out_dir}/coverages.tgz' + mkdir(dest) + dest = f'{dest}/coverages.tgz' + copy2(fp_coverages, dest) + + return dest + errors = [] ainfo = [] fp_biom = f'{out_dir}/free.biom' fp_alng = f'{out_dir}/alignment.tar' if exists(fp_biom) and exists(fp_alng): ainfo = [ArtifactInfo('Alignment Profile', 'BIOM', [ - (fp_biom, 'biom'), (fp_alng, 'log')])] + (fp_biom, 'biom'), (fp_alng, 'log'), + (_coverage_copy(f'{out_dir}/alignment/'), 'plan_text')])] else: ainfo = [] errors.append('Missing files from the "Alignment Profile"; please ' @@ -263,7 +273,8 @@ def woltka(qclient, job_id, parameters, out_dir): fp_biom = f'{out_dir}/none.biom' if exists(fp_biom): ainfo.append(ArtifactInfo('Per genome Predictions', 'BIOM', [ - (fp_biom, 'biom')])) + (fp_biom, 'biom'), + (_coverage_copy(f'{out_dir}/none/'), 'plan_text')])) else: errors.append('Table none/per-genome was not created, please contact ' 'qiita.help@gmail.com for more information') @@ -272,7 +283,8 @@ def woltka(qclient, job_id, parameters, out_dir): fp_biom = f'{out_dir}/per-gene.biom' if exists(fp_biom): ainfo.append(ArtifactInfo('Per gene Predictions', 'BIOM', [ - (fp_biom, 'biom')])) + (fp_biom, 'biom'), + (_coverage_copy(f'{out_dir}/per_gene/'), 'plan_text')])) else: errors.append('Table per-gene was not created, please contact ' 'qiita.help@gmail.com for more information') @@ -283,7 +295,8 @@ def woltka(qclient, job_id, parameters, out_dir): fp_biom = f'{out_dir}/ko.biom' if exists(fp_biom): ainfo.append(ArtifactInfo('KEGG Ontology (KO)', 'BIOM', [ - (fp_biom, 'biom')])) + (fp_biom, 'biom'), + (_coverage_copy(f'{out_dir}/ko/'), 'plan_text')])) else: errors.append('Table KEGG Ontology was not created, please ' 'contact qiita.help@gmail.com for more ' @@ -293,7 +306,8 @@ def woltka(qclient, job_id, parameters, out_dir): fp_biom = f'{out_dir}/ec.biom' if exists(fp_biom): ainfo.append(ArtifactInfo('KEGG Enzyme (EC)', 'BIOM', [ - (fp_biom, 'biom')])) + (fp_biom, 'biom'), + (_coverage_copy(f'{out_dir}/ec/'), 'plan_text')])) else: errors.append('Table KEGG Enzyme was not created, please ' 'contact qiita.help@gmail.com for more ' @@ -305,7 +319,10 @@ def woltka(qclient, job_id, parameters, out_dir): fp_biom = f'{out_dir}/pathway.biom' if exists(fp_biom): ainfo.append( - ArtifactInfo('KEGG Pathway', 'BIOM', [(fp_biom, 'biom')])) + ArtifactInfo('KEGG Pathway', 'BIOM', [ + (fp_biom, 'biom'), + (_coverage_copy(f'{out_dir}/pathway/'), + 'plan_text')])) else: errors.append('Table KEGG Pathway was not created, please ' 'contact qiita.help@gmail.com for more '