annotate baseline/wrapper.sh @ 81:b6f9a640e098 draft

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