Back to index

python-biopython  1.60
Public Member Functions
test_SeqIO_QualityIO.MappingTests Class Reference

List of all members.

Public Member Functions

def test_solexa_quality_from_phred
def test_phred_quality_from_solexa
def test_sanger_to_solexa
def test_solexa_to_sanger
def test_sanger_to_illumina
def test_illumina_to_sanger

Detailed Description

Definition at line 598 of file test_SeqIO_QualityIO.py.


Member Function Documentation

Mapping check for FASTQ Illumina (0 to 62) to Sanger (0 to 62)

Definition at line 699 of file test_SeqIO_QualityIO.py.

00699 
00700     def test_illumina_to_sanger(self):
00701         """Mapping check for FASTQ Illumina (0 to 62) to Sanger (0 to 62)"""
00702         seq = "N"*63
00703         qual = "".join(chr(64+q) for q in range(0,63))
00704         expected_phred = range(63)
00705         in_handle = StringIO("@Test\n%s\n+\n%s" % (seq,qual))
00706         out_handle = StringIO("")
00707         SeqIO.write(SeqIO.parse(in_handle, "fastq-illumina"),
00708                     out_handle, "fastq-sanger")
00709         out_handle.seek(0)
00710         record = SeqIO.read(out_handle, "fastq-sanger")
00711         self.assertEqual(str(record.seq), seq)
00712         self.assertEqual(record.letter_annotations["phred_quality"],
00713                          expected_phred)
00714 

Mapping check for function phred_quality_from_solexa

Definition at line 614 of file test_SeqIO_QualityIO.py.

00614 
00615     def test_phred_quality_from_solexa(self):
00616         """Mapping check for function phred_quality_from_solexa"""
00617         self.assertEqual(1, round(QualityIO.phred_quality_from_solexa(-5)))
00618         self.assertEqual(1, round(QualityIO.phred_quality_from_solexa(-4)))
00619         self.assertEqual(2, round(QualityIO.phred_quality_from_solexa(-3)))
00620         self.assertEqual(2, round(QualityIO.phred_quality_from_solexa(-2)))
00621         self.assertEqual(3, round(QualityIO.phred_quality_from_solexa(-1)))
00622         self.assertEqual(3, round(QualityIO.phred_quality_from_solexa(0)))
00623         self.assertEqual(4, round(QualityIO.phred_quality_from_solexa(1)))
00624         self.assertEqual(4, round(QualityIO.phred_quality_from_solexa(2)))
00625         self.assertEqual(5, round(QualityIO.phred_quality_from_solexa(3)))
00626         self.assertEqual(5, round(QualityIO.phred_quality_from_solexa(4)))
00627         self.assertEqual(6, round(QualityIO.phred_quality_from_solexa(5)))
00628         self.assertEqual(7, round(QualityIO.phred_quality_from_solexa(6)))
00629         self.assertEqual(8, round(QualityIO.phred_quality_from_solexa(7)))
00630         self.assertEqual(9, round(QualityIO.phred_quality_from_solexa(8)))
00631         self.assertEqual(10, round(QualityIO.phred_quality_from_solexa(9)))
00632         for i in range(10,100):
00633             self.assertEqual(i, round(QualityIO.phred_quality_from_solexa(i)))

Mapping check for FASTQ Sanger (0 to 93) to Illumina (0 to 62)

Definition at line 680 of file test_SeqIO_QualityIO.py.

00680 
00681     def test_sanger_to_illumina(self):
00682         """Mapping check for FASTQ Sanger (0 to 93) to Illumina (0 to 62)"""
00683         seq = "N"*94
00684         qual = "".join(chr(33+q) for q in range(0,94))
00685         expected_phred = [min(62,q) for q in range(0,94)]
00686         in_handle = StringIO("@Test\n%s\n+\n%s" % (seq,qual))
00687         out_handle = StringIO("")
00688         #Want to ignore the data loss warning
00689         #(on Python 2.6 we could check for it!)
00690         warnings.simplefilter('ignore', BiopythonWarning)
00691         SeqIO.write(SeqIO.parse(in_handle, "fastq-sanger"),
00692                     out_handle, "fastq-illumina")
00693         warnings.filters.pop()
00694         out_handle.seek(0)
00695         record = SeqIO.read(out_handle, "fastq-illumina")
00696         self.assertEqual(str(record.seq), seq)
00697         self.assertEqual(record.letter_annotations["phred_quality"],
00698                          expected_phred)

