From 8ee0c998a69d24ffab792f3de6de8cbff4cc3d39 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Thu, 2 Nov 2023 18:11:38 -0600 Subject: [PATCH] woltka_syndna_to_array --- qp_woltka/__init__.py | 2 +- qp_woltka/woltka.py | 6 ++++++ scripts/start_woltka | 43 +++++++++++++++++++++---------------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/qp_woltka/__init__.py b/qp_woltka/__init__.py index f4d5c28..e7c8645 100644 --- a/qp_woltka/__init__.py +++ b/qp_woltka/__init__.py @@ -46,7 +46,7 @@ 'input': ('artifact', ['per_sample_FASTQ']) } opt_params = { - 'Database': [f"choice: [{db_path}]", db_path] + 'Database': [f'choice: ["{db_path}"]', db_path] } outputs = { 'SynDNA hits': 'BIOM', diff --git a/qp_woltka/woltka.py b/qp_woltka/woltka.py index 514d365..ebb2c54 100644 --- a/qp_woltka/woltka.py +++ b/qp_woltka/woltka.py @@ -233,6 +233,12 @@ def woltka_to_array(files, output, database_bowtie2, prep, url, name): return main_fp, merge_fp +def woltka_syndna_to_array(files, output, database_bowtie2, prep, url, name): + """Creates files for submission of per sample bowtie2 and woltka_syndna + """ + raise ValueError('SynDNA not implemented') + + def syndna_woltka(qclient, job_id, parameters, out_dir): """ """ diff --git a/scripts/start_woltka b/scripts/start_woltka index 7d939b2..de9c98a 100755 --- a/scripts/start_woltka +++ b/scripts/start_woltka @@ -12,7 +12,7 @@ from subprocess import run, PIPE from os.path import dirname from qp_woltka import plugin -from qp_woltka.woltka import woltka_to_array +from qp_woltka.woltka import woltka_to_array, woltka_syndna_to_array from qp_woltka.util import client_connect @@ -36,32 +36,31 @@ def execute(url, job_id, out_dir): job_id, "Step 1 of 4: Collecting info and generating submission") artifact_id = parameters['input'] del parameters['input'] + files, prep = qclient.artifact_and_preparation_files(artifact_id) - if command.lower.startswith('woltka'): - files, prep = qclient.artifact_and_preparation_files(artifact_id) - - directory = {dirname(ffs['filepath']) for _, fs in files.items() - for ffs in fs if ffs is not None} - if len(directory) != 1: - msg = ('There is more than one input directory [%s]; please ' - 'contact qiita.help@gmail.com' % str(directory)) - return False, None, msg - else: - directory = directory.pop() + directory = {dirname(ffs['filepath']) for _, fs in files.items() + for ffs in fs if ffs is not None} + if len(directory) != 1: + msg = ('There is more than one input directory [%s]; please ' + 'contact qiita.help@gmail.com' % str(directory)) + return False, None, msg + else: + directory = directory.pop() - # Getting all the files from the database + if command.lower.startswith('woltka'): main_fp, merge_fp = woltka_to_array( files, out_dir, parameters['Database'], prep, url, job_id) - - # Submitting jobs and returning id - main_job = run(['sbatch', main_fp], stdout=PIPE) - main_job_id = main_job.stdout.decode('utf8').split()[-1] - merge_job = run(['sbatch', '-d', f'afterany:{main_job_id}', - merge_fp], stdout=PIPE) - merge_job_id = merge_job.stdout.decode('utf8').split()[-1] - print(f'{main_job_id}, {merge_job_id}') else: - raise ValueError('not implemented') + main_fp, merge_fp = woltka_syndna_to_array( + files, out_dir, parameters['Database'], prep, url, job_id) + + # Submitting jobs and returning id + main_job = run(['sbatch', main_fp], stdout=PIPE) + main_job_id = main_job.stdout.decode('utf8').split()[-1] + merge_job = run(['sbatch', '-d', f'afterany:{main_job_id}', + merge_fp], stdout=PIPE) + merge_job_id = merge_job.stdout.decode('utf8').split()[-1] + print(f'{main_job_id}, {merge_job_id}') qclient.update_job_step( job_id, "Step 2 of 4: Aligning sequences")