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