def test_RecordWithoutAssignedReadPair_CorrectFastqString(self): read = sam_record_from_sring("HISEQ2500-09:381:HJ2VGBCXX:2:1101:10005:7635 35 R00000042 1619836 99 151M = 1620303 618 CCAGAACAGGCGCGGGAAATGTGCGATACCGCGCGCAAACTGGGCAAGGTGCTGGCCTACGACTTTCACCATCGTTTTGCGCTCGATACGCAACAGCTGCGTGAACAGGTGACCAACGGCGTTTTGGGAGAGATTTACGTTACCACCGCCC DDDDDIIIIIIIIIIIIIIIHIHIIIIIIIIGIIIIIIIIGIIIHHIIIIGIIIIIIIIIIHIIIIIIIIIIIIIIIIIHIICGHIIIIHGIIIIHIIIGIGHIIIIIIIIIHHIIIIGIICHHHHIIHEHIIIIIIIIHHIIIIIHHIII PQ:i:205 SM:i:96 UQ:i:78 MQ:i:96 XQ:i:270 NM:i:2 RG:Z:824f45e8-37f3-4cb9-8a05-63f0b7c9b959") result = bam2fastq.to_fastq_string(read) expected = """@HISEQ2500-09:381:HJ2VGBCXX:2:1101:10005:7635 RG:824f45e8-37f3-4cb9-8a05-63f0b7c9b959 CCAGAACAGGCGCGGGAAATGTGCGATACCGCGCGCAAACTGGGCAAGGTGCTGGCCTACGACTTTCACCATCGTTTTGCGCTCGATACGCAACAGCTGCGTGAACAGGTGACCAACGGCGTTTTGGGAGAGATTTACGTTACCACCGCCC + DDDDDIIIIIIIIIIIIIIIHIHIIIIIIIIGIIIIIIIIGIIIHHIIIIGIIIIIIIIIIHIIIIIIIIIIIIIIIIIHIICGHIIIIHGIIIIHIIIGIGHIIIIIIIIIHHIIIIGIICHHHHIIHEHIIIIIIIIHHIIIIIHHIII""" self.assertEqual(result, expected)
def test_RecordWithoutRG_CorrectFastqString(self): read = sam_record_from_sring("HISEQ2500-09:381:HJ2VGBCXX:2:1101:10005:7635 99 R00000042 1619836 99 151M = 1620303 618 CCAGAACAGGCGCGGGAAATGTGCGATACCGCGCGCAAACTGGGCAAGGTGCTGGCCTACGACTTTCACCATCGTTTTGCGCTCGATACGCAACAGCTGCGTGAACAGGTGACCAACGGCGTTTTGGGAGAGATTTACGTTACCACCGCCC DDDDDIIIIIIIIIIIIIIIHIHIIIIIIIIGIIIIIIIIGIIIHHIIIIGIIIIIIIIIIHIIIIIIIIIIIIIIIIIHIICGHIIIIHGIIIIHIIIGIGHIIIIIIIIIHHIIIIGIICHHHHIIHEHIIIIIIIIHHIIIIIHHIII PQ:i:205 SM:i:96 UQ:i:78 MQ:i:96 XQ:i:270 NM:i:2") result = bam2fastq.to_fastq_string(read) expected = """@HISEQ2500-09:381:HJ2VGBCXX:2:1101:10005:7635/1 CCAGAACAGGCGCGGGAAATGTGCGATACCGCGCGCAAACTGGGCAAGGTGCTGGCCTACGACTTTCACCATCGTTTTGCGCTCGATACGCAACAGCTGCGTGAACAGGTGACCAACGGCGTTTTGGGAGAGATTTACGTTACCACCGCCC + DDDDDIIIIIIIIIIIIIIIHIHIIIIIIIIGIIIIIIIIGIIIHHIIIIGIIIIIIIIIIHIIIIIIIIIIIIIIIIIHIICGHIIIIHGIIIIHIIIGIGHIIIIIIIIIHHIIIIGIICHHHHIIHEHIIIIIIIIHHIIIIIHHIII""" self.assertEqual(result, expected)
def test_FullRecord_CorrectFastqString(self): read = sam_record_from_sring(reads_string.split('\n')[0].strip()) result = bam2fastq.to_fastq_string(read) expected = """@HISEQ2500-09:381:HJ2VGBCXX:2:1101:10005:7635/1 RG:824f45e8-37f3-4cb9-8a05-63f0b7c9b959 CCAGAACAGGCGCGGGAAATGTGCGATACCGCGCGCAAACTGGGCAAGGTGCTGGCCTACGACTTTCACCATCGTTTTGCGCTCGATACGCAACAGCTGCGTGAACAGGTGACCAACGGCGTTTTGGGAGAGATTTACGTTACCACCGCCC + DDDDDIIIIIIIIIIIIIIIHIHIIIIIIIIGIIIIIIIIGIIIHHIIIIGIIIIIIIIIIHIIIIIIIIIIIIIIIIIHIICGHIIIIHGIIIIHIIIGIGHIIIIIIIIIHHIIIIGIICHHHHIIHEHIIIIIIIIHHIIIIIHHIII""" self.assertEqual(result, expected)
def test_FullReverseRecord_CorrectFastqString(self): read = sam_record_from_sring(reads_string.split('\n')[4].strip()) result = bam2fastq.to_fastq_string(read) expected = """@HISEQ2500-09:381:HJ2VGBCXX:2:1101:10005:7635/2 RG:824f45e8-37f3-4cb9-8a05-63f0b7c9b959 ATTGATAAAGGCTTCCATGCTGCGCAAATGGCGGTTGTCGTCTGCCATTTCCCGTTGCATCAGCGTCATTAATTCACCGTTGTTATCGGTGTAGATATGTGCTGGAAACAGCGTCGCACCAGCTTTATCACCACAAAAGCTGACGTTCATA + DDDDDIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIFIIIIIHHHIIIIIIIIIIIGHIHIIIIIEHHHGHHIICHEHEH07F@HIHFC@CHDHHIHHIIHIIEHHIEECGHHE?GH@.@@FEA.7@FEH.""" self.assertEqual(result, expected)
def test_EmptyRecord_EmptyString(self): result = bam2fastq.to_fastq_string(pysam.AlignedSegment()) expected = "" self.assertEqual(result, expected)