comparison wrapper.sh @ 5:35b55f1c0c59 draft

Uploaded
author davidvanzessen
date Tue, 08 Jul 2014 09:38:54 -0400
parents
children 18ede27dc6b0
comparison
equal deleted inserted replaced
4:8e3d95d7f342 5:35b55f1c0c59
1 #!/bin/bash
2 input=$1
3 output=$2
4 outDir=$3
5 mkdir $outDir
6 EOL=$4
7 mismatches=$5
8 partial=$6
9 name=$(basename "$7")
10 ext="${name##*.}"
11 name="${name%.*}"
12 prefix=$name"_"
13 dir="$(cd "$(dirname "$0")" && pwd)"
14
15 unzip $dir/fastqc_v0.11.2.zip -d $PWD/ > $PWD/unziplog.log
16 chmod 755 $PWD/FastQC/fastqc
17
18 declare -A trim_start
19 declare -A trim_end
20 for ((i=8;i<=$#;i=i+4))
21 do
22 j=$((i+1))
23 start_int=$((i+2))
24 end_int=$((i+3))
25 id="${!i}"
26 echo "$id"
27 trim_start[$id]=${!start_int}
28 trim_end[$id]=${!end_int}
29 echo -e "$id\t${!j}" >> $outDir/barcodes.txt
30
31 done
32 trim_start["unmatched"]=0
33 trim_end["unmatched"]=0
34
35 echo "trim_start = ${trim_start[@]}"
36 echo "trim_end = ${trim_end[@]}"
37
38 workdir=$PWD
39 cd $outDir
40 echo "$3"
41 result=`$dir/sff2fastq $input | $dir/fastx_barcode_splitter.pl --bcfile $outDir/barcodes.txt --prefix "$prefix" --suffix ".fastq" --$EOL --mismatches $mismatches --partial $partial`
42 echo "$result" | tail -n +2 | sed 's/\t/,/g' > output.txt
43 echo "<html><head><title>$name demultiplex</title></head><body><table border='1'><thead><tr><th>ID</th><th>Count</th><th>FASTQ</th><th>FASTA</th><th>Trimmed FASTA</th><th>FASTQC</th></tr></thead><tbody>" >> $output
44 while IFS=, read barcode count location
45 do
46 if [ "total" == "$barcode" ]
47 then
48 echo "<tr><td>$barcode</td><td>$count</td><td></td><td></td><td></td><td></td><td></td><td></td></tr>" >> $output
49 break
50 fi
51 file=$name"_"$barcode
52 mkdir $outDir/fastqc_$barcode
53 $workdir/FastQC/fastqc $file.fastq -o $outDir 2> /dev/null
54 cat $file.fastq | awk 'NR%4==1{printf ">%s\n", substr($0,2)}NR%4==2{print}' > $file.fasta
55 python $dir/trim.py --input $file.fasta --output ${file}_trimmed.fasta --start ${trim_start[$barcode]} --end ${trim_end[$barcode]}
56 echo "<tr><td>$barcode</td><td>$count</td><td><a href='$file.fastq'>$file.fastq</a></td><td><a href='$file.fasta'>$file.fasta</a></td><td><a href='${file}_trimmed.fasta'>${file}_trimmed.fasta</a></td><td><a href='${name}_${barcode}_fastqc.html'>Report</a></td></tr>" >> $output
57 done < output.txt
58 echo "</tbody></body></html>" >> $output