forked from aseetharam/common_scripts
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Quiver_01.sh
executable file
·85 lines (67 loc) · 2.07 KB
/
Quiver_01.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
# Script to generate PBS sub files for quiver analysis
# 07/25/2016
# Andrew Severin <[email protected]>
function printUsage () {
cat <<EOF
Synopsis
$scriptName [-h | --help] <ReferenceGenomeToPolish>
Description
This is a bash script that will take all *.bax.h5 files in a folder and generate a list of pbalign commands, then generate a submission script for each one with the required modules loaded. The submission file is formatted to run on condo with 48 hours walltime on default queue.
The output will be named with the commands_file name along with the number suffix.
-h, --help
Brings up this help page
<ReferenceGenomeToPolish>
This fasta file contains the genome that you wish to polish with the raw read data (bax.h5).
Author
Andrew Severin, Genome Informatics Facilty, Iowa State University
25 July, 2016
EOF
}
if [ $# -lt 1 ] ; then
printUsage
exit 0
fi
GENOME="$1"
ls *bax.h5 | xargs -I xx echo "pbalign --forQuiver xx $1 aligned_reads.xx.cmp.h5" > pbalign.commands
INFILE="pbalign.commands"
function readlines () {
local N=1
local line
local rc="1"
for i in $(seq 1 $N); do
read line
if [ $? -eq 0 ]; then
echo "$line"
rc="0"
else
break
fi
done
return $rc
}
netid=$(whoami)
num=1
while chunk=$(readlines ${LINES}); do
cat <<JOBHEAD > ${INFILE%%.*}_${num}.sub
#!/bin/bash
#PBS -l nodes=1:ppn=16
#PBS -l walltime=48:00:00
#PBS -N ${INFILE%%.*}_${num}
#PBS -o \${PBS_JOBNAME}.o\${PBS_JOBID} -e \${PBS_JOBNAME}.e\${PBS_JOBID}
#PBS -m ae -M [email protected]
cd \$PBS_O_WORKDIR
ulimit -s unlimited
chmod g+rw \${PBS_JOBNAME}.[eo]\${PBS_JOBID}
module use /shared/modulefiles
module load LAS/parallel/20150922
module load python/2.7.10
module load SMRTAnalysis/2.3.0
JOBHEAD
echo -e "${chunk}" >> ${INFILE%%.*}_${num}.sub
echo -e "qstat -f \"\$PBS_JOBID\" | head" >> ${INFILE%%.*}_${num}.sub
echo -e "\nwalltime" >> ${INFILE%%.*}_${num}.sub
((num++))
done<"${INFILE}"
sed -i '/^$/d' ${INFILE}