Mercurial > repos > yufei-luo > s_mart
comparison commons/pyRepetUnit/hmmer/tests/TestProgramLauncher.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 pyRepet.launcher.programLauncher 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/config.cfg" | |
| 19 CURRENT_DIR = os.getcwd() | |
| 20 | |
| 21 class TestProgramLauncher(unittest.TestCase): | |
| 22 | |
| 23 def setUp(self): | |
| 24 os.chdir(CURRENT_DIR) | |
| 25 self._programLauncherInstance = programLauncher() | |
| 26 self._configFile = CONFIG_FILE | |
| 27 config = ConfigParser.ConfigParser() | |
| 28 config.readfp( open(self._configFile) ) | |
| 29 self._configFile = CONFIG_FILE | |
| 30 config = ConfigParser.ConfigParser() | |
| 31 config.readfp(open(self._configFile)) | |
| 32 self._inputFile = config.get("hmmer_config", "input_file") | |
| 33 self._outputFile = config.get("hmmer_config", "output_file") | |
| 34 self.fileUtils = FileUtils() | |
| 35 | |
| 36 def testLaunchHmmpfam(self): | |
| 37 config = ConfigParser.ConfigParser() | |
| 38 config.readfp( open(self._configFile) ) | |
| 39 self._programLauncherInstance.reset( self._inputFile ) | |
| 40 self._programLauncherInstance.setOutputFileName( self._outputFile ) | |
| 41 self._programLauncherInstance.launchHmmpfam( evalFilter=config.get("profil_search","Evalue"), | |
| 42 inputFormat=config.get("profil_search","InputFormat"), | |
| 43 profilDatabank=config.get("profil_search","ProfilDatabank")) | |
| 44 self.assertTrue(self.fileUtils.isRessourceExists(self._outputFile)) | |
| 45 self.assertFalse(self.fileUtils.isFileEmpty(self._outputFile)) | |
| 46 os.system( "rm " + self._outputFile) | |
| 47 self._inputFile = "repet_pipe/pyRepet/launcher/datas/hmmpfam/test_input_aa2.fa" | |
| 48 self._programLauncherInstance.reset( self._inputFile ) | |
| 49 self._programLauncherInstance.launchHmmpfam( evalFilter=config.get("profil_search","Evalue"), | |
| 50 inputFormat=config.get("profil_search","InputFormat"), | |
| 51 profilDatabank=config.get("profil_search","ProfilDatabank")) | |
| 52 self.assertFalse(self.fileUtils.isRessourceExists(self._outputFile)) | |
| 53 #No output file | |
| 54 self._outputFile = "" | |
| 55 self._inputFile = "repet_pipe/pyRepet/launcher/datas/hmmpfam/test_input_aa.fa" | |
| 56 self._programLauncherInstance.reset( self._inputFile ) | |
| 57 self._programLauncherInstance.setOutputFileName( self._outputFile ) | |
| 58 self._programLauncherInstance.launchHmmpfam( evalFilter=config.get("profil_search","Evalue"), | |
| 59 inputFormat=config.get("profil_search","InputFormat"), | |
| 60 profilDatabank=config.get("profil_search","ProfilDatabank")) | |
| 61 self.assertFalse(self.fileUtils.isRessourceExists(self._outputFile)) | |
| 62 os.chdir(CURRENT_DIR) | |
| 63 | |
| 64 if __name__ == "__main__": | |
| 65 unittest.main() |
