Skip to content

Commit

Permalink
Fix broken --reorder for paired minimap2 under Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bede committed Jan 13, 2024
1 parent ae632d7 commit 422ce2e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/hostile/aligner.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,10 @@ def gen_paired_clean_cmd(
" | samtools view -hF 12 -" if invert else " | samtools view -f 12 -"
)
reorder_cmd = ""
if reorder: # Under MacOS, Bowtie2's native --reorder is very slow
if util.get_platform() == "darwin":
if self.name == "Bowtie2" and reorder:
if (
util.get_platform() == "darwin"
): # Under MacOS, Bowtie2's native --reorder is very slow
reorder_cmd = " | samtools sort -n -O sam -@ 6 -m 1G" if reorder else ""
else: # Under Linux, Bowtie2's --reorder option works very well
reorder_cmd = ""
Expand Down
21 changes: 18 additions & 3 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ def test_invert_single():
fastqs=[data_dir / "sars-cov-2_1_1.fastq"],
aligner=lib.ALIGNER.minimap2,
index=data_dir / "sars-cov-2/sars-cov-2.fasta.gz",
reorder=True,
out_dir=out_dir,
invert=True,
force=True,
Expand All @@ -568,6 +567,24 @@ def test_invert_single():


def test_invert_paired():
stats = lib.clean_paired_fastqs(
fastqs=[
(
data_dir / "sars-cov-2_1_1.fastq",
data_dir / "sars-cov-2_1_2.fastq",
),
],
aligner=lib.ALIGNER.bowtie2,
index=data_dir / "sars-cov-2/sars-cov-2",
out_dir=out_dir,
invert=True,
force=True,
)
assert stats[0]["reads_out"] == 2
shutil.rmtree(out_dir, ignore_errors=True)


def test_minimap2_reordering_linux():
stats = lib.clean_paired_fastqs(
fastqs=[
(
Expand All @@ -579,8 +596,6 @@ def test_invert_paired():
index=data_dir / "sars-cov-2/sars-cov-2.fasta.gz",
reorder=True,
out_dir=out_dir,
invert=True,
force=True,
)
assert stats[0]["reads_out"] == 2
shutil.rmtree(out_dir, ignore_errors=True)

0 comments on commit 422ce2e

Please sign in to comment.