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