Mercurial > repos > davidvanzessen > combined_immune_repertoire_imgt
comparison combined.sh @ 1:d2b3bcabb478 draft
Uploaded
author | davidvanzessen |
---|---|
date | Mon, 09 Dec 2013 06:08:52 -0500 |
parents | |
children | 8ba0fd5b03a1 |
comparison
equal
deleted
inserted
replaced
0:e71c59b72669 | 1:d2b3bcabb478 |
---|---|
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 id=${inputData[0]} | |
16 forwardSlash="/" | |
17 mergerInput=() | |
18 count=0 | |
19 for current in $inputData; do | |
20 if [[ "$current" != *"$forwardSlash"* ]]; then | |
21 id=$current | |
22 count=0 | |
23 mergerInput+=($id) | |
24 continue | |
25 fi | |
26 fileName=$(basename $current) | |
27 convertedFileName="${fileName%.*}" | |
28 convertedFileName="$PWD/$convertedFileName.converted" | |
29 bash $dir/imgtconvert.sh $current $id $count $convertedFileName | |
30 mergerInput+=($convertedFileName) | |
31 count=$((count+1)) | |
32 done | |
33 wait | |
34 | |
35 | |
36 | |
37 echo "<tr><td>-----------------------------------</td></tr>" >> $html | |
38 echo "<tr><td>merging</td></tr>" >> $html | |
39 | |
40 python $dir/igblastmerge.py ${mergerInput[*]} --output $PWD/merged.txt | |
41 | |
42 echo "<tr><td>done</td></tr>" >> $html | |
43 echo "<tr><td>-----------------------------------</td></tr>" >> $html | |
44 echo "<tr><td>plotting</td></tr>" >> $html | |
45 | |
46 | |
47 inputFile=$PWD/merged.txt | |
48 outputFile=$html | |
49 outputDir=$imageDir | |
50 mkdir $outputDir | |
51 Rscript --verbose $dir/RScript.r $inputFile $outputDir $outputDir $clonalType 2>&1 | |
52 echo "<html>" > $outputFile | |
53 echo "<img src='VPlot.png'/>" >> $outputFile | |
54 echo "<img src='DPlot.png'/>" >> $outputFile | |
55 echo "<img src='JPlot.png'/>" >> $outputFile | |
56 | |
57 samples=`cat $outputDir/samples.txt` | |
58 count=1 | |
59 echo "<table border='1'><caption><a href='allUnique.tsv'><h3>$clonalType</h3></a></caption>" >> $outputFile | |
60 hasReplicateColumn="$(if head -n 1 $inputFile | grep -q 'Replicate'; then echo 'Yes'; else echo 'No'; fi)" | |
61 for sample in $samples; do | |
62 clonalityScore="$(cat $outputDir/ClonalityScore_$sample.csv)" | |
63 echo "<tr><td colspan='3' height='100'></td></tr>" >> $outputFile | |
64 echo "<tr><td colspan='3'><h1>$sample</h1></td></tr>" >> $outputFile | |
65 | |
66 echo "$hasReplicateColumn" | |
67 #if its a 'new' merged file with replicate info | |
68 if [[ "$hasReplicateColumn" == "Yes" ]] ; then | |
69 echo "<tr><td colspan='3'><a href='clonality_$sample.tsv'><h2>Clonality Score: $clonalityScore</h2></a></td></tr>" >> $outputFile | |
70 | |
71 #replicate,reads,squared | |
72 echo "<tr><td colspan='3'><table border='1'><tr><th>Replicate ID</th><th>Number of Reads</th><th>Reads Squared</th></tr>" >> $outputFile | |
73 while IFS=, read replicate reads squared | |
74 do | |
75 | |
76 echo "<tr><td><a href='clonality_${sample}_$replicate.tsv'>$replicate</a></td><td>$reads</td><td>$squared</td></tr>" >> $outputFile | |
77 done < $outputDir/ReplicateReads_$sample.csv | |
78 | |
79 #sum of reads and reads squared | |
80 while IFS=, read readsSum squaredSum | |
81 do | |
82 echo "<tr><td>Sum</td><td>$readsSum</td><td>$squaredSum</td></tr>" >> $outputFile | |
83 done < $outputDir/ReplicateSumReads_$sample.csv | |
84 | |
85 echo "</table></td></tr>" >> $outputFile | |
86 | |
87 #overview | |
88 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 | |
89 while IFS=, read type count weight weightedCount | |
90 do | |
91 echo "<tr><td>$type</td><td>$count</td><td>$weight</td><td>$weightedCount</td></tr>" >> $outputFile | |
92 done < $outputDir/ClonalityOverView_$sample.csv | |
93 echo "</table></td></tr>" >> $outputFile | |
94 fi | |
95 | |
96 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 | |
97 mv "$outputDir/HeatmapVD_$sample.png" "$outputDir/VD_$sample.png" | |
98 echo "<td><img src='VD_$sample.png'/></td>" >> $outputFile | |
99 mv "$outputDir/HeatmapVJ_$sample.png" "$outputDir/VJ_$sample.png" | |
100 echo "<td><img src='VJ_$sample.png'/></td>" >> $outputFile | |
101 mv "$outputDir/HeatmapDJ_$sample.png" "$outputDir/DJ_$sample.png" | |
102 echo "<td><img src='DJ_$sample.png'/></td></tr>" >> $outputFile | |
103 count=$((count+1)) | |
104 done | |
105 echo "</table>" >> $outputFile | |
106 | |
107 echo "</html>" >> $outputFile |