| 
0
 | 
     1 #!/bin/bash
 | 
| 
5
 | 
     2 set -e
 | 
| 
1
 | 
     3 inputFiles=($1)
 | 
| 
 | 
     4 outputDir=$3
 | 
| 
 | 
     5 outputFile=$3/index.html #$1
 | 
| 
 | 
     6 clonalType=$4
 | 
| 
 | 
     7 species=$5
 | 
| 
 | 
     8 locus=$6
 | 
| 
7
 | 
     9 filterproductive=$7
 | 
| 
1
 | 
    10 
 | 
| 
 | 
    11 html=$2
 | 
| 
0
 | 
    12 dir="$(cd "$(dirname "$0")" && pwd)"
 | 
| 
 | 
    13 array=("$@")
 | 
| 
 | 
    14 echo "<html><h3>Progress</h3><table><tr><td>info</td></tr>" > $html
 | 
| 
 | 
    15 echo "<tr><td>-----------------------------------</td></tr>" >> $html
 | 
| 
 | 
    16 
 | 
| 
 | 
    17 mkdir $PWD/igblastdatabase
 | 
| 
 | 
    18 unzip $dir/database.zip -d $PWD/igblastdatabase/
 | 
| 
 | 
    19 export IGDATA=$PWD/igblastdatabase/
 | 
| 
 | 
    20 
 | 
| 
 | 
    21 function blastAndParse {
 | 
| 
 | 
    22 	echo "<tr><td>Starting blast of sample $3 of patient $2</td></tr>" >> $html
 | 
| 
 | 
    23 	echo "igblastn -germline_db_V $PWD/igblastdatabase/database/human_gl_V -germline_db_J $PWD/igblastdatabase/database/human_gl_J -germline_db_D $PWD/igblastdatabase/database/human_gl_D -domain_system imgt -query $1 -auxiliary_data $PWD/igblastdatabase/optional_file/human_gl.aux -show_translation -outfmt 3 > $PWD/$4"
 | 
| 
 | 
    24 	/home/galaxy/galaxy/igblast/igblastn -germline_db_V $PWD/igblastdatabase/database/human_gl_V -germline_db_J $PWD/igblastdatabase/database/human_gl_J -germline_db_D $PWD/igblastdatabase/database/human_gl_D -domain_system imgt -query $1 -auxiliary_data $PWD/igblastdatabase/optional_file/human_gl.aux -show_translation -outfmt 3 > $PWD/$4
 | 
| 
 | 
    25 	echo "<tr><td>Finished blast of sample $3 of patient $2</td></tr>" >> $html
 | 
| 
 | 
    26 	echo "<tr><td>Starting parse of sample $3 of patient $2</td></tr>" >> $html
 | 
| 
1
 | 
    27 	perl $dir/igparse.pl $PWD/$4 0 | grep -v "D:" | cut -f2- > "$5"
 | 
| 
0
 | 
    28 	echo "<tr><td>Finished parse of sample $3 of patient $2</td></tr>" >> $html
 | 
| 
 | 
    29 }
 | 
| 
 | 
    30 
 | 
| 
 | 
    31 function imgtConvert {
 | 
| 
 | 
    32 	echo "<tr><td>Starting imgt convert of sample $3 of patient $2</td></tr>" >> $html
 | 
| 
5
 | 
    33 	bash $dir/imgt_loader.sh $1 $4 $5
 | 
| 
0
 | 
    34 	echo "<tr><td>Finished conversion of sample $3 of patient $2</td></tr>" >> $html
 | 
| 
 | 
    35 }
 | 
| 
 | 
    36 
 | 
| 
1
 | 
    37 id=""
 | 
| 
0
 | 
    38 forwardSlash="/"
 | 
| 
 | 
    39 mergerInput=()
 | 
| 
1
 | 
    40 echo "Before loop"
 | 
| 
 | 
    41 count=1
 | 
| 
 | 
    42 for current in "${inputFiles[@]}"
 | 
| 
 | 
    43 do
 | 
| 
 | 
    44 	if [[ "$current" != *"$forwardSlash"* ]]; then
 | 
| 
 | 
    45 			id="$current"
 | 
| 
 | 
    46 			mergerInput+=($id)
 | 
| 
 | 
    47 			count=1
 | 
| 
 | 
    48 			continue
 | 
| 
 | 
    49 	fi
 | 
| 
 | 
    50 	echo "working on $current"
 | 
| 
0
 | 
    51 	fileName=$(basename $current)
 | 
| 
 | 
    52 	parsedFileName="${fileName%.*}"
 | 
| 
 | 
    53 	parsedFileName="$PWD/$parsedFileName.parsed"
 | 
| 
 | 
    54 	f=$(file $current)
 | 
| 
 | 
    55 	zipType="Zip archive"
 | 
| 
 | 
    56   if [[ "$f" == *"$zipType"* ]]
 | 
| 
 | 
    57 	then
 | 
| 
 | 
    58 		echo "<tr><td>Sample $count of patient $id is a zip file, using IMGT Loader</td></tr>" >> $html
 | 
| 
 | 
    59 	  fileName=$(basename $current)
 | 
| 
6
 | 
    60 		imgtConvert $current $id $count $parsedFileName "${id}_${count}" #&
 | 
| 
0
 | 
    61 	else
 | 
| 
 | 
    62 		echo "<tr><td>Sample $count of patient $id is not a zip file, using igBLASTn</td></tr>" >> $html
 | 
| 
 | 
    63 		blastAndParse $current $id $count $fileName $parsedFileName &
 | 
| 
 | 
    64 	fi
 | 
| 
 | 
    65 	mergerInput+=($parsedFileName)
 | 
| 
 | 
    66 	count=$((count+1))
 | 
| 
 | 
    67 done
 | 
| 
 | 
    68 wait
 | 
| 
 | 
    69 
 | 
| 
1
 | 
    70 echo "after loop"
 | 
| 
0
 | 
    71 
 | 
| 
 | 
    72 echo "<tr><td>-----------------------------------</td></tr>" >> $html
 | 
| 
 | 
    73 echo "<tr><td>merging</td></tr>" >> $html
 | 
| 
 | 
    74 
 | 
| 
5
 | 
    75 python $dir/experimental_design.py ${mergerInput[*]} --output $PWD/merged.txt
 | 
| 
0
 | 
    76 
 | 
| 
 | 
    77 echo "<tr><td>done</td></tr>" >> $html
 | 
| 
 | 
    78 echo "<tr><td>-----------------------------------</td></tr>" >> $html
 | 
| 
 | 
    79 echo "<tr><td>plotting</td></tr>" >> $html
 | 
| 
 | 
    80 
 | 
| 
5
 | 
    81 echo "after ED"
 | 
| 
 | 
    82 
 | 
| 
7
 | 
    83 $dir/r_wrapper.sh $PWD/merged.txt $2 $outputDir $clonalType $species $locus $filterproductive
 | 
| 
0
 | 
    84 
 |