0
|
1 #!/bin/bash
|
|
2
|
2
|
3 export IGDATA=/home/david/Galaxy/galaxy-dist/toolsheddependencies/igBlastn/1.0.0/davidvanzessen/igblast_human/1c64c977624e/ncbi-igblast-1.0.0/;
|
|
4
|
|
5 clonalType=${@:(-3):1}
|
0
|
6 html=${@:(-2):1}
|
|
7 imageDir=${@:(-1):1}
|
|
8 dir="$(cd "$(dirname "$0")" && pwd)"
|
2
|
9 fileCount=`expr $# - 3`
|
0
|
10 array=("$@")
|
|
11 echo "<html><h3>Progress</h3><table><tr><td>info</td></tr>" > $html
|
2
|
12 for var in "$@"
|
|
13 do
|
|
14 echo "$var" >> $html
|
|
15 done
|
0
|
16 echo "<tr><td>-----------------------------------</td></tr>" >> $html
|
|
17 limit=`expr $fileCount / 2`
|
|
18
|
|
19 function blastAndParse {
|
|
20 echo "<tr><td>Starting blast of $2</td></tr>" >> $html
|
|
21 fileName=$(basename $1)
|
|
22 $IGDATA/bin/igblastn -germline_db_V $IGDATA/database/human_gl_V -germline_db_J $IGDATA/database/human_gl_J -germline_db_D $IGDATA/database/human_gl_D -domain_system imgt -query $1 -auxiliary_data $IGDATA/optional_file/human_gl.aux -show_translation -outfmt 3 > $PWD/$fileName
|
|
23 echo "<tr><td>Finished blast of $2</td></tr>" >> $html
|
|
24
|
|
25 echo "<tr><td>Starting parse of $2</td></tr>" >> $html
|
|
26 parsedFileName="${fileName%.*}"
|
|
27 parsedFileName="$parsedFileName.parsed"
|
|
28 perl $dir/igparse.pl $PWD/$fileName 0 | grep -v "D:" | cut -f2- > $parsedFileName
|
|
29 echo "<tr><td>Finished parse of $2</td></tr>" >> $html
|
|
30 }
|
|
31
|
|
32 for ((i=0;i<$fileCount;i=$((i+2))))
|
|
33 do
|
|
34 next=$((i+1))
|
|
35 blastAndParse ${array[$i]} ${array[$next]} &
|
|
36 done
|
|
37 wait
|
|
38
|
|
39
|
|
40
|
|
41 echo "<tr><td>-----------------------------------</td></tr>" >> $html
|
|
42 echo "<tr><td>merging</td></tr>" >> $html
|
|
43
|
|
44 count=0
|
|
45 for ((i=0;i<$fileCount;i=$((i+2))))
|
|
46 do
|
|
47 id=$((i+1))
|
|
48 place=$((count+limit))
|
|
49 fn=$(basename ${array[$i]})
|
|
50 fn="${fn%.*}"
|
|
51 mergeInputs[$count]="$PWD/$fn.parsed"
|
|
52 mergeIDs[$place]=${array[$id]}
|
|
53 count=$((count+1))
|
|
54 done
|
|
55
|
|
56 python $dir/igblastmerge.py --input ${mergeInputs[*]} --id ${mergeIDs[*]} --output $PWD/merged.txt
|
|
57
|
|
58 echo "<tr><td>done</td></tr>" >> $html
|
|
59 echo "<tr><td>-----------------------------------</td></tr>" >> $html
|
|
60 echo "<tr><td>plotting</td></tr>" >> $html
|
|
61
|
|
62
|
|
63 inputFile=$PWD/merged.txt
|
|
64 outputFile=$html
|
|
65 outputDir=$imageDir
|
|
66 mkdir $outputDir
|
2
|
67 Rscript --verbose $dir/RScript.r $inputFile $outputDir $outputDir $clonalType 2>&1
|
0
|
68 echo "<html>" > $outputFile
|
|
69 echo "<img src='VPlot.png'/>" >> $outputFile
|
|
70 echo "<img src='DPlot.png'/>" >> $outputFile
|
|
71 echo "<img src='JPlot.png'/>" >> $outputFile
|
|
72
|
|
73 samples=`cat $outputDir/samples.txt`
|
|
74 count=1
|
|
75 echo "<table border='1'>" >> $outputFile
|
|
76 for sample in $samples; do
|
|
77 echo "<tr><td colspan='3' height='100'></td>" >> $outputFile
|
|
78 echo "<tr><td colspan='3'><h1>$sample</h1></td></tr>" >> $outputFile
|
|
79 echo "<tr><td><h2>V-D Heatmap:</h2></td><td><h2>V-J Heatmap:</h2></td><td><h2>D-J Heatmap:</h2></td></tr><tr>" >> $outputFile
|
|
80 mv "$outputDir/HeatmapVD_$sample.png" "$outputDir/VD_$sample.png"
|
|
81 echo "<td><img src='VD_$sample.png'/></td>" >> $outputFile
|
|
82 mv "$outputDir/HeatmapVJ_$sample.png" "$outputDir/VJ_$sample.png"
|
|
83 echo "<td><img src='VJ_$sample.png'/></td>" >> $outputFile
|
|
84 mv "$outputDir/HeatmapDJ_$sample.png" "$outputDir/DJ_$sample.png"
|
|
85 echo "<td><img src='DJ_$sample.png'/></td></tr>" >> $outputFile
|
|
86 count=$((count+1))
|
|
87 done
|
|
88 echo "</table>" >> $outputFile
|
2
|
89 echo "<h1>$clonalType</h1>" >> $outputFile
|
0
|
90
|
|
91 echo "</html>" >> $2
|