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