annotate baseline/wrapper.sh @ 4:5ffd52fc35c4 draft

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