-
Notifications
You must be signed in to change notification settings - Fork 0
/
optional1-sortSam.sh
executable file
·64 lines (52 loc) · 1.33 KB
/
optional1-sortSam.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
#!/bin/sh
## Usage
# sh optional1-sortSam.sh stem
# sh optional1-sortSam.sh snyder
# sh optional1-sortSam.sh hippo
# Define variables
EXPERIMENT=$1
SHORT="sortSam-${EXPERIMENT}"
# Directories
ROOTDIR=/dcl01/lieber/ajaffe/derRuns/derSoftware
MAINDIR=${ROOTDIR}/${EXPERIMENT}
WDIR=${MAINDIR}/sortSam
if [[ "${EXPERIMENT}" == "stem" ]]
then
SAMFILES='/dcs01/ajaffe/UCSC_Epigenome/RNAseq/TopHat/*out/accepted_hits.bam'
elif [[ "${EXPERIMENT}" == "snyder" ]]
then
SAMFILES='/dcs01/ajaffe/Snyder/RNAseq/TopHat/*out/accepted_hits.bam'
elif [[ "${EXPERIMENT}" == "hippo" ]]
then
SAMFILES='/dcs01/ajaffe/Hippo/TopHat/*out/accepted_hits.bam'
else
echo "Specify a valid experiment: stem, snyder, or hippo"
fi
# Construct shell files
sname="${SHORT}"
echo "Creating script ${sname}"
cat > ${ROOTDIR}/.${sname}.sh <<EOF
#!/bin/bash
#$ -cwd
#$ -m e
#$ -l mem_free=100G,h_vmem=200G,h_fsize=100G
#$ -N ${sname}
echo "**** Job starts ****"
date
# Make logs directory
mkdir -p ${WDIR}/logs
## Transform BAM files to SAM files
for file in ${SAMFILES}
do
echo ${file}
samtools sort -n $file ${file/.bam/_sorted}
samtools view -h ${file/.bam/_sorted.bam} > ${file/.bam/_sorted.sam}
done
## Move log files into the logs directory
mv ${ROOTDIR}/${sname}.* ${WDIR}/logs/
echo "**** Job ends ****"
date
EOF
call="qsub .${sname}.sh"
echo $call
$call