Mercurial > repos > yufei-luo > s_mart
diff commons/tools/tests/Test_GetMultAlignAndPhylogenyPerTErefSeq.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commons/tools/tests/Test_GetMultAlignAndPhylogenyPerTErefSeq.py Mon Apr 29 03:20:15 2013 -0400 @@ -0,0 +1,54 @@ +import unittest +import os +import time +from commons.core.sql.DbMySql import DbMySql +from commons.tools.GetMultAlignAndPhylogenyPerTErefSeq import GetMultAlignAndPhylogenyPerTErefSeq +from commons.core.utils.FileUtils import FileUtils + + +class Test_GetMultAlignAndPhylogenyPerTErefSeq( unittest.TestCase ): + + def setUp( self ): + self.fileUtils = FileUtils() + self._inputTEFile = "dummyTE" + self._iGMAP = GetMultAlignAndPhylogenyPerTErefSeq() + self._uniqId = "%s_%s" % ( time.strftime("%Y_%m_%d_%H_%M_%S") , os.getpid() ) + self._configFileName = "dummyConfig_%s" % self._uniqId + configFile = open( self._configFileName, "w" ) + configFile.write("[repet_env]\n") + configFile.write( "repet_host: %s\n" % ( os.environ["REPET_HOST"] ) ) + configFile.write( "repet_user: %s\n" % ( os.environ["REPET_USER"] ) ) + configFile.write( "repet_pw: %s\n" % ( os.environ["REPET_PW"] ) ) + configFile.write( "repet_db: %s\n" % ( os.environ["REPET_DB"] ) ) + configFile.write( "repet_port: %s\n" % ( os.environ["REPET_PORT"] ) ) + configFile.close() + + def tearDown( self ): + os.remove( self._configFileName ) + os.remove( self._inputTEFile ) + + + def test_getNamesOfTErefSeq_fromFile_ok(self): + expTEList =["DHX-incomp-chim_Blc1_DmelChr4-L-B1-Map1_reversed", + "DT-comp_DmelChr4-B-P0.0-Map3", "RLX-incomp_Blc3_DmelChr4-L-B3-Map1"] + self._iGMAP._TErefseq = os.path.abspath(self._inputTEFile) + self.writeInputTEFile() + obsTEList = self._iGMAP.getNamesOfTErefSeq() + self.assertEqual(obsTEList, expTEList) + + def test_getNamesOfTErefSeq_from_empty_file(self): + expTEList =[] + self._iGMAP._TErefseq = os.path.abspath(self._inputTEFile) + with open(self._inputTEFile,"w") as TEFile: + TEFile.write("") + obsTEList = self._iGMAP.getNamesOfTErefSeq() + self.assertEqual(obsTEList, expTEList) + + def writeInputTEFile(self): + with open(self._inputTEFile,"w") as TEFile: + TEFile.write("""DHX-incomp-chim_Blc1_DmelChr4-L-B1-Map1_reversed +RLX-incomp_Blc3_DmelChr4-L-B3-Map1\t reverse +DT-comp_DmelChr4-B-P0.0-Map3\t""") + +if __name__ == "__main__": + unittest.main() \ No newline at end of file