annotate baseline/wrapper.sh @ 55:6cd12c71c3d3 draft

Uploaded
author davidvanzessen
date Wed, 14 Jun 2017 11:14:00 -0400
parents c33d93683a09
children 8728284105ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
1 #!/bin/bash
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
2 dir="$(cd "$(dirname "$0")" && pwd)"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
3
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
4 testID=$1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
5 species=$2
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
6 substitutionModel=$3
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
7 mutabilityModel=$4
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
8 clonal=$5
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
9 fixIndels=$6
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
10 region=$7
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
11 inputs=$8
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
12 inputs=($inputs)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
13 IDs=$9
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
14 IDs=($IDs)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
15 ref=${10}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
16 output=${11}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
17 selection=${12}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
18 output_table=${13}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
19 outID="result"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
20
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
21 echo "$PWD"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
22
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
23 echo "testID = $testID"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
24 echo "species = $species"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
25 echo "substitutionModel = $substitutionModel"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
26 echo "mutabilityModel = $mutabilityModel"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
27 echo "clonal = $clonal"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
28 echo "fixIndels = $fixIndels"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
29 echo "region = $region"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
30 echo "inputs = ${inputs[@]}"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
31 echo "IDs = ${IDs[@]}"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
32 echo "ref = $ref"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
33 echo "output = $output"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
34 echo "outID = $outID"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
35
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
36 fasta="$PWD/baseline.fasta"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
37
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
38
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
39 count=0
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
40 for current in ${inputs[@]}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
41 do
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
42 f=$(file $current)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
43 zipType="Zip archive"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
44 if [[ "$f" == *"$zipType"* ]] || [[ "$f" == *"XZ compressed data"* ]]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
45 then
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
46 id=${IDs[$count]}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
47 echo "id=$id"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
48 if [[ "$f" == *"Zip archive"* ]] ; then
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
49 echo "Zip archive"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
50 echo "unzip $input -d $PWD/files/"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
51 unzip $current -d "$PWD/$id/"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
52 elif [[ "$f" == *"XZ compressed data"* ]] ; then
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
53 echo "ZX archive"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
54 echo "tar -xJf $input -C $PWD/files/"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
55 mkdir -p "$PWD/$id/files"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
56 tar -xJf $current -C "$PWD/$id/files/"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
57 fi
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
58 summaryfile="$PWD/summary_${id}.txt"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
59 gappedfile="$PWD/gappednt_${id}.txt"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
60 filtered="$PWD/filtered_${id}.txt"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
61 filecount=`ls -l $PWD/$id/ | wc -l`
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
62 if [[ "$filecount" -eq "2" ]]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
63 then
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
64 cat $PWD/$id/*/1_* > $summaryfile
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
65 cat $PWD/$id/*/2_* > $gappedfile
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
66 else
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
67 cat $PWD/$id/1_* > $summaryfile
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
68 cat $PWD/$id/2_* > $gappedfile
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
69 fi
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
70 Rscript $dir/filter.r $summaryfile $gappedfile "$selection" $filtered 2>&1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
71
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
72 final="$PWD/final_${id}.txt"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
73 cat $filtered | cut -f2,4,7 > $final
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
74 python $dir/script_imgt.py --input $final --ref $ref --output $fasta --id $id
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
75 else
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
76 python $dir/script_xlsx.py --input $current --ref $ref --output $fasta
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
77 fi
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
78 count=$((count+1))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
79 done
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
80
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
81 if [[ $(wc -l < $fasta) -eq "1" ]]; then
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
82 echo "No sequences in the fasta file, exiting"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
83 exit 0
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
84 fi
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
85
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
86 workdir="$PWD"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
87 cd $dir
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
88 echo "file: ${inputs[0]}"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
89 #Rscript --verbose $dir/Baseline_Main.r $testID $species $substitutionModel $mutabilityModel $clonal $fixIndels $region ${inputs[0]} $workdir/ $outID 2>&1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
90 Rscript --verbose $dir/Baseline_Main.r $testID $species $substitutionModel $mutabilityModel $clonal $fixIndels $region $fasta $workdir/ $outID 2>&1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
91
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
92 echo "$workdir/${outID}.txt"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
93
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
94 rows=`tail -n +2 $workdir/${outID}.txt | grep -v "All sequences combined" | grep -n 'Group' | grep -Eoh '^[0-9]+' | tr '\n' ' '`
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
95 rows=($rows)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
96 #unset rows[${#rows[@]}-1]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
97
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
98 cd $dir
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
99 Rscript --verbose $dir/comparePDFs.r $workdir/${outID}.RData $output ${rows[@]} 2>&1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
100 cp $workdir/result.txt ${output_table}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
101
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
102
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
103
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
104