annotate baseline/wrapper.sh @ 63:8728284105ee draft

Uploaded
author davidvanzessen
date Wed, 06 Dec 2017 08:04:52 -0500
parents c33d93683a09
children
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"
63
8728284105ee Uploaded
davidvanzessen
parents: 0
diff changeset
44 if [[ "$f" == *"Zip archive"* ]] || [[ "$f" == *"XZ compressed data"* ]]
0
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 filtered="$PWD/filtered_${id}.txt"
63
8728284105ee Uploaded
davidvanzessen
parents: 0
diff changeset
59 imgt_1_file="`find $PWD/$id -name '1_*.txt'`"
8728284105ee Uploaded
davidvanzessen
parents: 0
diff changeset
60 imgt_2_file="`find $PWD/$id -name '2_*.txt'`"
8728284105ee Uploaded
davidvanzessen
parents: 0
diff changeset
61 echo "1_Summary file: ${imgt_1_file}"
8728284105ee Uploaded
davidvanzessen
parents: 0
diff changeset
62 echo "2_IMGT-gapped file: ${imgt_2_file}"
8728284105ee Uploaded
davidvanzessen
parents: 0
diff changeset
63 echo "filter.r for $id"
8728284105ee Uploaded
davidvanzessen
parents: 0
diff changeset
64 Rscript $dir/filter.r ${imgt_1_file} ${imgt_2_file} "$selection" $filtered 2>&1
0
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
65
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
66 final="$PWD/final_${id}.txt"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
67 cat $filtered | cut -f2,4,7 > $final
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
68 python $dir/script_imgt.py --input $final --ref $ref --output $fasta --id $id
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
69 else
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
70 python $dir/script_xlsx.py --input $current --ref $ref --output $fasta
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
71 fi
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
72 count=$((count+1))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
73 done
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
74 workdir="$PWD"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
75 cd $dir
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
76 echo "file: ${inputs[0]}"
c33d93683a09 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
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
78 Rscript --verbose $dir/Baseline_Main.r $testID $species $substitutionModel $mutabilityModel $clonal $fixIndels $region $fasta $workdir/ $outID 2>&1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
79
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
80 echo "$workdir/${outID}.txt"
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
81
c33d93683a09 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' ' '`
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
83 rows=($rows)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
84 #unset rows[${#rows[@]}-1]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
85
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
86 cd $dir
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
87 Rscript --verbose $dir/comparePDFs.r $workdir/${outID}.RData $output ${rows[@]} 2>&1
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
88 cp $workdir/result.txt ${output_table}
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
89
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
90
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
91
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
92