-
Notifications
You must be signed in to change notification settings - Fork 1
/
BB_run_rnaseq_pipeline.sh~
executable file
·108 lines (104 loc) · 3.43 KB
/
BB_run_rnaseq_pipeline.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
if [ $# -lt 6 ];then
echo -e "$0 prefix srr_id num_of_lane single/paired yes/reverse/no/miss genome"
echo -e "set num_of_lane to 0 if the SRR file had already downloaded and gunzipped"
exit 1
fi
PREFIX=$1
SRR_ID=$2
NUM_LANE=$3
TYPE=$4
STRAND=$5
GENOME=$6
if [ $NUM_LANE -eq 1 ];then
TYPE_OTHER_LANE=${TYPE}
elif [ $NUM_LANE -eq 2 ];then
HEAD=${SRR_ID:0:3}
TAIL=${SRR_ID:3:7}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE}" "${HEAD}${TAIL}
elif [ $NUM_LANE -eq 3 ];then
HEAD=${SRR_ID:0:3}
TAIL=${SRR_ID:3:7}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
elif [ $NUM_LANE -eq 4 ];then
HEAD=${SRR_ID:0:3}
TAIL=${SRR_ID:3:7}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
elif [ $NUM_LANE -eq 5 ];then
HEAD=${SRR_ID:0:3}
TAIL=${SRR_ID:3:7}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
elif [ $NUM_LANE -eq 6 ];then
HEAD=${SRR_ID:0:3}
TAIL=${SRR_ID:3:7}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
TAIL=`expr $TAIL + 1`
TYPE_OTHER_LANE=${TYPE_OTHER_LANE}" "${HEAD}${TAIL}
else
echo "Warning: too many lanes"
fi
# download data
cd /data/tongji2/Recycle/RNAseq/Data
if [ $NUM_LANE -gt 0 ];then
BB_download_GEO.sh ${SRR_ID} ${TYPE_OTHER_LANE}
fi
# run pipeline
if [ "$TYPE" == "single" ];then
BB_rnaseq_pipeline.sh -l ${SRR_ID}.fastq -g ${GENOME} -o /data/tongji2/Recycle/RNAseq/Output \
-L ${STRAND} -A gene_name -p ${PREFIX}
elif [ "$TYPE" == "paired" ];then
BB_rnaseq_pipeline.sh -l ${SRR_ID}_1.fastq -r ${SRR_ID}_2.fastq -g ${GENOME} \
-o /data/tongji2/Recycle/RNAseq/Output -L ${STRAND} -A gene_name -p ${PREFIX}
else
echo "wrong type, single/paired"
fi
# check if it has really ran
RESULT_LENGTH=(`wc -l /data/tongji2/Recycle/RNAseq/Output/Htseq/${PREFIX}.rpm`)
if [ $RESULT_LENGTH -lt 2 ];then
if [ ! -f /data/tongji2/Recycle/RNAseq/error.list ];then
echo -e "sample_name\tsrr_id\tlane_num\ttype\tstrand\tgenome" > \
/data/tongji2/Recycle/RNAseq/error.list
fi
echo -e "${PREFIX}\t${SRR_ID}\t${NUM_LANE}\t${TYPE}\t${STRAND}\t${GENOME}" \
>> /data/tongji2/Recycle/RNAseq/error.list
else
if [ ! -f /data/tongji2/Recycle/RNAseq/finish.list ];then
echo -e "sample_name\tsrr_id\tlane_num\ttype\tstrand\tgenome" > \
/data/tongji2/Recycle/RNAseq/finish.list
fi
echo -e "${PREFIX}\t${SRR_ID}\t${NUM_LANE}\t${TYPE}\t${STRAND}\t${GENOME}" \
>> /data/tongji2/Recycle/RNAseq/finish.list
fi
# remove big files
if [ "$TYPE" == "single" ];then
rm /data/tongji2/Recycle/RNAseq/Data/${SRR_ID}*.fastq
else
rm /data/tongji2/Recycle/RNAseq/Data/${SRR_ID}_1.fastq \
/data/tongji2/Recycle/RNAseq/Data/${SRR_ID}_2.fastq
fi
rm /data/tongji2/Recycle/RNAseq/Output/STAR/${PREFIX}Log.out \
/data/tongji2/Recycle/RNAseq/Output/STAR/${PREFIX}Log.progress.out \
/data/tongji2/Recycle/RNAseq/Output/STAR/${PREFIX}*.bam