diff commons/launcher/YassClusterLauncher.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/launcher/YassClusterLauncher.py	Mon Apr 29 03:20:15 2013 -0400
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+
+##@file
+# Launch YassProgramLauncher on several files in parallel on a cluster.
+
+
+from pyRepet.launcher.AbstractClusterLauncher import *
+from commons.core.coord.AlignUtils import AlignUtils
+from commons.launcher.YassProgramLauncher import YassProgramLauncher
+from commons.tools import srptBlasterMatcher
+
+
+class YassClusterLauncher( AbstractClusterLauncher ):
+    """
+    Launch Yass on several files in parallel on a cluster.
+    """
+    
+    def __init__( self ):
+        """
+        Constructor.
+        """
+        AbstractClusterLauncher.__init__( self )
+        AbstractClusterLauncher.setAcronym( self, "Yass" )
+        
+        self._cmdLineSpecificOptions = "s:p:A"
+        
+        self._exeWrapper = "YassProgramLauncher.py"
+        self._prgLauncher = None
+        self._prgLauncher = self.getProgramLauncherInstance()
+        
+        
+    def getSpecificHelpAsString( self ):
+        """
+        Return the specific help as a string.
+        """
+        string = ""
+        string += "\nspecific options:"
+        string += "\n     -s: name of the subject file (format='fasta')"
+        string += "\n     -p: parameters for 'yass'"
+        string += "\n     -Z: concatenate output files"
+        string += "\n     -A: same sequences (all-by-all)"
+        return string
+    
+    
+    def getSubjectFile( self ):
+        return self._prgLauncher.getSubjectFile()
+    
+    
+    def getProgramParameters( self ):
+        return self._prgLauncher.getProgramParameters()
+    
+    
+    def getProgramLauncherInstance( self ):
+        if self._prgLauncher == None:
+            self._prgLauncher = YassProgramLauncher()
+            self._prgLauncher.setInputFile( GENERIC_IN_FILE )
+            self._prgLauncher.setClean()
+            self._prgLauncher.setVerbosityLevel( 1 )
+            self._prgLauncher.setListFilesToKeep()
+            self._prgLauncher.setListFilesToRemove()
+        return self._prgLauncher
+    
+    
+    def processOutputFile( self, tmpFile, outFile ):
+        sortFile = "%s.sort" % ( tmpFile )
+        AlignUtils.sortAlignFile( tmpFile, sortFile )
+        if self._prgLauncher.getAllByAll():
+            srptBlasterMatcher.filterRedundantMatches( sortFile,
+                                                                  outFile )
+            os.remove( sortFile )
+        else:
+            os.rename( sortFile, outFile )
+            
+            
+if __name__ == "__main__":
+    i = YassClusterLauncher()
+    i.setAttributesFromCmdLine()
+    i.run()