-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto-hisat2.sh
81 lines (69 loc) · 2.64 KB
/
auto-hisat2.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
# Authored by huangjj27([email protected], SYSU Student No.13331087)
# To know more about the author, see https://huangjj27.gitlab.ios/about
# unify the files as follow:
# current_dir
# |-- data
# |-- genome.fna.gz # the genome file
# |-- samples # all the RNA samples, sperated into directories
# |-- one_of_your_sample
# |-- R1.fastq.gz
# |-- R2.fastq.gz
# |-- results # separated by your sample
#!/bin/sh
hisat2_dir=${HISAT2_DIR:-"./hisat2"}
threads=${THREADS:-1}
picard_jar=${PICARD_JAR:-"./picar.jar"}
cufflinks=${CUFFLINKS:-"./cufflinks"}
echo "using ${threads} thread(s) to run the commmands..."
echo "geting fna file."
data_dir=${DATA:-"./data"}
if [ -z ${GENOME} ]; then
echo "ERR: genome file(.fna) is not set"
echo "HINT: rerun the script will a param \"GENOME=your_genome_file_basename\""
echo "EXAMPLE: GENOME=genome ./auto-hisat2.sh"
exit 1
fi
fna="${data_dir}/${GENOME}.fna.gz"
echo "using genome file ${fna}"
rm -rf results
mkdir results
for sample in `ls ${data_dir}/samples`
do
echo "dealing with sample #${sample}"
mkdir ./results/${sample}
echo "indexing sample #${sample}"
current_indices="./results/${sample}/indices"
mkdir ${current_indices}
${hisat2_dir}/hisat2-build -p ${threads} \
-f ${fna} \
"${current_indices}/sample_${sample}" \
1> "./results/${sample}/index.log" \
2> "./results/${sample}/index.err" \
echo "indexing sample #${sample} done!"
echo "aligning sample #${sample}"
${hisat2_dir}/hisat2-align-s -p ${threads} \
-x "${current_indices}/sample_${sample}" \
-1 "${data_dir}/samples/${sample}/R1.fastq.gz" \
-2 "${data_dir}/samples/${sample}/R2.fastq.gz" \
-S "./results/${sample}/align.sam" \
1> "./results/${sample}/align.log" \
2> "./results/${sample}/align.err"
echo "aligning sample #${sample} done!"
echo "using picard and sortSam"
java -jar ${picard_jar} SortSam \
INPUT="./results/${sample}/align.sam" \
OUTPUT="./results/${sample}/picard.sorted.bam" \
CREATE_INDEX=true \
SORT_ORDER=coordinate \
1> "./results/${sample}/picard.log" \
2> "./results/${sample}/picard.err"
echo "picard #${sample} done!"
echo "cufflinking #${sample}"
${cufflinks} -p ${threads} \
--library-type fr-firststrand \
-o "./results/${sample}/cufflinks-${sample}" \
"./results/${sample}/picard.sorted.bam" \
1> "./results/${sample}/cufflinks.log" \
2> "./results/${sample}/cufflinks.err"
echo "cufflinking #${sample} done!"
done