comparison from_imgt.sh @ 0:5560672b1ca4 draft default tip

Uploaded
author davidvanzessen
date Fri, 24 Jul 2015 04:44:39 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:5560672b1ca4
1 set -e
2
3 dir="$(cd "$(dirname "$0")" && pwd)"
4
5 args=($@)
6 inputs=(${args[@]:1})
7 output="${args[0]}"
8 echo "$PWD"
9
10 function get_summary_file
11 {
12 imgt_zip=$1
13 summary_file=$2
14
15 mkdir ${PWD}/tmp/
16 type="`file ${imgt_zip}`"
17 if [[ "$type" == *"Zip archive"* ]] ; then
18 unzip ${imgt_zip} -d $PWD/tmp/
19 elif [[ "$type" == *"XZ compressed data"* ]] ; then
20 mkdir "$PWD/tmp/files"
21 tar -xJf ${imgt_zip} -C $PWD/tmp/files
22 fi
23
24 cat $PWD/tmp/*/1_* > ${summary_file}
25 rm -rf $PWD/tmp
26 }
27
28 index=0
29
30 echo -e "Patient\tReceptor\tSample\tCell_Count\tClone_Molecule_Count_From_Spikes\tLog10_Frequency\tTotal_Read_Count\tV_Segment_Major_Gene\tJ_Segment_Major_Gene\tClone_Sequence\tCDR3_Sense_Sequence\tRelated_to_leukemia_clone" > "$output"
31
32 while true
33 do
34 patient="${inputs[$index]}"
35 index=$((index + 1))
36 cell_count="${inputs[$index]}"
37 index=$((index + 1))
38 receptor="${inputs[$index]}"
39 index=$((index + 1))
40 sample_count="${inputs[$index]}"
41 index=$((index + 1))
42
43 sample_name="${inputs[$index]}"
44 index=$((index + 1))
45
46 sample_file="${inputs[$index]}"
47 index=$((index + 1))
48
49 echo "patient: $patient"
50 echo "cell_count: ${cell_count}"
51 echo "receptor: $receptor"
52 echo "sample_count: ${sample_count}"
53 echo "sample_name: ${sample_name}"
54 echo "sample_file: ${sample_file}"
55
56 get_summary_file ${sample_file} ${PWD}/summ.txt
57
58 Rscript --verbose $dir/from_imgt.r ${PWD}/summ.txt ${patient} ${sample_name} ${cell_count} ${receptor} ${PWD}/tmp.txt 2>&1
59 cat "${PWD}/tmp.txt" >> "$output"
60
61 if [[ "${sample_count}" -gt "1" ]]; then
62 sample_name="${inputs[$index]}"
63 index=$((index + 1))
64
65 sample_file="${inputs[$index]}"
66 index=$((index + 1))
67
68 echo "sample_name: ${sample_name}"
69 echo "sample_file: ${sample_file}"
70
71 get_summary_file ${sample_file} ${PWD}/summ.txt
72
73 Rscript --verbose $dir/from_imgt.r ${PWD}/summ.txt ${patient} ${sample_name} ${cell_count} ${receptor} ${PWD}/tmp.txt 2>&1
74 cat "${PWD}/tmp.txt" >> "$output"
75 fi
76
77 if [[ "${sample_count}" -eq "3" ]]; then
78 sample_name="${inputs[$index]}"
79 index=$((index + 1))
80
81 sample_file="${inputs[$index]}"
82 index=$((index + 1))
83
84 echo "sample_name: ${sample_name}"
85 echo "sample_file: ${sample_file}"
86
87 get_summary_file ${sample_file} ${PWD}/summ.txt
88
89 Rscript --verbose $dir/from_imgt.r ${PWD}/summ.txt ${patient} ${sample_name} ${cell_count} ${receptor} ${PWD}/tmp.txt 2>&1
90 cat "${PWD}/tmp.txt" >> "$output"
91 fi
92 if [[ "${index}" -eq "${#inputs[@]}" ]]; then
93 exit 0
94 fi
95 done
96
97
98
99
100
101
102
103
104