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