def test_single_alignment(fastq_record: FastqRecord, ref_fasta: Path) -> None: # run BWA results = list(align(reads=[fastq_record], idxbase=ref_fasta)) # Check the returned alignments assert len(results) == 1 _assert_alignment_for_fastq_record(read=fastq_record, results=results[0])
def test_paired_end_reads(fastq_record: FastqRecord, ref_fasta: Path) -> None: # run BWA r1 = attr.evolve(fastq_record, read_number=1) r2 = attr.evolve(r1, read_number=2) io_opts = InputOutputOptions(interleaved_pairs=True) results = list(align(reads=[r1, r2], idxbase=ref_fasta, io_opts=io_opts)) _assert_alignment_for_fastq_record(read=r1, results=results[0]) _assert_alignment_for_fastq_record(read=r2, results=results[1])
def test_no_alignment(ref_fasta: Path) -> None: fastq_record = FastqRecord(name="unmapped", bases="A" * 60, quals="I" * 60, needs_alignment=False) # run BWA results = list(align(reads=[fastq_record], idxbase=ref_fasta)) # Check the returned alignments assert len(results) == 1 fastq, alignments = results[0] assert len(alignments) == 0 assert fastq_record == fastq
def test_needs_alignment(fastq_record: FastqRecord, ref_fasta: Path) -> None: # run BWA rec1 = fastq_record rec2 = FastqRecord(name="needs_alignment=False", bases=rec1.bases, quals=rec1.quals, needs_alignment=False) results = list(align(reads=[rec1, rec2], idxbase=ref_fasta)) # Check the returned alignments assert len(results) == 2 for result in results: fastq, alignments = result if fastq.needs_alignment: assert fastq == rec1 _assert_alignment_for_fastq_record(read=fastq_record, results=result) else: assert len(alignments) == 0 assert fastq.name == "needs_alignment=False" assert fastq == rec2
def test_fails_consecutive_reads_with_the_same_name_and_number( fastq_record: FastqRecord, ref_fasta: Path) -> None: # run BWA with pytest.raises(Exception, match="Consecutive reads"): list(align(reads=[fastq_record, fastq_record], idxbase=ref_fasta))