From d991141371e817f9695f67722978ab81a982cd72 Mon Sep 17 00:00:00 2001 From: Antonio Gonzalez Date: Wed, 9 Oct 2024 14:19:59 -0600 Subject: [PATCH] renaming files --- .github/workflows/qiita-plugin-ci.yml | 2 +- qp_meta/sortmerna/__init__.py | 14 ++----- qp_meta/sortmerna/sortmerna.py | 27 ++++++++---- qp_meta/sortmerna/tests/test_sortmerna.py | 51 ++++++++++++++++------- 4 files changed, 59 insertions(+), 35 deletions(-) diff --git a/.github/workflows/qiita-plugin-ci.yml b/.github/workflows/qiita-plugin-ci.yml index 5f655f2..82bf229 100644 --- a/.github/workflows/qiita-plugin-ci.yml +++ b/.github/workflows/qiita-plugin-ci.yml @@ -81,7 +81,7 @@ jobs: conda config --add channels anaconda conda config --add channels conda-forge conda config --add channels bioconda - conda create -q --yes -n qp-meta python=3.9 biom-format sortmerna=4.3.2 samtools pigz + conda create -q --yes -n qp-meta python=3.9 biom-format sortmerna=4.3.7 samtools pigz conda activate qp-meta export QIITA_ROOTCA_CERT=`pwd`/qiita-dev/qiita_core/support_files/ci_rootca.crt diff --git a/qp_meta/sortmerna/__init__.py b/qp_meta/sortmerna/__init__.py index 6d29cd5..b1df722 100644 --- a/qp_meta/sortmerna/__init__.py +++ b/qp_meta/sortmerna/__init__.py @@ -14,24 +14,16 @@ # Defining the Sortmerna command req_params = {'input': ('artifact', ['per_sample_FASTQ'])} -opt_params = { - 'Output blast format': ['integer', '1'], - 'Number of alignments': ['integer', '1'], - 'Memory': ['integer', '3988'] - } +opt_params = {} outputs = {'Non-ribosomal reads': 'per_sample_FASTQ', 'Ribosomal reads': 'per_sample_FASTQ'} # defining default parameter set AKA what's going to be shown to the user # as options for the command dflt_param_set = { - 'Ribosomal read filtering': { - 'Output blast format': 1, - 'Number of alignments': 1, - 'Memory': 31000 - } + 'Ribosomal read filtering': {} } sortmerna_cmd = QiitaCommand( - 'Sortmerna v4.3.2', "Ribosomal read filtering", sortmerna, + 'SortMeRNA v4.3.7', "Ribosomal read filtering", sortmerna, req_params, opt_params, outputs, dflt_param_set) diff --git a/qp_meta/sortmerna/sortmerna.py b/qp_meta/sortmerna/sortmerna.py index 906eef3..7e8cc22 100644 --- a/qp_meta/sortmerna/sortmerna.py +++ b/qp_meta/sortmerna/sortmerna.py @@ -15,7 +15,8 @@ DIR = environ["QC_SORTMERNA_DB_DP"] -RNA_REF_DB = ('--ref {0}smr_v4.3_default_db.fasta').format(DIR) +RNA_REF_DB = ( + '--ref {0}smr_v4.3_default_db.fasta --idx-dir {0}idx/').format(DIR) # resources per job @@ -62,26 +63,36 @@ def generate_sortmerna_commands(forward_seqs, reverse_seqs, map_file, samples = make_read_pairs_per_sample(forward_seqs, reverse_seqs, map_file) cmds = [] - # --aligned {smr_r_op} --other {smr_nr_op} + if reverse_seqs: template = ( "sortmerna {ref_db} --reads {fwd} --reads {rev} --workdir {wkdir} " "--other --aligned --fastx --blast 1 --num_alignments 1 " - "--threads {thrds} --paired_in --out2 -m 3988 --log") + "--threads {thrds} --paired_in --out2 -index 0; " + "mv {wkdir}/out/aligned_fwd.fq.gz {out_dir}/{fname}." + "ribosomal.R1.fastq.gz; " + "mv {wkdir}/out/aligned_rev.fq.gz {out_dir}/{fname}." + "ribosomal.R2.fastq.gz; " + "mv {wkdir}/out/other_fwd.fq.gz {out_dir}/{fname}." + "nonribosomal.R1.fastq.gz; " + "mv {wkdir}/out/other_rev.fq.gz {out_dir}/{fname}." + "nonribosomal.R2.fastq.gz; ") else: template = ( "sortmerna {ref_db} --reads {fwd} --workdir {wkdir} " "--other --aligned --fastx --blast 1 --num_alignments 1 " - "--threads {thrds} --out2 -m 3988 --log") + "--threads {thrds} --out2 -index 0; " + "mv {wkdir}/out/aligned_fwd.fq.gz {out_dir}/{fname}." + "ribosomal.R1.fastq.gz; " + "mv {wkdir}/out/other_fwd.fq.gz {out_dir}/{fname}." + "nonribosomal.R1.fastq.gz; ") - arguments = {'thrds': PPN, 'ref_db': RNA_REF_DB} + arguments = {'thrds': PPN, 'ref_db': RNA_REF_DB, 'out_dir': out_dir} for run_prefix, sample, f_fp, r_fp in samples: arguments['wkdir'] = join(out_dir, run_prefix) arguments['fwd'] = f_fp arguments['rev'] = r_fp - - # arguments['smr_r_op_gz'] = arguments['smr_r_op'] + '.fastq.gz' - # arguments['smr_nr_op_gz'] = arguments['smr_nr_op'] + '.fastq.gz' + arguments['fname'] = run_prefix cmds.append(template.format(**arguments)) diff --git a/qp_meta/sortmerna/tests/test_sortmerna.py b/qp_meta/sortmerna/tests/test_sortmerna.py index 72510f2..dfd91c4 100644 --- a/qp_meta/sortmerna/tests/test_sortmerna.py +++ b/qp_meta/sortmerna/tests/test_sortmerna.py @@ -35,11 +35,7 @@ class QC_SortmernaTests(PluginTestCase): def setUp(self): plugin("https://localhost:21174", 'register', 'ignored') - self.params = { - 'Output blast format': '1', - 'Number of alignments': '1', - 'Memory': '3988', - } + self.params = {} self._clean_up_files = [] def tearDown(self): @@ -51,12 +47,13 @@ def tearDown(self): remove(fp) def test_format_sortmerna_params(self): - obs = _format_params(self.params, SORTMERNA_PARAMS) - exp = ( - '--blast 1 ' + obs = _format_params( + {'Output blast format': '1', + 'Number of alignments': '1', + 'Memory': '3988'}, SORTMERNA_PARAMS) + exp = ('--blast 1 ' '-m 3988 ' - '--num_alignments 1' - ) + '--num_alignments 1') self.assertEqual(obs, exp) def _helper_tester(self, prep_info_dict, just_forward=True): @@ -96,7 +93,7 @@ def _helper_tester(self, prep_info_dict, just_forward=True): self.params['input'] = aid data = {'user': 'demo@microbio.me', - 'command': dumps(['qp-meta', '2024.10', 'Sortmerna v4.3.2']), + 'command': dumps(['qp-meta', '2024.10', 'SortMeRNA v4.3.7']), 'status': 'running', 'parameters': dumps(self.params)} job_id = self.qclient.post( @@ -207,13 +204,29 @@ def test_generate_sortmerna_analysis_commands_forward_reverse(self): f'--reads {adir}/S22205_S104_L001_R2_001.fastq.gz ' f'--workdir {out_dir}/S22205_S104 --other --aligned --fastx ' f'--blast 1 --num_alignments 1 --threads 10 --paired_in --out2 ' - '-m 3988 --log\n', + '-index 0; ' + f'mv {out_dir}/S22205_S104/out/aligned_fwd.fq.gz ' + f'{out_dir}/S22205_S104.ribosomal.R1.fastq.gz; ' + f'mv {out_dir}/S22205_S104/out/aligned_rev.fq.gz ' + f'{out_dir}/S22205_S104.ribosomal.R2.fastq.gz; ' + f'mv {out_dir}/S22205_S104/out/other_fwd.fq.gz ' + f'{out_dir}/S22205_S104.nonribosomal.R1.fastq.gz; ' + f'mv {out_dir}/S22205_S104/out/other_rev.fq.gz ' + f'{out_dir}/S22205_S104.nonribosomal.R2.fastq.gz; \n', f'sortmerna {RNA_REF_DB} ' f'--reads {adir}/S22282_S102_L001_R1_001.fastq.gz ' f'--reads {adir}/S22282_S102_L001_R2_001.fastq.gz ' f'--workdir {out_dir}/S22282_S102 --other --aligned --fastx ' f'--blast 1 --num_alignments 1 --threads 10 --paired_in --out2 ' - '-m 3988 --log'] + '-index 0; ' + f'mv {out_dir}/S22282_S102/out/aligned_fwd.fq.gz ' + f'{out_dir}/S22282_S102.ribosomal.R1.fastq.gz; ' + f'mv {out_dir}/S22282_S102/out/aligned_rev.fq.gz ' + f'{out_dir}/S22282_S102.ribosomal.R2.fastq.gz; ' + f'mv {out_dir}/S22282_S102/out/other_fwd.fq.gz ' + f'{out_dir}/S22282_S102.nonribosomal.R1.fastq.gz; ' + f'mv {out_dir}/S22282_S102/out/other_rev.fq.gz ' + f'{out_dir}/S22282_S102.nonribosomal.R2.fastq.gz; '] self.assertEqual(exp_details, details) # making sure it finishes correctly @@ -351,12 +364,20 @@ def test_generate_sortmerna_analysis_commands_forward(self): f'--reads {adir}/S22205_S104_L001_R1_001.fastq.gz ' f'--workdir {out_dir}/S22205_S104 --other --aligned --fastx ' f'--blast 1 --num_alignments 1 --threads 10 ' - '--out2 -m 3988 --log\n', + '--out2 -index 0; ' + f'mv {out_dir}/S22205_S104/out/aligned_fwd.fq.gz ' + f'{out_dir}/S22205_S104.ribosomal.R1.fastq.gz; ' + f'mv {out_dir}/S22205_S104/out/other_fwd.fq.gz ' + f'{out_dir}/S22205_S104.nonribosomal.R1.fastq.gz; \n', f'sortmerna {RNA_REF_DB} ' f'--reads {adir}/S22282_S102_L001_R1_001.fastq.gz ' f'--workdir {out_dir}/S22282_S102 --other --aligned --fastx ' f'--blast 1 --num_alignments 1 --threads 10 ' - '--out2 -m 3988 --log'] + '--out2 -index 0; ' + f'mv {out_dir}/S22282_S102/out/aligned_fwd.fq.gz ' + f'{out_dir}/S22282_S102.ribosomal.R1.fastq.gz; ' + f'mv {out_dir}/S22282_S102/out/other_fwd.fq.gz ' + f'{out_dir}/S22282_S102.nonribosomal.R1.fastq.gz; '] self.assertEqual(exp_details, details) # making sure it finishes correctly