Mapping check for FASTQ Sanger (0 to 93) to Solexa (-5 to 62)

Definition at line 634 of file test_SeqIO_QualityIO.py.

00634 
00635     def test_sanger_to_solexa(self):
00636         """Mapping check for FASTQ Sanger (0 to 93) to Solexa (-5 to 62)"""
00637         #The point of this test is the writing code doesn't actually use the
00638         #solexa_quality_from_phred function directly. For speed it uses a
00639         #cached dictionary of the mappings.
00640         seq = "N"*94
00641         qual = "".join(chr(33+q) for q in range(0,94))
00642         expected_sol = [min(62,int(round(QualityIO.solexa_quality_from_phred(q)))) \
00643                         for q in range(0,94)]
00644         in_handle = StringIO("@Test\n%s\n+\n%s" % (seq,qual))
00645         out_handle = StringIO("")
00646         #Want to ignore the data loss warning
00647         #(on Python 2.6 we could check for it!)
00648         warnings.simplefilter('ignore', BiopythonWarning)
00649         SeqIO.write(SeqIO.parse(in_handle, "fastq-sanger"),
00650                     out_handle, "fastq-solexa")
00651         warnings.filters.pop()
00652         out_handle.seek(0)
00653         record = SeqIO.read(out_handle, "fastq-solexa")
00654         self.assertEqual(str(record.seq), seq)
00655         self.assertEqual(record.letter_annotations["solexa_quality"],
00656                          expected_sol)

Mapping check for function solexa_quality_from_phred

Definition at line 599 of file test_SeqIO_QualityIO.py.

00599 
00600     def test_solexa_quality_from_phred(self):
00601         """Mapping check for function solexa_quality_from_phred"""
00602         self.assertEqual(-5, round(QualityIO.solexa_quality_from_phred(0)))
00603         self.assertEqual(-5, round(QualityIO.solexa_quality_from_phred(1)))
00604         self.assertEqual(-2, round(QualityIO.solexa_quality_from_phred(2)))
00605         self.assertEqual(0, round(QualityIO.solexa_quality_from_phred(3)))
00606         self.assertEqual(2, round(QualityIO.solexa_quality_from_phred(4)))
00607         self.assertEqual(3, round(QualityIO.solexa_quality_from_phred(5)))
00608         self.assertEqual(5, round(QualityIO.solexa_quality_from_phred(6)))
00609         self.assertEqual(6, round(QualityIO.solexa_quality_from_phred(7)))
00610         self.assertEqual(7, round(QualityIO.solexa_quality_from_phred(8)))
00611         self.assertEqual(8, round(QualityIO.solexa_quality_from_phred(9)))
00612         for i in range(10,100):
00613             self.assertEqual(i, round(QualityIO.solexa_quality_from_phred(i)))
        
Mapping check for FASTQ Solexa (-5 to 62) to Sanger (0 to 62)

Definition at line 657 of file test_SeqIO_QualityIO.py.

00657 
00658     def test_solexa_to_sanger(self):
00659         """Mapping check for FASTQ Solexa (-5 to 62) to Sanger (0 to 62)"""
00660         #The point of this test is the writing code doesn't actually use the
00661         #solexa_quality_from_phred function directly. For speed it uses a
00662         #cached dictionary of the mappings.
00663         seq = "N"*68
00664         qual = "".join(chr(64+q) for q in range(-5,63))
00665         expected_phred = [round(QualityIO.phred_quality_from_solexa(q)) \
00666                           for q in range(-5,63)]
00667         in_handle = StringIO("@Test\n%s\n+\n%s" % (seq,qual))
00668         out_handle = StringIO("")
00669         #Want to ignore the data loss warning
00670         #(on Python 2.6 we could check for it!)
00671         warnings.simplefilter('ignore', BiopythonWarning)
00672         SeqIO.write(SeqIO.parse(in_handle, "fastq-solexa"),
00673                     out_handle, "fastq-sanger")
00674         warnings.filters.pop()
00675         out_handle.seek(0)
00676         record = SeqIO.read(out_handle, "fastq-sanger")
00677         self.assertEqual(str(record.seq), seq)
00678         self.assertEqual(record.letter_annotations["phred_quality"],
00679                          expected_phred)


The documentation for this class was generated from the following file: