18
|
1 #!/usr/bin/env python
|
|
2
|
|
3 ##@file
|
|
4 # Launch BlatProgramLauncher on several files in parallel on a cluster.
|
|
5
|
|
6
|
|
7 from pyRepet.launcher.AbstractClusterLauncher import *
|
|
8 from commons.launcher.BlatProgramLauncher import BlatProgramLauncher
|
|
9 from commons.core.coord.AlignUtils import AlignUtils
|
|
10 from commons.tools import srptBlasterMatcher
|
|
11
|
|
12
|
|
13 class BlatClusterLauncher( AbstractClusterLauncher ):
|
|
14 """
|
|
15 Launch Blat on several files in parallel on a cluster.
|
|
16 """
|
|
17
|
|
18 def __init__( self ):
|
|
19 """
|
|
20 Constructor.
|
|
21 """
|
|
22 AbstractClusterLauncher.__init__( self )
|
|
23 AbstractClusterLauncher.setAcronym( self, "Blat" )
|
|
24
|
|
25 self._cmdLineSpecificOptions = "s:p:A"
|
|
26
|
|
27 self._exeWrapper = "BlatProgramLauncher.py"
|
|
28 self._prgLauncher = BlatProgramLauncher()
|
|
29 self._prgLauncher.setInputFile( GENERIC_IN_FILE )
|
|
30 self._prgLauncher.setClean()
|
|
31 self._prgLauncher.setVerbosityLevel( 1 )
|
|
32 self._prgLauncher.setListFilesToKeep()
|
|
33 self._prgLauncher.setListFilesToRemove()
|
|
34
|
|
35
|
|
36 def getSpecificHelpAsString( self ):
|
|
37 """
|
|
38 Return the specific help as a string.
|
|
39 """
|
|
40 string = ""
|
|
41 string += "\nspecific options:"
|
|
42 string += "\n -s: name of the subject file (format='fasta')"
|
|
43 string += "\n -p: parameters for '%s'" % ( self._prgLauncher.getProgramName() )
|
|
44 string += "\n -Z: concatenate output files"
|
|
45 string += "\n -A: same sequences (all-by-all)"
|
|
46 return string
|
|
47
|
|
48
|
|
49 def getSubjectFile( self ):
|
|
50 return self._prgLauncher.getSubjectFile()
|
|
51
|
|
52
|
|
53 def getProgramParameters( self ):
|
|
54 return self._prgLauncher.getProgramParameters()
|
|
55
|
|
56
|
|
57 def processOutputFile( self, tmpFile, outFile ):
|
|
58 sortFile = "%s.sort" % ( tmpFile )
|
|
59 AlignUtils.sortAlignFile( tmpFile, sortFile )
|
|
60 if self._prgLauncher.getAllByAll():
|
|
61 srptBlasterMatcher.filterRedundantMatches( sortFile,
|
|
62 outFile )
|
|
63 os.remove( sortFile )
|
|
64 else:
|
|
65 os.rename( sortFile, outFile )
|
|
66
|
|
67 def setASpecificAttributeFromCmdLine( self, o, a="" ):
|
|
68 if o =="-s":
|
|
69 self._prgLauncher.setSubjectFile( a )
|
|
70
|
|
71 if __name__ == "__main__":
|
|
72 i = BlatClusterLauncher()
|
|
73 i.setAttributesFromCmdLine()
|
|
74 i.run()
|