Mercurial > repos > yufei-luo > s_mart
view commons/launcher/tests/Test_F_BlatProgramLauncher.py @ 19:9bcfa7936eec
Deleted selected files
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:23:29 -0400 |
parents | 94ab73e8a190 |
children |
line wrap: on
line source
import os import unittest from commons.core.utils.FileUtils import FileUtils from devTools.tests.MockFastaSupctg30 import MockFastaSupctg30 from devTools.tests.MockMiniProtBankSupctg30 import MockMiniProtBankSupctg30 from commons.launcher.tests.MockDataBankForBlat import MockDataBankForBlat from commons.launcher.tests.MockESTBankForBlat import MockESTBankForBlat from commons.launcher.tests.MockOutputForBlat import MockOutputForBlat from commons.launcher.BlatProgramLauncher import BlatProgramLauncher class Test_F_BlatProgramLauncher(unittest.TestCase): def test_run_empty_result(self): queryFileName = "smallProtBank_supctg30.fa" mock = MockMiniProtBankSupctg30() mock.write(queryFileName) subjectFileName = "subjectBank.fa" mock = MockFastaSupctg30() mock.write(subjectFileName) expOutputFileName = "expBlatOutput.blast.align" self.writeEmptyExpOutputFile(expOutputFileName) obsOutputFileName = "obsBlatOutput.blast.align" bpl = BlatProgramLauncher() bpl.setInputFile(queryFileName) bpl.setSubjectFile(subjectFileName) bpl.setOutputFile(obsOutputFileName) bpl.setProgramParameters("") bpl.run() blastFileName = queryFileName + ".blast" self.assertTrue(os.path.exists(obsOutputFileName)) self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName)) os.remove(queryFileName) os.remove(subjectFileName) os.remove(blastFileName) os.remove(expOutputFileName) os.remove(obsOutputFileName) def test_as_script_empty_result(self): queryFileName = "smallProtBank_supctg30.fa" mock = MockMiniProtBankSupctg30() mock.write(queryFileName) subjectFileName = "subjectBank.fa" mock = MockFastaSupctg30() mock.write(subjectFileName) expOutputFileName = "expBlatOutput.blast.align" self.writeEmptyExpOutputFile(expOutputFileName) obsOutputFileName = "obsBlatOutput.blast.align" cmd2Launch = "python ../BlatProgramLauncher.py -s " + subjectFileName + " -i " + queryFileName + " -p '' -o " + obsOutputFileName os.system(cmd2Launch) blastFileName = queryFileName + ".blast" self.assertTrue(os.path.exists(obsOutputFileName)) self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName)) os.remove(queryFileName) os.remove(subjectFileName) os.remove(blastFileName) os.remove(expOutputFileName) os.remove(obsOutputFileName) def test_run(self): queryFileName = "smallESTBank.fa" mock = MockESTBankForBlat() mock.write(queryFileName) subjectFileName = "subjectBank.fa" mock = MockDataBankForBlat() mock.write(subjectFileName) expOutputFileName = "expBlatOutput.blast.align" mock = MockOutputForBlat() mock.write(expOutputFileName) obsOutputFileName = "obsBlatOutput.blast.align" bpl = BlatProgramLauncher() bpl.setInputFile(queryFileName) bpl.setSubjectFile(subjectFileName) bpl.setOutputFile(obsOutputFileName) bpl.setProgramParameters("") bpl.run() blastFileName = queryFileName + ".blast" self.assertTrue(os.path.exists(obsOutputFileName)) self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName)) os.remove(queryFileName) os.remove(subjectFileName) os.remove(blastFileName) os.remove(expOutputFileName) os.remove(obsOutputFileName) def test_as_script(self): queryFileName = "smallESTBank.fa" mock = MockESTBankForBlat() mock.write(queryFileName) subjectFileName = "subjectBank.fa" mock = MockDataBankForBlat() mock.write(subjectFileName) expOutputFileName = "expBlatOutput.blast.align" mock = MockOutputForBlat() mock.write(expOutputFileName) obsOutputFileName = "obsBlatOutput.blast.align" cmd2Launch = "python ../BlatProgramLauncher.py -s " + subjectFileName + " -i " + queryFileName + " -p '' -o " + obsOutputFileName os.system(cmd2Launch) blastFileName = queryFileName + ".blast" self.assertTrue(os.path.exists(obsOutputFileName)) self.assertTrue(FileUtils.are2FilesIdentical(expOutputFileName, obsOutputFileName)) os.remove(queryFileName) os.remove(subjectFileName) os.remove(blastFileName) os.remove(expOutputFileName) os.remove(obsOutputFileName) def writeEmptyExpOutputFile(self, outputFileName): f = open(outputFileName, "w") f.write("") f.close() if __name__ == "__main__": unittest.main()