comparison commons/core/parsing/test/Test_pilerTAToGrouperMap.py @ 6:769e306b7933

Change the repository level.
author yufei-luo
date Fri, 18 Jan 2013 04:54:14 -0500
parents
children
comparison
equal deleted inserted replaced
5:ea3082881bf8 6:769e306b7933
1 import unittest
2 import os
3 from commons.core.parsing.PilerTAToGrouperMap import PilerTAToGrouperMap
4 from commons.core.utils.FileUtils import FileUtils
5
6 class Test_pilerTAToGrouperMap(unittest.TestCase):
7
8 def setUp(self):
9 self._inputGffFileName = "input.gff"
10 self._inputPYRFileName = "input_pyr.gff"
11 self._inputMOTIFFileName = "input_motif.gff"
12
13 self._obsOutFileName = "output.info"
14 self._obsGrouperFileName = "input_motif.gff.grp"
15 self._obsGrpMapFileName = "input_motif.gff.grp.map"
16
17 self._expOutFileName = "exp_output.info"
18 self._expGrouperFileName = "exp_motif.gff.grp"
19 self._expGrpMapFileName = "exp_motif.gff.grp.map"
20
21 def tearDown(self):
22 os.remove(self._inputGffFileName)
23 os.remove(self._inputPYRFileName)
24 os.remove(self._inputMOTIFFileName)
25
26 os.remove(self._obsOutFileName)
27 os.remove(self._obsGrouperFileName)
28 os.remove(self._obsGrpMapFileName)
29
30 os.remove(self._expOutFileName)
31 os.remove(self._expGrouperFileName)
32 os.remove(self._expGrpMapFileName)
33
34 def testRun(self):
35 self._writePilerTAFilePYR(self._inputPYRFileName)
36 self._writePilerTAFileMOTIF(self._inputMOTIFFileName)
37 self._writePilerTAGff(self._inputGffFileName)
38
39 self._writeExpOutputFile(self._expOutFileName)
40 self._writeExpGrouperFile(self._expGrouperFileName)
41 self._writeExpGrouperMapFile(self._expGrpMapFileName)
42
43 iPilerTAToGrouperMap = PilerTAToGrouperMap(self._inputGffFileName, self._inputPYRFileName,self._inputMOTIFFileName, self._obsOutFileName)
44 iPilerTAToGrouperMap.run()
45
46 self.assertTrue(FileUtils.are2FilesIdentical(self._expOutFileName, self._obsOutFileName))
47 self.assertTrue(FileUtils.are2FilesIdentical(self._expGrouperFileName, self._obsGrouperFileName))
48 self.assertTrue(FileUtils.are2FilesIdentical(self._expGrpMapFileName, self._obsGrpMapFileName))
49
50
51 def _writePilerTAGff(self, fileName):
52 f = open(fileName, "w")
53 f.write("chunk21\tpiler\thit\t155146\t156020\t0\t+\t.\tTarget chunk21 150519 151392 ; Pile 510 ; Pyramid 0\n")
54 f.write("chunk21\tpiler\thit\t154790\t156023\t0\t+\t.\tTarget chunk21 150519 151751 ; Pile 510 ; Pyramid 0\n")
55 f.write("chunk21\tpiler\thit\t154078\t156023\t0\t+\t.\tTarget chunk21 150519 152463 ; Pile 510 ; Pyramid 0\n")
56 f.write("chunk21\tpiler\thit\t154256\t156023\t0\t+\t.\tTarget chunk21 150519 152285 ; Pile 510 ; Pyramid 0\n")
57 f.write("chunk21\tpiler\thit\t154434\t156023\t0\t+\t.\tTarget chunk21 150519 152107 ; Pile 510 ; Pyramid 0\n")
58 f.close()
59
60 def _writePilerTAFilePYR(self, fileName):
61 f = open(fileName, "w")
62 f.write("chunk21\tpiler\tpyramid\t150519\t156023\t0\t.\t.\tPyramidIndex 0\n")
63 f.write("chunk21\tpiler\tpyramid\t150519\t156023\t0\t.\t.\tPyramidIndex 1\n")
64 f.write("chunk21\tpiler\tpyramid\t165574\t174424\t0\t.\t.\tPyramidIndex 2\n")
65 f.write("chunk21\tpiler\tpyramid\t166301\t174424\t0\t.\t.\tPyramidIndex 3\n")
66 f.write("chunk21\tpiler\tpyramid\t168967\t174424\t0\t.\t.\tPyramidIndex 4\n")
67 f.write("chunk21\tpiler\tpyramid\t170215\t174424\t0\t.\t.\tPyramidIndex 5\n")
68 f.close()
69
70 def _writePilerTAFileMOTIF(self, fileName):
71 f = open(fileName, "w")
72 f.write("chunk21\tpiler\ttandemmotif\t155843\t156020\t0\t.\t.\tTarget chunk21 151215 151392 ; Pyramid 0\n")
73 f.write("chunk21\tpiler\ttandemmotif\t151215\t151392\t0\t.\t.\tTarget chunk21 155843 156020 ; Pyramid 0\n")
74 f.write("chunk21\tpiler\ttandemmotif\t151574\t151751\t0\t.\t.\tTarget chunk21 155843 156020 ; Pyramid 0\n")
75 f.write("chunk21\tpiler\ttandemmotif\t152286\t152463\t0\t.\t.\tTarget chunk21 155843 156020 ; Pyramid 0\n")
76 f.write("chunk21\tpiler\ttandemmotif\t152108\t152285\t0\t.\t.\tTarget chunk21 155843 156020 ; Pyramid 0\n")
77 f.close()
78
79 def _writeExpOutputFile(self, fileName):
80 f = open(fileName, "w")
81 f.write("Pile 510\tPyramid 0\n")
82 f.write("\tPyramid 1\n")
83 f.write("\tPyramid 2\n")
84 f.write("\tPyramid 3\n")
85 f.write("\tPyramid 4\n")
86 f.write("\tPyramid 5\n")
87 f.close()
88
89 def _writeExpGrouperFile(self, fileName):
90 f = open(fileName, "w")
91 f.write("MbS1Gr0Cl510\tchunk21\tpiler\ttandemmotif\t155843\t156020\t0\t.\t.\tTarget chunk21 151215 151392 \tPile 510\tPyramid 0\n")
92 f.write("MbS2Gr0Cl510\tchunk21\tpiler\ttandemmotif\t151215\t151392\t0\t.\t.\tTarget chunk21 155843 156020 \tPile 510\tPyramid 0\n")
93 f.write("MbS3Gr0Cl510\tchunk21\tpiler\ttandemmotif\t151574\t151751\t0\t.\t.\tTarget chunk21 155843 156020 \tPile 510\tPyramid 0\n")
94 f.write("MbS4Gr0Cl510\tchunk21\tpiler\ttandemmotif\t152286\t152463\t0\t.\t.\tTarget chunk21 155843 156020 \tPile 510\tPyramid 0\n")
95 f.write("MbS5Gr0Cl510\tchunk21\tpiler\ttandemmotif\t152108\t152285\t0\t.\t.\tTarget chunk21 155843 156020 \tPile 510\tPyramid 0\n")
96 f.close()
97
98 def _writeExpGrouperMapFile(self, fileName):
99 f = open(fileName, "w")
100 f.write("MbS1Gr0Cl510\tchunk21\t155843\t156020\n")
101 f.write("MbS2Gr0Cl510\tchunk21\t151215\t151392\n")
102 f.write("MbS3Gr0Cl510\tchunk21\t151574\t151751\n")
103 f.write("MbS4Gr0Cl510\tchunk21\t152286\t152463\n")
104 f.write("MbS5Gr0Cl510\tchunk21\t152108\t152285\n")
105 f.close()
106
107 if __name__ == "__main__":
108 unittest.main()