annotate baseline/wrapper.sh @ 98:d714f5ea83d7 draft default tip

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