-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkraken_cdhit.sh
45 lines (39 loc) · 1.62 KB
/
kraken_cdhit.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
# Kraken standard database ############################################
KRAKEN=/vol/projects/dzhiluo/tools/kraken_uv2000/kraken
KRAKEN_R=/vol/projects/dzhiluo/tools/kraken_uv2000/kraken-report
KRAKEN_MR=/vol/projects/dzhiluo/tools/kraken_uv2000/kraken-mpa-report
db=${1%/}
outdir=${2%/}
NCORE=100
for file in *_cl_mRNA_R1.fastq
do
sample=${file%_cl_mRNA_R1.fastq}
outpath=${outdir}/${sample}
r1=${file}
r2=${sample}_cl_mRNA_R2.fastq
logfile=${outpath}_kraken.log
$KRAKEN --db $db --threads $NCORE --fastq-input --paired $r1 $r2 --unclassified-out ${outpath}_unclassified.fastq --classified-out ${outpath}_classified.fastq --output ${logfile}
$KRAKEN_R --db $db $logfile > ${logfile%.log}_normal.report
$KRAKEN_MR --show-zeros --db $db $logfile > ${logfile%.log}_report_mpa.txt
done
# BWA to gene catalog #################################################
export BWA=/vol/biotools/bin/bwa
export NCORE=20
export SAMTOOLS=/vol/biotools/bin/samtools
index=$1
outdir=${2%/}
for file in *_cl_mRNA_R1.fastq
do
sample=${file%_cl_mRNA_R1.fastq}
outpath=${outdir}/${sample}
r1=${file}
r2=${sample}_cl_mRNA_R2.fastq
bamfile=${outpath}_sorted.bam
logfile=${outpath}_aln.log
samcountfile=${outpath}_samcount.txt
countfile=${outpath}_count.txt
$BWA mem -k 31 -t $NCORE $index ${r1} ${r2} | $SAMTOOLS view -Shb - 2>> $logfile|$SAMTOOLS sort -@ 20 -m 10G -f - $bamfile >> $logfile 2>&1
$SAMTOOLS index $bamfile
$SAMTOOLS idxstats $bamfile > $samcountfile
awk -F"\t" '{print $3}' $samcountfile > $countfile
done