-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupDirs.py
executable file
·48 lines (45 loc) · 1.29 KB
/
setupDirs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
import sys,getopt,os
SplitInput_string = """#!/bin/bash
#$ -N SplitInput
#$ -cwd
#$ -V
#$ -S /bin/bash
#$ -t 1-%numSamples%
#$ -o Logs/SplitInput.out
#$ -e Logs/SplitInput.err
#$ -q micro
PATH=%path%
export PATH
echo Date: `date`
t1=`date +%s`
sleep ${SGE_TASK_ID}
python LSFScripts/array_merge.py -r ${SGE_TASK_ID} -i %input% -o original_reads/
[ $? -eq 0 ] || echo 'JOB FAILURE: $?'
echo Date: `date`
t2=`date +%s`
tdiff=`echo 'scale=3;('$t2'-'$t1')/3600' | bc`
echo 'Total time: '$tdiff' hours'
"""
help_message = "usage example: python setupDirs.py -i /path/to/reads/ -n numberOfSamples"
if __name__ == "__main__":
try:
opts, args = getopt.getopt(sys.argv[1:],'hi:n:',["inputdir="])
except:
print help_message
sys.exit(2)
for opt, arg in opts:
if opt in ('-h','--help'):
print help_message
sys.exit()
elif opt in ('-i','--inputdir'):
inputdir = arg
if inputdir[-1] != '/':
inputdir += '/'
elif opt in ('-n'):
n = arg
for dir in ['Logs','original_reads','hashed_reads','cluster_vectors','read_partitions','partitions','fastq_temp','splits_temp']:
os.system('mkdir %s' % (dir))
f = open('LSFScripts/SplitInput_ArrayJob.q','w')
f.write(SplitInput_string.replace('%numSamples%',n).replace('%input%',inputdir).replace('%path%',os.environ['PATH']))
f.close()