Skip to content

Commit

Permalink
renaming files
Browse files Browse the repository at this point in the history
  • Loading branch information
antgonza committed Oct 9, 2024
1 parent 7297d62 commit d991141
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/qiita-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 3 additions & 11 deletions qp_meta/sortmerna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
27 changes: 19 additions & 8 deletions qp_meta/sortmerna/sortmerna.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down
51 changes: 36 additions & 15 deletions qp_meta/sortmerna/tests/test_sortmerna.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -96,7 +93,7 @@ def _helper_tester(self, prep_info_dict, just_forward=True):
self.params['input'] = aid

data = {'user': '[email protected]',
'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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d991141

Please sign in to comment.