|
0
|
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 for ((i=8;i<=$#;i=i+2))
|
|
|
16 do
|
|
|
17 j=$((i+1))
|
|
|
18 echo -e "${!i}\t${!j}" >> $outDir/barcodes.txt
|
|
|
19 done
|
|
|
20
|
|
|
21 cd $outDir
|
|
|
22 echo "$3"
|
|
|
23 result=`$dir/sff2fastq $input | $dir/fastx_barcode_splitter.pl --bcfile $outDir/barcodes.txt --prefix "$prefix" --suffix ".fastq" --$EOL --mismatches $mismatches --partial $partial`
|
|
|
24 echo "$result" | tail -n +2 | sed 's/\t/,/g' > output.txt
|
|
|
25 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></tr></thead><tbody>" >> $output
|
|
|
26 ls
|
|
|
27 while IFS=, read barcode count location
|
|
|
28 do
|
|
|
29 if [ "total" == "$barcode" ]
|
|
|
30 then
|
|
|
31 echo "<tr><td>$barcode</td><td>$count</td><td></td><td></td></tr>" >> $output
|
|
|
32 break
|
|
|
33 fi
|
|
|
34 file=$name"_"$barcode
|
|
|
35 cat $file.fastq | perl -e '$i=0;while(< >){if(/^\@/&&$i==0){s/^\@/\>/;print;}elsif($i==1){print;$i=-3}$i++;}' > $file.fasta
|
|
|
36 cat $file.fastq
|
|
|
37 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></tr>" >> $output
|
|
|
38 done < output.txt
|
|
|
39 echo "</tbody></body></html>" >> $output
|