Back to index

python-biopython  1.60
Public Member Functions | Public Attributes
test_Phd.PhdTestOne Class Reference

List of all members.

Public Member Functions

def setUp
def tearDown
def test_check_SeqIO
def test_check_record_parser

Public Attributes

 handle

Detailed Description

Definition at line 10 of file test_Phd.py.


Member Function Documentation

def test_Phd.PhdTestOne.setUp (   self)

Definition at line 11 of file test_Phd.py.

00011 
00012     def setUp(self):
00013         self.handle = open("Phd/phd1")

Definition at line 14 of file test_Phd.py.

00014 
00015     def tearDown(self):
00016         self.handle.close()

Test phd1 file in detail.

Definition at line 59 of file test_Phd.py.

00059 
00060     def test_check_record_parser(self):
00061         """Test phd1 file in detail."""
00062         records = Phd.parse(self.handle)
00063         # Record 1
00064         record = records.next()
00065         self.assertEqual(record.file_name, "34_222_(80-A03-19).b.ab1")
00066         self.assertEqual(record.comments['abi_thumbprint'], 0)
00067         self.assertEqual(record.comments['call_method'], "phred")
00068         self.assertEqual(record.comments['chem'], "term")
00069         self.assertEqual(record.comments['chromat_file'], "34_222_(80-A03-19).b.ab1")
00070         self.assertEqual(record.comments['dye'], "big")
00071         self.assertEqual(record.comments['phred_version'], "0.020425.c")
00072         self.assertEqual(record.comments['quality_levels'], 99)
00073         self.assertEqual(record.comments['time'], "Fri Feb 13 09:16:11 2004")
00074         self.assertEqual(record.comments['trace_array_max_index'], 10867)
00075         self.assertEqual(record.comments['trace_array_min_index'], 0)
00076         self.assertAlmostEqual(record.comments['trace_peak_area_ratio'], 0.1467)
00077         self.assertEqual(record.comments['trim'][0], 3)
00078         self.assertEqual(record.comments['trim'][1], 391)
00079         self.assertAlmostEqual(record.comments['trim'][2], 0.05)
00080         center = len(record.sites)//2
00081         self.assertEqual(record.sites[0], ('c', '9', '6'))
00082         self.assertEqual(record.sites[1], ('t', '9', '18'))
00083         self.assertEqual(record.sites[2], ('c', '10', '26'))
00084         self.assertEqual(record.sites[3], ('c', '19', '38'))
00085         self.assertEqual(record.sites[4], ('g', '22', '49'))
00086         self.assertEqual(record.sites[5], ('t', '37', '65'))
00087         self.assertEqual(record.sites[6], ('c', '28', '76'))
00088         self.assertEqual(record.sites[7], ('g', '28', '87'))
00089         self.assertEqual(record.sites[8], ('g', '24', '100'))
00090         self.assertEqual(record.sites[9], ('a', '22', '108'))
00091         self.assertEqual(record.sites[center-5], ('c', '11', '5259'))
00092         self.assertEqual(record.sites[center-4], ('c', '11', '5273'))
00093         self.assertEqual(record.sites[center-3], ('t', '9', '5286'))
00094         self.assertEqual(record.sites[center-2], ('g', '10', '5300'))
00095         self.assertEqual(record.sites[center-1], ('a', '10', '5316'))
00096         self.assertEqual(record.sites[center], ('t', '8', '5323'))
00097         self.assertEqual(record.sites[center+1], ('c', '8', '5343'))
00098         self.assertEqual(record.sites[center+2], ('g', '8', '5352'))
00099         self.assertEqual(record.sites[center+3], ('c', '8', '5366'))
00100         self.assertEqual(record.sites[center+4], ('c', '8', '5378'))
00101         self.assertEqual(record.sites[-10], ('c', '8', '10756'))
00102         self.assertEqual(record.sites[-9], ('c', '8', '10764'))
00103         self.assertEqual(record.sites[-8], ('a', '8', '10769'))
00104         self.assertEqual(record.sites[-7], ('a', '8', '10788'))
00105         self.assertEqual(record.sites[-6], ('a', '8', '10803'))
00106         self.assertEqual(record.sites[-5], ('g', '10', '10816'))
00107         self.assertEqual(record.sites[-4], ('c', '11', '10826'))
00108         self.assertEqual(record.sites[-3], ('g', '11', '10840'))
00109         self.assertEqual(record.sites[-2], ('t', '11', '10855'))
00110         self.assertEqual(record.sites[-1], ('g', '11', '10864'))
00111         self.assertEqual(record.seq.tostring()[:10], 'ctccgtcgga')
00112         self.assertEqual(record.seq.tostring()[-10:], 'ccaaagcgtg')
00113         self.assertEqual(record.seq_trimmed.tostring()[:10], 'cgtcggaaca')
00114         self.assertEqual(record.seq_trimmed.tostring()[-10:], 'tatttcggag')
00115         # Record 2
00116         record = records.next()
00117         center = len(record.sites)//2
00118         self.assertEqual(record.file_name, "425_103_(81-A03-19).g.ab1")
00119         self.assertEqual(record.comments['abi_thumbprint'], 0)
00120         self.assertEqual(record.comments['call_method'], 'phred')
00121         self.assertEqual(record.comments['chem'], 'term')
00122         self.assertEqual(record.comments['chromat_file'], '425_103_(81-A03-19).g.ab1')
00123         self.assertEqual(record.comments['dye'], 'big')
00124         self.assertEqual(record.comments['phred_version'], '0.020425.c')
00125         self.assertEqual(record.comments['quality_levels'], 99)
00126         self.assertEqual(record.comments['time'], 'Tue Feb 17 10:31:15 2004')
00127         self.assertEqual(record.comments['trace_array_max_index'], 10606)
00128         self.assertEqual(record.comments['trace_array_min_index'], 0)
00129         self.assertAlmostEqual(record.comments['trace_peak_area_ratio'], 0.0226)
00130         self.assertEqual(record.comments['trim'][0], 10)
00131         self.assertEqual(record.comments['trim'][1], 432)
00132         self.assertAlmostEqual(record.comments['trim'][2], 0.05)
00133         self.assertEqual(record.sites[0], ('c', '14', '3'))
00134         self.assertEqual(record.sites[1], ('g', '17', '11'))
00135         self.assertEqual(record.sites[2], ('g', '22', '23'))
00136         self.assertEqual(record.sites[3], ('g', '10', '35'))
00137         self.assertEqual(record.sites[4], ('a', '10', '53'))
00138         self.assertEqual(record.sites[5], ('t', '10', '68'))
00139         self.assertEqual(record.sites[6], ('c', '15', '75'))
00140         self.assertEqual(record.sites[7], ('c', '8', '85'))
00141         self.assertEqual(record.sites[8], ('c', '8', '94'))
00142         self.assertEqual(record.sites[9], ('a', '9', '115'))
00143         self.assertEqual(record.sites[center-5], ('c', '33', '5140'))
00144         self.assertEqual(record.sites[center-4], ('c', '28', '5156'))
00145         self.assertEqual(record.sites[center-3], ('g', '25', '5167'))
00146         self.assertEqual(record.sites[center-2], ('c', '28', '5178'))
00147         self.assertEqual(record.sites[center-1], ('c', '18', '5193'))
00148         self.assertEqual(record.sites[center], ('a', '16', '5204'))
00149         self.assertEqual(record.sites[center+1], ('a', '15', '5213'))
00150         self.assertEqual(record.sites[center+2], ('a', '10', '5230'))
00151         self.assertEqual(record.sites[center+3], ('a', '10', '5242'))
00152         self.assertEqual(record.sites[center+4], ('t', '8', '5249'))
00153         self.assertEqual(record.sites[-10], ('c', '8', '10489'))
00154         self.assertEqual(record.sites[-9], ('c', '8', '10503'))
00155         self.assertEqual(record.sites[-8], ('c', '8', '10514'))
00156         self.assertEqual(record.sites[-7], ('a', '8', '10516'))
00157         self.assertEqual(record.sites[-6], ('g', '8', '10530'))
00158         self.assertEqual(record.sites[-5], ('c', '8', '10550'))
00159         self.assertEqual(record.sites[-4], ('c', '10', '10566'))
00160         self.assertEqual(record.sites[-3], ('a', '8', '10574'))
00161         self.assertEqual(record.sites[-2], ('a', '7', '10584'))
00162         self.assertEqual(record.sites[-1], ('g', '7', '10599'))
00163         self.assertEqual(record.seq.tostring()[:10], 'cgggatccca')
00164         self.assertEqual(record.seq.tostring()[-10:], 'cccagccaag')
00165         self.assertEqual(record.seq_trimmed.tostring()[:10], 'cctgatccga')
00166         self.assertEqual(record.seq_trimmed.tostring()[-10:], 'ggggccgcca')
00167         # Record 3
00168         record = records.next()
00169         center = len(record.sites)//2
00170         self.assertEqual(record.file_name, '425_7_(71-A03-19).b.ab1')
00171         self.assertEqual(record.comments['abi_thumbprint'], 0)
00172         self.assertEqual(record.comments['call_method'], 'phred')
00173         self.assertEqual(record.comments['chem'], 'term')
00174         self.assertEqual(record.comments['chromat_file'], '425_7_(71-A03-19).b.ab1')
00175         self.assertEqual(record.comments['dye'], 'big')
00176         self.assertEqual(record.comments['phred_version'], '0.020425.c')
00177         self.assertEqual(record.comments['quality_levels'], 99)
00178         self.assertEqual(record.comments['time'], 'Thu Jan 29 11:46:14 2004')
00179         self.assertEqual(record.comments['trace_array_max_index'], 9513)
00180         self.assertEqual(record.comments['trace_array_min_index'], 0)
00181         self.assertAlmostEqual(record.comments['trace_peak_area_ratio'], 100.0)
00182         self.assertEqual(record.comments['trim'][0], -1)
00183         self.assertEqual(record.comments['trim'][1], -1)
00184         self.assertEqual(record.comments['trim'][2], 0.05)
00185         self.assertEqual(record.sites[0], ('a', '10', '7'))
00186         self.assertEqual(record.sites[1], ('c', '10', '13'))
00187         self.assertEqual(record.sites[2], ('a', '10', '21'))
00188         self.assertEqual(record.sites[3], ('t', '10', '28'))
00189         self.assertEqual(record.sites[4], ('a', '8', '33'))
00190         self.assertEqual(record.sites[5], ('a', '8', '40'))
00191         self.assertEqual(record.sites[6], ('a', '6', '50'))
00192         self.assertEqual(record.sites[7], ('t', '6', '53'))
00193         self.assertEqual(record.sites[8], ('c', '6', '66'))
00194         self.assertEqual(record.sites[9], ('a', '6', '68'))
00195         self.assertEqual(record.sites[center-5], ('a', '6', '4728'))
00196         self.assertEqual(record.sites[center-4], ('t', '10', '4737'))
00197         self.assertEqual(record.sites[center-3], ('a', '10', '4746'))
00198         self.assertEqual(record.sites[center-2], ('a', '8', '4756'))
00199         self.assertEqual(record.sites[center-1], ('t', '8', '4759'))
00200         self.assertEqual(record.sites[center], ('t', '8', '4768'))
00201         self.assertEqual(record.sites[center+1], ('a', '8', '4775'))
00202         self.assertEqual(record.sites[center+2], ('g', '10', '4783'))
00203         self.assertEqual(record.sites[center+3], ('t', '8', '4788'))
00204         self.assertEqual(record.sites[center+4], ('g', '8', '4794'))
00205         self.assertEqual(record.sites[-10], ('a', '8', '9445'))
00206         self.assertEqual(record.sites[-9], ('t', '6', '9453'))
00207         self.assertEqual(record.sites[-8], ('c', '6', '9462'))
00208         self.assertEqual(record.sites[-7], ('t', '6', '9465'))
00209         self.assertEqual(record.sites[-6], ('g', '6', '9478'))
00210         self.assertEqual(record.sites[-5], ('c', '6', '9483'))
00211         self.assertEqual(record.sites[-4], ('t', '6', '9485'))
00212         self.assertEqual(record.sites[-3], ('t', '8', '9495'))
00213         self.assertEqual(record.sites[-2], ('t', '3', '9504'))
00214         self.assertEqual(record.sites[-1], ('n', '0', '9511'))
00215         self.assertEqual(record.seq.tostring()[:10], 'acataaatca')
00216         self.assertEqual(record.seq.tostring()[-10:], 'atctgctttn')
00217         # Make sure that no further records are found
00218         self.assertRaises(StopIteration, records.next)

