Mercurial > repos > davidvanzessen > igblastn_immunerepertoire_igg
comparison combined.sh @ 0:d52f6a986108 draft
Uploaded
author | davidvanzessen |
---|---|
date | Thu, 23 Jan 2014 08:22:28 -0500 |
parents | |
children | 7b0d9c107680 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d52f6a986108 |
---|---|
1 #!/bin/bash | |
2 | |
3 #export IGDATA=/home/david/tmp/ncbi-igblast-1.0.0; | |
4 | |
5 clonalType=${@:(-3):1} | |
6 html=${@:(-2):1} | |
7 imageDir=${@:(-1):1} | |
8 dataCount=`expr $# - 3` | |
9 inputData=${@:(1):dataCount} | |
10 dir="$(cd "$(dirname "$0")" && pwd)" | |
11 array=("$@") | |
12 echo "<html><h3>Progress</h3><table><tr><td>info</td></tr>" > $html | |
13 echo "<tr><td>-----------------------------------</td></tr>" >> $html | |
14 | |
15 function blastAndParse { | |
16 echo "<tr><td>Starting blast of sample $3 of patient $2</td></tr>" >> $html | |
17 echo "$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/$4" | |
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/$4 | |
19 echo "<tr><td>Finished blast of sample $3 of patient $2</td></tr>" >> $html | |
20 | |
21 echo "<tr><td>Starting parse of sample $3 of patient $2</td></tr>" >> $html | |
22 perl $dir/igparse.pl $PWD/$4 0 | grep -v "D:" | cut -f2- > $5 | |
23 echo "<tr><td>Finished parse of sample $3 of patient $2</td></tr>" >> $html | |
24 } | |
25 | |
26 id=${inputData[0]} | |
27 forwardSlash="/" | |
28 mergerInput=() | |
29 count=0 | |
30 for current in $inputData; do | |
31 if [[ "$current" != *"$forwardSlash"* ]]; then | |
32 id=$current | |
33 count=0 | |
34 mergerInput+=($id) | |
35 continue | |
36 fi | |
37 fileName=$(basename $current) | |
38 parsedFileName="${fileName%.*}" | |
39 parsedFileName="$PWD/$parsedFileName.parsed" | |
40 blastAndParse $current $id $count $fileName $parsedFileName & | |
41 mergerInput+=($parsedFileName) | |
42 count=$((count+1)) | |
43 done | |
44 wait | |
45 | |
46 | |
47 | |
48 echo "<tr><td>-----------------------------------</td></tr>" >> $html | |
49 echo "<tr><td>merging</td></tr>" >> $html | |
50 | |
51 python $dir/igblastmerge.py ${mergerInput[*]} --output $PWD/merged.txt | |
52 | |
53 echo "<tr><td>done</td></tr>" >> $html | |
54 echo "<tr><td>-----------------------------------</td></tr>" >> $html | |
55 echo "<tr><td>plotting</td></tr>" >> $html | |
56 | |
57 | |
58 inputFile=$PWD/merged.txt | |
59 outputFile=$html | |
60 outputDir=$imageDir | |
61 mkdir $outputDir | |
62 Rscript --verbose $dir/RScript.r $inputFile $outputDir $outputDir $clonalType 2>&1 | |
63 echo "<html>" > $outputFile | |
64 echo "<img src='VPlot.png'/>" >> $outputFile | |
65 echo "<img src='DPlot.png'/>" >> $outputFile | |
66 echo "<img src='JPlot.png'/>" >> $outputFile | |
67 | |
68 samples=`cat $outputDir/samples.txt` | |
69 count=1 | |
70 echo "<table border='1'><caption><a href='allUnique.tsv'><h3>$clonalType</h3></a></caption>" >> $outputFile | |
71 hasReplicateColumn="$(if head -n 1 $inputFile | grep -q 'Replicate'; then echo 'Yes'; else echo 'No'; fi)" | |
72 for sample in $samples; do | |
73 clonalityScore="$(cat $outputDir/ClonalityScore_$sample.csv)" | |
74 echo "<tr><td colspan='3' height='100'></td></tr>" >> $outputFile | |
75 echo "<tr><td colspan='3'><h1>$sample</h1></td></tr>" >> $outputFile | |
76 | |
77 echo "$hasReplicateColumn" | |
78 #if its a 'new' merged file with replicate info | |
79 if [[ "$hasReplicateColumn" == "Yes" ]] ; then | |
80 echo "<tr><td colspan='3'><a href='clonality_$sample.tsv'><h2>Clonality Score: $clonalityScore</h2></a></td></tr>" >> $outputFile | |
81 | |
82 #replicate,reads,squared | |
83 echo "<tr><td colspan='3'><table border='1'><tr><th>Replicate ID</th><th>Number of Reads</th><th>Reads Squared</th></tr>" >> $outputFile | |
84 while IFS=, read replicate reads squared | |
85 do | |
86 | |
87 echo "<tr><td><a href='clonality_${sample}_$replicate.tsv'>$replicate</a></td><td>$reads</td><td>$squared</td></tr>" >> $outputFile | |
88 done < $outputDir/ReplicateReads_$sample.csv | |
89 | |
90 #sum of reads and reads squared | |
91 while IFS=, read readsSum squaredSum | |
92 do | |
93 echo "<tr><td>Sum</td><td>$readsSum</td><td>$squaredSum</td></tr>" >> $outputFile | |
94 done < $outputDir/ReplicateSumReads_$sample.csv | |
95 | |
96 echo "</table></td></tr>" >> $outputFile | |
97 | |
98 #overview | |
99 echo "<tr><td colspan='3'><table border='1'><tr><th>Coincidence Type</th><th>Raw Coincidence Freq</th><th>Coincidence Weight</th><th>Coincidences, Weighted</th></tr>" >> $outputFile | |
100 while IFS=, read type count weight weightedCount | |
101 do | |
102 echo "<tr><td>$type</td><td>$count</td><td>$weight</td><td>$weightedCount</td></tr>" >> $outputFile | |
103 done < $outputDir/ClonalityOverView_$sample.csv | |
104 echo "</table></td></tr>" >> $outputFile | |
105 fi | |
106 | |
107 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 | |
108 mv "$outputDir/HeatmapVD_$sample.png" "$outputDir/VD_$sample.png" | |
109 echo "<td><img src='VD_$sample.png'/></td>" >> $outputFile | |
110 mv "$outputDir/HeatmapVJ_$sample.png" "$outputDir/VJ_$sample.png" | |
111 echo "<td><img src='VJ_$sample.png'/></td>" >> $outputFile | |
112 mv "$outputDir/HeatmapDJ_$sample.png" "$outputDir/DJ_$sample.png" | |
113 echo "<td><img src='DJ_$sample.png'/></td></tr>" >> $outputFile | |
114 count=$((count+1)) | |
115 done | |
116 echo "</table>" >> $outputFile | |
117 | |
118 echo "</html>" >> $outputFile |