def test_parse(self): for label, seq, qual in parse_fastq(self.FASTQ_EXAMPLE, phred_offset=64): self.assertTrue(label in DATA) self.assertEqual(seq, DATA[label]["seq"]) self.assertTrue((qual == DATA[label]["qual"]).all()) # Make sure that enforce_qual_range set to False allows qual scores # to fall outside the typically acceptable range of 0-62 for label, seq, qual in parse_fastq(self.FASTQ_EXAMPLE_2, phred_offset=33, enforce_qual_range=False): self.assertTrue(label in DATA_2) self.assertEqual(seq, DATA_2[label]["seq"]) self.assertTrue((qual == DATA_2[label]["qual"]).all()) # This should raise a FastqParseError since the qual scores are # intended to be interpreted with an offset of 64, and using 33 will # make the qual score fall outside the acceptable range of 0-62. with self.assertRaises(FastqParseError): list(parse_fastq(self.FASTQ_EXAMPLE, phred_offset=33))
def test_invalid_phred_offset(self): with self.assertRaises(ValueError): list(parse_fastq(self.FASTQ_EXAMPLE, phred_offset=42))
def test_parse_error(self): with self.assertRaises(FastqParseError): list(parse_fastq(self.FASTQ_EXAMPLE_2, strict=True)) with self.assertRaises(FastqParseError): list(parse_fastq(self.FASTQ_EXAMPLE_3, phred_offset=64))