annotate commons/launcher/YassClusterLauncher.py @ 18:94ab73e8a190

Uploaded
author m-zytnicki
date Mon, 29 Apr 2013 03:20:15 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
1 #!/usr/bin/env python
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
2
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
3 ##@file
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
4 # Launch YassProgramLauncher on several files in parallel on a cluster.
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
5
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
6
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
7 from pyRepet.launcher.AbstractClusterLauncher import *
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
8 from commons.core.coord.AlignUtils import AlignUtils
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
9 from commons.launcher.YassProgramLauncher import YassProgramLauncher
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
10 from commons.tools import srptBlasterMatcher
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13 class YassClusterLauncher( AbstractClusterLauncher ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15 Launch Yass on several files in parallel on a cluster.
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 def __init__( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20 Constructor.
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 AbstractClusterLauncher.__init__( self )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23 AbstractClusterLauncher.setAcronym( self, "Yass" )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 self._cmdLineSpecificOptions = "s:p:A"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 self._exeWrapper = "YassProgramLauncher.py"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 self._prgLauncher = None
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 self._prgLauncher = self.getProgramLauncherInstance()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 def getSpecificHelpAsString( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 Return the specific help as a string.
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 """
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36 string = ""
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 string += "\nspecific options:"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 string += "\n -s: name of the subject file (format='fasta')"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 string += "\n -p: parameters for 'yass'"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40 string += "\n -Z: concatenate output files"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 string += "\n -A: same sequences (all-by-all)"
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 return string
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 def getSubjectFile( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 return self._prgLauncher.getSubjectFile()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 def getProgramParameters( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 return self._prgLauncher.getProgramParameters()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 def getProgramLauncherInstance( self ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 if self._prgLauncher == None:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 self._prgLauncher = YassProgramLauncher()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 self._prgLauncher.setInputFile( GENERIC_IN_FILE )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 self._prgLauncher.setClean()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 self._prgLauncher.setVerbosityLevel( 1 )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59 self._prgLauncher.setListFilesToKeep()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 self._prgLauncher.setListFilesToRemove()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61 return self._prgLauncher
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 def processOutputFile( self, tmpFile, outFile ):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65 sortFile = "%s.sort" % ( tmpFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 AlignUtils.sortAlignFile( tmpFile, sortFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67 if self._prgLauncher.getAllByAll():
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68 srptBlasterMatcher.filterRedundantMatches( sortFile,
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69 outFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 os.remove( sortFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
71 else:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
72 os.rename( sortFile, outFile )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
73
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
74
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
75 if __name__ == "__main__":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
76 i = YassClusterLauncher()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
77 i.setAttributesFromCmdLine()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
78 i.run()