-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_dexseq_icgc_exon.sh
executable file
·69 lines (57 loc) · 1.89 KB
/
run_dexseq_icgc_exon.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
#!/bin/bash
set -e
dexseq_count=PATH_TO/dexseq_count.py
anno=PATH_TO_ANNOTATION/rnaseq.gc19_extNc.dexseq.gff
meta=METADATA
aligndir=ALIGNMENT_DIR
outdir=OUTDIR
mkdir -p $outdir
mem=30gb
if [ ! -z "$1" ]
then
file=$1
filebase=$(basename $file)
donefile="${outdir}/${filebase%bam}count.done"
logfile="${outdir}/${filebase%bam}count.log"
outfile="${outdir}/${filebase%bam}count.txt"
paired=$(samtools view -H $file | grep PG | python is_paired.py)
aid=$(echo $filebase | cut -f 1 -d '.')
stranded=$(grep $aid $meta | cut -f 31)
if [ "$stranded" == "fr-firststrand" ]
then
strand="reverse"
elif [ "$stranded" == "fr-secondstrand" ]
then
strand="yes"
else
strand="no"
fi
if [ -f ${file%bam}done -a ! -f $donefile ]
then
cd $(pwd); samtools view -F 4 $file | python $dexseq_count -s $strand -f sam -r pos -p $paired $anno - $outfile && touch $donefile
fi
else
for file in $(ls -1 ${aligndir}/*.bam)
do
filebase=$(basename $file)
donefile="${outdir}/${filebase%bam}count.done"
logfile="${outdir}/${filebase%bam}count.log"
outfile="${outdir}/${filebase%bam}count.txt"
paired=$(samtools view -H $file | grep PG | python is_paired.py)
aid=$(echo $filebase | cut -f 1 -d '.')
stranded=$(grep $aid $meta | cut -f 31)
if [ "$stranded" == "fr-firststrand" ]
then
strand="reverse"
elif [ "$stranded" == "fr-secondstrand" ]
then
strand="yes"
else
strand="no"
fi
if [ -f ${file%bam}done -a ! -f $donefile ]
then
echo "samtools view -F 4 $file | python $dexseq_count -s $strand -f sam -r pos -p $paired $anno - $outfile && touch $donefile" | qsub -l nodes=1:ppn=1,mem=$mem,vmem=$mem,pmem=$mem,walltime=24:00:00 -N icgc_htseq -j oe -o $logfile
fi
done
fi