18
|
1 import os
|
|
2 import unittest
|
|
3 from pyRepet.launcher.programLauncher import *
|
|
4 from pyRepet.util.file.FileUtils import *
|
|
5 import commons.pyRepetUnit.fastaTranslation.allFrames.TranslateInAllFramesAndReplaceStopByX
|
|
6 import commons.pyRepetUnit.hmmer.hmmOutput.HmmpfamOutputProcessing
|
|
7 import ConfigParser
|
|
8
|
|
9 class LaunchPreProcessHmmpfamPostProcessNotInParallel:
|
|
10
|
|
11 def __init__( self ):
|
|
12
|
|
13 #for global analysis
|
|
14 self._configFile = ""
|
|
15 self._inputFile = ""
|
|
16 self._outputFile = ""
|
|
17 self.fileUtils = FileUtils()
|
|
18 self._programLauncherInstance = programLauncher()
|
|
19 #specific to PreProcess
|
|
20 self.bioseq = Bioseq()
|
|
21 self.preProcess = commons.pyRepetUnit.fastaTranslation.allFrames.TranslateInAllFramesAndReplaceStopByX.TranslateInAllFramesAndReplaceStopByX()
|
|
22 self._outputFilePreprocess = ""
|
|
23 #specific to PostProcess
|
|
24 self.hmmpfamOutputProcess = commons.pyRepetUnit.hmmer.hmmOutput.HmmpfamOutputProcessing.HmmpfamOutputProcessing()
|
|
25
|
|
26 def _cleanTemporaryFiles(self, outputFilePreProcess, outputFileHmmpfam):
|
|
27 os.remove( outputFilePreProcess )
|
|
28 os.remove( outputFileHmmpfam )
|
|
29
|
|
30 def _launchPostProcess(self, outputFileHmmpfam):
|
|
31 return self.hmmpfamOutputProcess.readHmmOutputsAndWriteAlignFile(outputFileHmmpfam, self._outputFile)
|
|
32
|
|
33
|
|
34 def _launchHmmpfam(self, outputFilePreprocess):
|
|
35 config = ConfigParser.ConfigParser()
|
|
36 config.readfp(open(self._configFile))
|
|
37 self._programLauncherInstance.reset(outputFilePreprocess)
|
|
38 outputFileHmmpfam = outputFilePreprocess + ".hmmpfamOut"
|
|
39 self._programLauncherInstance.setOutputFileName(outputFileHmmpfam)
|
|
40 self._programLauncherInstance.launchHmmpfam(evalFilter=config.get("profil_search", "Evalue"), inputFormat=config.get("profil_search", "InputFormat"), profilDatabank=config.get("profil_search", "ProfilDatabank"))
|
|
41 return outputFileHmmpfam
|
|
42
|
|
43
|
|
44 def _launchHmmpfamPreProcess(self):
|
|
45 self.preProcess.setInputFile(self._inputFile)
|
|
46 outputFilePreprocess = self._inputFile + ".translated"
|
|
47 self.preProcess.setOutputFile(outputFilePreprocess)
|
|
48 self.preProcess.run()
|
|
49 return outputFilePreprocess
|
|
50
|
|
51 def setInputFile( self, input ):
|
|
52 self._inputFile = input;
|
|
53
|
|
54 def setOutputFile( self, output ):
|
|
55 self._outputFile = output;
|
|
56
|
|
57 def setConfigFile ( self, configFile ):
|
|
58 self._configFile = configFile
|
|
59
|
|
60 def checkInputFile(self):
|
|
61 return self._checkFileExitsAndNotEmpty( self._inputFile )
|
|
62
|
|
63 def checkConfigFile(self):
|
|
64 return self._checkFileExitsAndNotEmpty( self._configFile )
|
|
65
|
|
66 def _checkFileExitsAndNotEmpty(self, fileName):
|
|
67 fileUtils = FileUtils()
|
|
68 if fileUtils.isRessourceExists(fileName) and not fileUtils.isFileEmpty(fileName):
|
|
69 return 1
|
|
70 return 0
|
|
71
|
|
72 def run(self):
|
|
73
|
|
74 if not self.checkInputFile():
|
|
75 print "Warning : there is no input file : " + self._inputFile + "\n"
|
|
76 return 0
|
|
77 if not self.checkConfigFile():
|
|
78 print "Warning : there is no config file : " + self._configFile + "\n"
|
|
79 return 0
|
|
80 outputFilePreProcess = self._launchHmmpfamPreProcess()
|
|
81 outputFileHmmpfam = self._launchHmmpfam(outputFilePreProcess)
|
|
82 self._launchPostProcess(outputFileHmmpfam)
|
|
83 self._cleanTemporaryFiles(outputFilePreProcess, outputFileHmmpfam)
|
|
84
|
|
85
|
|
86 if __name__ == "__main__":
|
|
87 main()
|
|
88
|
|
89
|
|
90
|
|
91
|
|
92
|
|
93
|
|
94
|
|
95
|
|
96
|
|
97
|
|
98
|
|
99
|
|
100
|
|
101
|
|
102
|
|
103
|
|
104
|
|
105
|
|
106
|
|
107
|
|
108
|
|
109
|
|
110
|
|
111
|
|
112
|
|
113
|
|
114
|
|
115
|
|
116
|
|
117
|
|
118
|
|
119
|
|
120
|
|
121 if __name__ == "__main__":
|
|
122 main() |