annotate commons/tools/tests/Test_GetMultAlignAndPhylogenyPerTErefSeq.py @ 18:94ab73e8a190

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