Test phd1 using parser via SeqIO.

Definition at line 17 of file test_Phd.py.

00017 
00018     def test_check_SeqIO(self):
00019         """Test phd1 using parser via SeqIO."""
00020         records = SeqIO.parse(self.handle, "phd")
00021         #Contig 1
00022         record = records.next()
00023         self.assertEqual(record.id, "34_222_(80-A03-19).b.ab1")
00024         self.assertEqual(record.name, "34_222_(80-A03-19).b.ab1")
00025         self.assertEqual(record.description, "34_222_(80-A03-19).b.ab1")
00026         self.assertTrue(record.seq.startswith("ctccgtcggaacatcatcggatcctatcaca"))
00027         self.assertTrue(record.seq.endswith("ctctcctctccctccctccgactccaaagcgtg"))
00028         self.assertEqual(record.letter_annotations["phred_quality"][:10],
00029                          [9, 9, 10, 19, 22, 37, 28, 28, 24, 22])
00030         self.assertEqual(record[:10].format("fasta"),
00031                          ">34_222_(80-A03-19).b.ab1\nctccgtcgga\n")
00032         self.assertEqual(record[:10].format("qual"),
00033                          ">34_222_(80-A03-19).b.ab1\n"
00034                          "9 9 10 19 22 37 28 28 24 22\n")
00035         self.assertEqual(record[:10].format("fastq"),
00036                          "@34_222_(80-A03-19).b.ab1\n"
00037                          "ctccgtcgga\n"
00038                          "+\n"
00039                          "**+47F==97\n")
00040         self.assertEqual(record[:10].format("fastq-illumina"),
00041                          "@34_222_(80-A03-19).b.ab1\n"
00042                          "ctccgtcgga\n"
00043                          "+\n"
00044                          "IIJSVe\\\\XV\n")
00045         #Contig 2
00046         record = records.next()
00047         self.assertEqual(record.id, "425_103_(81-A03-19).g.ab1")
00048         self.assertEqual(record.name, "425_103_(81-A03-19).g.ab1")
00049         self.assertEqual(record.letter_annotations["phred_quality"][:10],
00050                          [14, 17, 22, 10, 10, 10, 15, 8, 8, 9])
00051         #Contig 3
00052         record = records.next()
00053         self.assertEqual(record.id, '425_7_(71-A03-19).b.ab1')
00054         self.assertEqual(record.name, '425_7_(71-A03-19).b.ab1')
00055         self.assertEqual(record.letter_annotations["phred_quality"][:10],
00056                          [10, 10, 10, 10, 8, 8, 6, 6, 6, 6])
00057         # Make sure that no further records are found
00058         self.assertRaises(StopIteration, records.next)


Member Data Documentation

Definition at line 12 of file test_Phd.py.


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