Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/convCoord/test/TestConvCoordWithOverlapps.py @ 31:0ab839023fe4
Uploaded
author | m-zytnicki |
---|---|
date | Tue, 30 Apr 2013 14:33:21 -0400 |
parents | 94ab73e8a190 |
children |
comparison
equal
deleted
inserted
replaced
30:5677346472b5 | 31:0ab839023fe4 |
---|---|
1 import unittest | |
2 import os | |
3 import time | |
4 from commons.core.utils.FileUtils import FileUtils | |
5 from commons.core.sql.DbMySql import DbMySql | |
6 | |
7 | |
8 class Test_ConvCoordWithOverlaps( unittest.TestCase ): | |
9 pass | |
10 | |
11 # def setUp(self): | |
12 # self._uniqId = "%s_%s" % ( time.strftime("%Y%m%d%H%M%S") , os.getpid() ) | |
13 # self._mapFile = "map_file.map" | |
14 # _MockMapFile( self._mapFile ) | |
15 # self._resultFile = "dummyObsFile_%s" % ( self._uniqId ) | |
16 # self._refFileToCompare = "dummyExpFile_%s" % ( self._uniqId ) | |
17 # self._configFileName = "dummyConfigFile_%s" % ( self._uniqId ) | |
18 # configF = open(self._configFileName, "w" ) | |
19 # configF.write( "[repet_env]\n" ) | |
20 # configF.write( "repet_host: %s\n" % ( os.environ["REPET_HOST"] ) ) | |
21 # configF.write( "repet_user: %s\n" % ( os.environ["REPET_USER"] ) ) | |
22 # configF.write( "repet_pw: %s\n" % ( os.environ["REPET_PW"] ) ) | |
23 # configF.write( "repet_db: %s\n" % ( os.environ["REPET_DB"] ) ) | |
24 # configF.write( "repet_port: %s\n" % ( os.environ["REPET_PORT"] ) ) | |
25 # configF.close() | |
26 # self._db = DbMySql( cfgFileName = self._configFileName ) | |
27 # | |
28 # def tearDown(self): | |
29 # os.remove( self._mapFile ) | |
30 # os.remove( self._resultFile ) | |
31 # os.remove( self._refFileToCompare ) | |
32 # self._db.close() | |
33 # self._uniqId = None | |
34 # | |
35 # | |
36 # def test_run_TwoHitsOverlapOnFirstAndSecondChunks( self ): | |
37 # file2Process = "two_hits_overlap_on_first_and_second_chunk.align" | |
38 # linesToProcess = [ "chunk1" + "\t" + "95535" + "\t" + "95570" + "\t" + "sbj2" + "\t" + "125423" + "\t" + "125467" + "\t" + "7e-15" + "\t" + "82" + "\t" + "97.78" + "\n", | |
39 # "chunk2" + "\t" + "5544" + "\t" + "5575" + "\t" + "sbj2" + "\t" + "125457" + "\t" + "133465" + "\t" + "2e-38" + "\t" + "83" + "\t" + "65" + "\n" ] | |
40 # _MockAlignFile( file2Process, linesToProcess ) | |
41 # | |
42 # convCoord = ConvCoord( file2Process, "q", self._mapFile, self._resultFile, "", 0, self._db ) | |
43 # convCoord.run() | |
44 # | |
45 # refLine = ["dmel_chr4" + "\t" + "95535" + "\t" + "95575" + "\t" + "sbj2" + "\t" + "125423" + "\t" + "133465" + "\t" + "2e-38" + "\t" + "83" + "\t" + "97.78" + "\n"] | |
46 # _MockAlignFile( self._refFileToCompare, refLine ) | |
47 # | |
48 # self.assertTrue( FileUtils.are2FilesIdentical( self._refFileToCompare, self._resultFile ) ) | |
49 # os.remove( file2Process ) | |
50 # | |
51 # | |
52 # def test_run_ThreeHitsOverlapOnFirstAndSecondChunks( self ): | |
53 # file2Process = "three_hits_overlap_on_first_and_second_chunk.align" | |
54 # linesToProcess = [ "chunk1" + "\t" + "95535" + "\t" + "95570" + "\t" + "sbj2" + "\t" + "125423" + "\t" + "125467" + "\t" + "7e-15" + "\t" + "82" + "\t" + "97.78" + "\n", | |
55 # "chunk2" + "\t" + "5544" + "\t" + "5575" + "\t" + "sbj2" + "\t" + "125457" + "\t" + "133465" + "\t" + "2e-38" + "\t" + "83" + "\t" + "65" + "\n" | |
56 # "chunk2" + "\t" + "5540" + "\t" + "5573" + "\t" + "sbj2" + "\t" + "125454" + "\t" +"125750" + "\t" + "8e-58" + "\t" + "224" + "\t" + "86.43" + "\n" ] | |
57 # _MockAlignFile( file2Process, linesToProcess ) | |
58 # | |
59 # convCoord = ConvCoord( file2Process, "q", self._mapFile, self._resultFile, "", 0, self._db ) | |
60 # convCoord.run() | |
61 # | |
62 # refLine = ["dmel_chr4" + "\t" + "95535" + "\t" + "95575" + "\t" + "sbj2" + "\t" + "125423" + "\t" + "133465" + "\t" + "8e-58" + "\t" + "224" + "\t" + "97.78" + "\n"] | |
63 # _MockAlignFile( self._refFileToCompare, refLine ) | |
64 # | |
65 # self.assertTrue( FileUtils.are2FilesIdentical( self._refFileToCompare, self._resultFile ) ) | |
66 # os.remove( file2Process ) | |
67 # | |
68 # | |
69 # def test_run_HitsOnDifferentStrandsAndDifferentSubjects( self ): | |
70 # file2Process = "hits_on_different_strands_and_different_subjects.align" | |
71 # linesToProcess = [ "chunk1" + "\t" + "95535" + "\t" + "95570" + "\t" + "sbj2" + "\t" + "125423" + "\t" + "125467" + "\t" + "7e-15" + "\t" + "82" + "\t" + "97.78" + "\n", | |
72 # "chunk2" + "\t" + "5575" + "\t" + "5544" + "\t" + "sbj2" + "\t" + "125457" + "\t" + "133465" + "\t" + "2e-38" + "\t" + "83" + "\t" + "65" + "\n", | |
73 # "chunk2" + "\t" + "5540" + "\t" + "5573" + "\t" + "sbj3" + "\t" + "125454" + "\t" +"125750" + "\t" + "8e-58" + "\t" + "224" + "\t" + "86.43" + "\n" ] | |
74 # _MockAlignFile( file2Process, linesToProcess ) | |
75 # | |
76 # convCoord = ConvCoord( file2Process, "q", self._mapFile, self._resultFile, "", 0, self._db ) | |
77 # convCoord.run() | |
78 # | |
79 # refLine = ["dmel_chr4" + "\t" + "95535" + "\t" + "95570" + "\t" + "sbj2" + "\t" + "125423" + "\t" + "125467" + "\t" + "7e-15" + "\t" + "82" + "\t" + "97.78" + "\n", | |
80 # "dmel_chr4" + "\t" + "95544" + "\t" + "95575" + "\t" + "sbj2" + "\t" + "133465" + "\t" + "125457" + "\t" + "2e-38" + "\t" + "83" + "\t" + "65" + "\n", | |
81 # "dmel_chr4" + "\t" + "95540" + "\t" + "95573" + "\t" + "sbj3" + "\t" + "125454" + "\t" +"125750" + "\t" + "8e-58" + "\t" + "224" + "\t" + "86.43" + "\n" ] | |
82 # _MockAlignFile( self._refFileToCompare, refLine ) | |
83 # | |
84 # self.assertTrue( FileUtils.are2FilesIdentical( self._refFileToCompare, self._resultFile ) ) | |
85 # os.remove( file2Process ) | |
86 # | |
87 # | |
88 # def test_run_TwoHitsOnChunksOnlyAndOnOverlap( self ): | |
89 # file2Process = "two_hits_on_chunks_only_and_on_overlap.align" | |
90 # linesToProcess = [ "chunk2" + "\t" + "85000" + "\t" + "95000" + "\t" + "sbj2" + "\t" + "125457" + "\t" + "133465" + "\t" + "2e-38" + "\t" + "83" + "\t" + "65" + "\n", | |
91 # "chunk3" + "\t" + "1000" + "\t" +" 5000" + "\t" + "sbj2" + "\t" + "125454" + "\t" + "125750" + "\t" + "8e-58" + "\t" + "224" + "\t" + "86.43" + "\n" ] | |
92 # _MockAlignFile( file2Process, linesToProcess ) | |
93 # | |
94 # convCoord = ConvCoord( file2Process, "q", self._mapFile, self._resultFile, "", 0, self._db ) | |
95 # convCoord.run() | |
96 # | |
97 # refLine = ["dmel_chr4" + "\t" + "175000"+ "\t" + "185000"+ "\t" + "sbj2"+ "\t" + "125454"+ "\t" + "133465"+ "\t" + "8e-58"+ "\t" + "224"+ "\t" + "86.43"+"\n"] | |
98 # _MockAlignFile( self._refFileToCompare, refLine ) | |
99 # | |
100 # self.assertTrue( FileUtils.are2FilesIdentical( self._refFileToCompare, self._resultFile ) ) | |
101 # os.remove( file2Process ) | |
102 # | |
103 # | |
104 # def test_run_TwoHitsOnChunks_And_OnOverlap_OnReverseStrand_ForSubject( self ): | |
105 # file2Process = "two_hits_on_chunks_and_on_overlap_on_reverse_strand_for_subject.align" | |
106 # linesToProcess = [ "chunk2" + "\t" + "85000" + "\t" + "95000" + "\t" + "sbj2" + "\t" + "133465" + "\t" + "125457" + "\t" + "2e-38" + "\t" + "83" + "\t" + "65" + "\n", | |
107 # "chunk3" + "\t" + "1000" + "\t" + "5000" + "\t" + "sbj2" + "\t" + "125750" + "\t" + "125454" + "\t" + "8e-58" + "\t" + "224" + "\t" + "86.43" + "\n" ] | |
108 # _MockAlignFile( file2Process, linesToProcess ) | |
109 # | |
110 # convCoord = ConvCoord( file2Process, "q", self._mapFile, self._resultFile, "", 0, self._db ) | |
111 # convCoord.run() | |
112 # | |
113 # refLine = ["dmel_chr4" + "\t" + "175000"+ "\t" + "185000" + "\t" + "sbj2"+ "\t" + "133465" + "\t" + "125454" + "\t" + "8e-58"+ "\t" + "224"+ "\t" + "86.43"+"\n"] | |
114 # _MockAlignFile( self._refFileToCompare, refLine ) | |
115 # | |
116 # self.assertTrue( FileUtils.are2FilesIdentical( self._refFileToCompare, self._resultFile ) ) | |
117 # os.remove( file2Process ) | |
118 # | |
119 # | |
120 # def test_run_ThreeHitsAllByAllWithTwoHitsWithinAChunkOverlap( self ): | |
121 # file2Process = "dummyAlignFile_%s" % ( self._uniqId ) | |
122 # linesToProcess = [ "chunk1"+"\t"+"192"+"\t"+"197"+"\t"+"chunk2"+"\t"+"2"+"\t"+"7"+"\t"+"8e-58"+"\t"+"11"+"\t"+"97.8"+"\n", | |
123 # "chunk1"+"\t"+"192"+"\t"+"197"+"\t"+"chunk2"+"\t"+"51"+"\t"+"56"+"\t"+"8e-58"+"\t"+"11"+"\t"+"97.8"+"\n", | |
124 # "chunk2"+"\t"+"2"+"\t"+"7"+"\t"+"chunk2"+"\t"+"51"+"\t"+"56"+"\t"+"8e-58"+"\t"+"11"+"\t"+"97.8"+"\n" ] | |
125 # _MockAlignFile( file2Process, linesToProcess ) | |
126 # | |
127 # mapFileName = "dummyMapFile_%s" % ( self._uniqId ) | |
128 # mapF = open( mapFileName, "w" ) | |
129 # mapF.write( "chunk1\tdmel_chr4\t1\t200\n" ) | |
130 # mapF.write( "chunk2\tdmel_chr4\t191\t390\n" ) | |
131 # mapF.close() | |
132 # | |
133 # convCoord = ConvCoord( file2Process, "qs", mapFileName, self._resultFile, "", 0, self._db ) | |
134 # convCoord.run() | |
135 # | |
136 # refLine = [ "dmel_chr4"+"\t"+"192"+"\t"+"197"+"\t"+"dmel_chr4"+"\t"+"241"+"\t"+"246"+"\t"+"8e-58"+"\t"+"11"+"\t"+"97.8"+"\n" ] | |
137 # _MockAlignFile( self._refFileToCompare, refLine ) | |
138 # | |
139 # self.assertTrue( FileUtils.are2FilesIdentical( self._refFileToCompare, self._resultFile ) ) | |
140 # os.remove( file2Process ) | |
141 # os.remove( mapFileName ) | |
142 # | |
143 # | |
144 #class _MockAlignFile: | |
145 # | |
146 # def __init__(self, fileName, lines): | |
147 # alignF = open(fileName, "w"); | |
148 # for line in lines: | |
149 # alignF.write(line) | |
150 # alignF.close | |
151 # | |
152 # | |
153 #class _MockMapFile: | |
154 # | |
155 # def __init__ (self, fileName): | |
156 # mapF = open(fileName, "w") | |
157 # line1 = "chunk1" + '\t' + "dmel_chr4" + '\t' + "1" + '\t'+ "100000" + "\n" | |
158 # line2 = "chunk2" + '\t' + "dmel_chr4" + '\t' + "90001" + '\t'+ "190000" + "\n" | |
159 # line3 = "chunk3" + '\t' + "dmel_chr4" + '\t' + "180001" + '\t' + "280000" + "\n" | |
160 # mapF.write(line1) | |
161 # mapF.write(line2) | |
162 # mapF.write(line3) | |
163 # mapF.close | |
164 | |
165 | |
166 test_suite = unittest.TestSuite() | |
167 test_suite.addTest( unittest.makeSuite( Test_ConvCoordWithOverlaps ) ) | |
168 if __name__ == "__main__": | |
169 unittest.TextTestRunner(verbosity=2).run( test_suite ) |