Mercurial > repos > yufei-luo > s_mart
comparison commons/tools/tests/Test_GetMultAlignAndPhylogenyPerTErefSeq.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
17:b0e8584489e6 | 18:94ab73e8a190 |
---|---|
1 import unittest | |
2 import os | |
3 import time | |
4 from commons.core.sql.DbMySql import DbMySql | |
5 from commons.tools.GetMultAlignAndPhylogenyPerTErefSeq import GetMultAlignAndPhylogenyPerTErefSeq | |
6 from commons.core.utils.FileUtils import FileUtils | |
7 | |
8 | |
9 class Test_GetMultAlignAndPhylogenyPerTErefSeq( unittest.TestCase ): | |
10 | |
11 def setUp( self ): | |
12 self.fileUtils = FileUtils() | |
13 self._inputTEFile = "dummyTE" | |
14 self._iGMAP = GetMultAlignAndPhylogenyPerTErefSeq() | |
15 self._uniqId = "%s_%s" % ( time.strftime("%Y_%m_%d_%H_%M_%S") , os.getpid() ) | |
16 self._configFileName = "dummyConfig_%s" % self._uniqId | |
17 configFile = open( self._configFileName, "w" ) | |
18 configFile.write("[repet_env]\n") | |
19 configFile.write( "repet_host: %s\n" % ( os.environ["REPET_HOST"] ) ) | |
20 configFile.write( "repet_user: %s\n" % ( os.environ["REPET_USER"] ) ) | |
21 configFile.write( "repet_pw: %s\n" % ( os.environ["REPET_PW"] ) ) | |
22 configFile.write( "repet_db: %s\n" % ( os.environ["REPET_DB"] ) ) | |
23 configFile.write( "repet_port: %s\n" % ( os.environ["REPET_PORT"] ) ) | |
24 configFile.close() | |
25 | |
26 def tearDown( self ): | |
27 os.remove( self._configFileName ) | |
28 os.remove( self._inputTEFile ) | |
29 | |
30 | |
31 def test_getNamesOfTErefSeq_fromFile_ok(self): | |
32 expTEList =["DHX-incomp-chim_Blc1_DmelChr4-L-B1-Map1_reversed", | |
33 "DT-comp_DmelChr4-B-P0.0-Map3", "RLX-incomp_Blc3_DmelChr4-L-B3-Map1"] | |
34 self._iGMAP._TErefseq = os.path.abspath(self._inputTEFile) | |
35 self.writeInputTEFile() | |
36 obsTEList = self._iGMAP.getNamesOfTErefSeq() | |
37 self.assertEqual(obsTEList, expTEList) | |
38 | |
39 def test_getNamesOfTErefSeq_from_empty_file(self): | |
40 expTEList =[] | |
41 self._iGMAP._TErefseq = os.path.abspath(self._inputTEFile) | |
42 with open(self._inputTEFile,"w") as TEFile: | |
43 TEFile.write("") | |
44 obsTEList = self._iGMAP.getNamesOfTErefSeq() | |
45 self.assertEqual(obsTEList, expTEList) | |
46 | |
47 def writeInputTEFile(self): | |
48 with open(self._inputTEFile,"w") as TEFile: | |
49 TEFile.write("""DHX-incomp-chim_Blc1_DmelChr4-L-B1-Map1_reversed | |
50 RLX-incomp_Blc3_DmelChr4-L-B3-Map1\t reverse | |
51 DT-comp_DmelChr4-B-P0.0-Map3\t""") | |
52 | |
53 if __name__ == "__main__": | |
54 unittest.main() |