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