Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/hmmer/tests/TestLaunchPreProcessHmmpfamPostProcessNotInParallel.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 os | |
| 2 import unittest | |
| 3 from commons.pyRepetUnit.hmmer.LaunchPreProcessHmmpfamPostProcessNotInParallel import * | |
| 4 from pyRepet.util.file.FileUtils import * | |
| 5 import ConfigParser | |
| 6 | |
| 7 if (not os.environ.has_key("REPET_PATH")): | |
| 8 print "*** Error: no environment variable REPET_PATH" | |
| 9 exit =1 | |
| 10 | |
| 11 if (not os.environ.has_key("PYTHONPATH")): | |
| 12 print "*** Error: no environment variable PYTHONPATH" | |
| 13 exit =1 | |
| 14 | |
| 15 if (exit == 1): | |
| 16 sys.exit(1) | |
| 17 | |
| 18 CONFIG_FILE = "datas/configTestLaunchPreProcessHmmpfamPostProcessNotInParallel.cfg" | |
| 19 CURRENT_DIR = os.getcwd() | |
| 20 | |
| 21 class TestLaunchPreProcessHmmpfamPostProcessNotInParallel(unittest.TestCase): | |
| 22 | |
| 23 def setUp( self ): | |
| 24 os.chdir(CURRENT_DIR) | |
| 25 self._LaunchPreProcessHmmpfamPostProcess = LaunchPreProcessHmmpfamPostProcessNotInParallel() | |
| 26 self._configFile = CONFIG_FILE | |
| 27 config = ConfigParser.ConfigParser() | |
| 28 config.readfp(open(self._configFile)) | |
| 29 self._InputFile = config.get("hmmer_config", "input_file") | |
| 30 self._OutputFile = config.get("hmmer_config", "output_file") | |
| 31 self.fileUtils = FileUtils() | |
| 32 | |
| 33 def testRun(self): | |
| 34 #Normal launch | |
| 35 self._LaunchPreProcessHmmpfamPostProcess.setInputFile( self._InputFile ) | |
| 36 self._LaunchPreProcessHmmpfamPostProcess.setOutputFile( self._OutputFile ) | |
| 37 self._LaunchPreProcessHmmpfamPostProcess.setConfigFile( self._configFile ) | |
| 38 self._LaunchPreProcessHmmpfamPostProcess.run() | |
| 39 self.assertTrue(self.fileUtils.isRessourceExists(self._OutputFile)) | |
| 40 self.assertFalse(self.fileUtils.isFileEmpty(self._OutputFile)) | |
| 41 os.system("rm " + self._OutputFile) | |
| 42 #without config file | |
| 43 configFile = "/workspace/repet_pipe/commons/pyRepetUnit/hmmer/datas/configdummy.cfg" | |
| 44 self._LaunchPreProcessHmmpfamPostProcess.setConfigFile( configFile ) | |
| 45 self._LaunchPreProcessHmmpfamPostProcess.run() | |
| 46 self.assertFalse(self.fileUtils.isRessourceExists(self._OutputFile)) | |
| 47 #without input file | |
| 48 InputFile = "" | |
| 49 self._LaunchPreProcessHmmpfamPostProcess.setInputFile( InputFile ) | |
| 50 self._LaunchPreProcessHmmpfamPostProcess.run() | |
| 51 self.assertFalse(self.fileUtils.isRessourceExists(self._OutputFile)) | |
| 52 #without output file | |
| 53 self._LaunchPreProcessHmmpfamPostProcess.setConfigFile( self._configFile ) | |
| 54 self._LaunchPreProcessHmmpfamPostProcess.setInputFile( self._InputFile ) | |
| 55 OutputFile = "" | |
| 56 self._LaunchPreProcessHmmpfamPostProcess.setOutputFile( OutputFile ) | |
| 57 self._LaunchPreProcessHmmpfamPostProcess.run() | |
| 58 self.assertFalse(self.fileUtils.isRessourceExists(self._OutputFile)) | |
| 59 | |
| 60 | |
| 61 | |
| 62 if __name__ == "__main__": | |
| 63 unittest.main() |
