Skip to content

Commit

Permalink
adding tgz to artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
antgonza committed Aug 7, 2023
1 parent 228f198 commit ce3f1bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions qp_woltka/tests/test_woltka.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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']
Expand Down
33 changes: 25 additions & 8 deletions qp_woltka/woltka.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 '
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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 '
Expand All @@ -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 '
Expand All @@ -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 '
Expand Down

0 comments on commit ce3f1bf

Please sign in to comment.