Last active
August 28, 2015 17:15
-
-
Save wckdouglas/0176bc4fda9a8cbd6f2d to your computer and use it in GitHub Desktop.
For high-throughput computing on TACC lonestar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import os | |
| import fileinput | |
| #==============================set parameter=================== | |
| time='1:30:00' | |
| allocation = '{Allocation-name}' | |
| projectPrerfix = '{name for the job}' | |
| commandPerJob = 1 | |
| coresPerCommand = 12 | |
| commandPerNode = 1 | |
| # ========================== main function =================== | |
| def check(): | |
| if (commandPerNode * coresPerCommand) % 12 != 0: | |
| sys.exit('Error: posible wrong cores!\n') | |
| def main(): | |
| if len(sys.argv) != 2: | |
| sys.exit('usage python %s <command.sh> \n' %sys.argv[0]) | |
| jobNum = 0 # job count | |
| i = 0 #command count | |
| count = 0 | |
| jobFile = '' | |
| for command in fileinput.input(): | |
| if i % commandPerJob == 0: | |
| if i != 0: | |
| sge.close() | |
| c.close() | |
| print 'written %s and %s with %i commands' %(jobFile, commandFile, count) | |
| jobNum += 1 | |
| jobFile = 'job_%02d.sge' %jobNum | |
| commandFile = 'command_%02d.sh' %jobNum | |
| count = 1 | |
| sge = open(jobFile,'w') | |
| c = open(commandFile,'w') | |
| sge.write("#!/bin/bash\n" +\ | |
| "#$ -N %s_%02d\n" %(projectPrerfix,jobNum)+\ | |
| "#$ -pe %iway %i\n" %(commandPerNode,coresPerCommand*commandPerJob) +\ | |
| "#$ -q normal\n" + \ | |
| "#$ -o %s_%02d.o$JOB_ID\n" %(projectPrerfix,jobNum) +\ | |
| "#$ -l h_rt=%s\n" %(time) +\ | |
| "#$ -V\n" +\ | |
| "#$ -cwd\n" +\ | |
| "#$ -A %s\n" %(allocation) + \ | |
| "module load launcher\nmodule swap intel gcc/4.4.5\n" + \ | |
| "module load bowtie/2.1.0 bwa/0.7.7 bedtools tophat/2.0.10 java64/1.7.0\n" + \ | |
| "export EXECUTABLE=$TACC_LAUNCHER_DIR/init_launcher\n" +\ | |
| "export CONTROL_FILE=%s\n" %commandFile+\ | |
| "export WORKDIR=.\n" +\ | |
| "$TACC_LAUNCHER_DIR/paramrun $EXECUTABLE $CONTROL_FILE\n") | |
| c.write(command) | |
| elif i % commandPerJob != 0: | |
| c.write(command) | |
| count += 1 | |
| i += 1 | |
| sge.close() | |
| c.close() | |
| print 'written %s and %s with %i commands' %(jobFile, commandFile, count) | |
| maxJob = 50 | |
| if jobNum > maxJob: | |
| print 'Warnings: written %i jobs, maximum is %i' %(jobNum,maxJob) | |
| return 0 | |
| # =========================================================== | |
| if __name__ == '__main__': | |
| check() | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment