Skip to content

Commit

Permalink
Merge pull request #156 from charles-cowart/fastq_description_update
Browse files Browse the repository at this point in the history
Update to optional description support
  • Loading branch information
charles-cowart authored Oct 21, 2024
2 parents 9d5b7d4 + 49c773d commit 867ad4d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
4 changes: 3 additions & 1 deletion sequence_processing_pipeline/NuQCJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,10 @@ def _generate_mmi_filter_cmds(self, working_dir):
# been annotated with. Samtools will safely ignore tags that
# are not present.
tags = " -T %s" % ','.join(self.additional_fastq_tags)
t_switch = " -y"
else:
tags = ""
t_switch = ""

for count, mmi_db_path in enumerate(self.mmi_file_paths):
if count == 0:
Expand All @@ -428,7 +430,7 @@ def _generate_mmi_filter_cmds(self, working_dir):
input = tmp_file1
output = tmp_file2

cmds.append(f"minimap2 -2 -ax sr -y -t {cores_to_allocate} "
cmds.append(f"minimap2 -2 -ax sr{t_switch} -t {cores_to_allocate} "
f"{mmi_db_path} {input} -a | samtools fastq -@ "
f"{cores_to_allocate} -f 12 -F 256{tags} > "
f"{output}")
Expand Down
46 changes: 44 additions & 2 deletions sequence_processing_pipeline/tests/test_NuQCJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -2108,10 +2108,10 @@ def test_generate_mmi_filter_cmds(self):
obs = job._generate_mmi_filter_cmds("/my_work_dir")

exp = [
"minimap2 -2 -ax sr -y -t 2 db_path/mmi_1.db /my_work_dir/seqs."
"minimap2 -2 -ax sr -t 2 db_path/mmi_1.db /my_work_dir/seqs."
"interleaved.fastq -a | samtools fastq -@ 2 -f 12 -F 256 > "
"/my_work_dir/foo",
"minimap2 -2 -ax sr -y -t 2 db_path/mmi_2.db /my_work_dir/foo -a"
"minimap2 -2 -ax sr -t 2 db_path/mmi_2.db /my_work_dir/foo -a"
" | samtools fastq -@ 2 -f 12 -F 256 > /my_work_dir/bar",
"mv /my_work_dir/bar /my_work_dir/seqs.interleaved.filter_"
"alignment.fastq",
Expand All @@ -2123,6 +2123,48 @@ def test_generate_mmi_filter_cmds(self):

self.assertEqual(obs, exp)

def test_generate_mmi_filter_cmds_w_descriptions(self):
double_db_paths = ["db_path/mmi_1.db", "db_path/mmi_2.db"]
job = NuQCJob(
self.fastq_root_path,
self.output_path,
self.good_sample_sheet_path,
double_db_paths,
"queue_name",
1,
1440,
"8",
"fastp",
"minimap2",
"samtools",
[],
self.qiita_job_id,
1000,
"",
self.movi_path,
self.gres_value,
self.pmls_path,
["BX"]
)

obs = job._generate_mmi_filter_cmds("/my_work_dir")

exp = [
"minimap2 -2 -ax sr -y -t 2 db_path/mmi_1.db /my_work_dir/seqs."
"interleaved.fastq -a | samtools fastq -@ 2 -f 12 -F 256 -T BX > "
"/my_work_dir/foo",
"minimap2 -2 -ax sr -y -t 2 db_path/mmi_2.db /my_work_dir/foo -a"
" | samtools fastq -@ 2 -f 12 -F 256 -T BX > /my_work_dir/bar",
"mv /my_work_dir/bar /my_work_dir/seqs.interleaved.filter_"
"alignment.fastq",
"[ -e /my_work_dir/foo ] && rm /my_work_dir/foo",
"[ -e /my_work_dir/bar ] && rm /my_work_dir/bar",
]

exp = "\n".join(exp)

self.assertEqual(obs, exp)

def test_generate_mmi_filter_cmds_w_annotate_fastq(self):
double_db_paths = ["db_path/mmi_1.db", "db_path/mmi_2.db"]
job = NuQCJob(
Expand Down

0 comments on commit 867ad4d

Please sign in to comment.