-
Notifications
You must be signed in to change notification settings - Fork 0
/
optional2-HTSeq.sh
executable file
·87 lines (68 loc) · 1.78 KB
/
optional2-HTSeq.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
86
87
#!/bin/sh
## Usage
# sh optional2-HTSeq.sh stem
# sh optional2-HTSeq.sh snyder
# sh optional2-HTSeq.sh hippo
# Define variables
EXPERIMENT=$1
SHORT="HTSeq-${EXPERIMENT}"
# Directories
ROOTDIR=/dcl01/lieber/ajaffe/derRuns/derSoftware
MAINDIR=${ROOTDIR}/${EXPERIMENT}
WDIR=${MAINDIR}/HTSeq
if [[ "${EXPERIMENT}" == "stem" ]]
then
SAMFILES='/dcs01/ajaffe/UCSC_Epigenome/RNAseq/TopHat/*out'
elif [[ "${EXPERIMENT}" == "snyder" ]]
then
SAMFILES='/dcs01/ajaffe/Snyder/RNAseq/TopHat/*out'
elif [[ "${EXPERIMENT}" == "hippo" ]]
then
SAMFILES='/dcs01/ajaffe/Hippo/TopHat/*out'
else
echo "Specify a valid experiment: stem, snyder, or hippo"
fi
# Construct shell files
for sam in $SAMFILES
do
current=${sam##*/}
sname="${SHORT}.${current}"
echo "Creating script ${sname}"
cat > ${ROOTDIR}/.${sname}.sh <<EOF
#!/bin/bash
#$ -cwd
#$ -m e
#$ -l mem_free=50G,h_vmem=100G,h_fsize=30G
#$ -hold_jid sortSam-${EXPERIMENT}
#$ -N ${sname}
echo "**** Job starts ****"
date
# Make logs directory
mkdir -p ${WDIR}/logs
# Copy files to a scratch disk
TDIR=\${TMPDIR}/htseq
mkdir -p \${TDIR}
cd \${TDIR}
# Specify file names
orifile=${sam}/accepted_hits_sorted.sam
newfile=\${TDIR}/accepted_hits_sorted.sam
# Actually do the copying
echo "Copying \${orifile} to scratch disk \${newfile}"
cp \${orifile} \${newfile}
# run htseq
echo "**** HTSeq starts ****"
date
htseq-count --stranded=no --type='sequence_feature' --idattr='ID' accepted_hits_sorted.sam ${ROOTDIR}/gff/GenomicState.Hsapiens.ensembl.GRCh37.p11.exons.gff > htseq_output.txt
echo "**** HTSeq finishes ****"
date
# Copy back the results
mv htseq_output.txt ${sam}/
## Move log files into the logs directory
mv ${ROOTDIR}/${sname}.* ${WDIR}/logs/
echo "**** Job ends ****"
date
EOF
call="qsub .${sname}.sh"
echo $call
$call
done