annotate tools/scrsh.sh @ 1:ddde82ae5dea draft

planemo upload
author marpiech
date Sun, 11 Dec 2016 18:57:58 -0500
parents c5a812cdf478
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
1 #!/bin/bash
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
2
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
3 #sample_data=(tmp tmp1 tmp2 tmp3)
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
4 sample_data=(`cat $1 | cut -f1 | sed ':a;N;$!ba;s/\n/ /g'`)
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
5 #sample_name=(sample1 sample2 sample3 sample4)
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
6 sample_name=(`cat $1 | cut -f2 | sed ':a;N;$!ba;s/\n/ /g'`)
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
7 #sample_group=(gr1 gr1 gr2 gr2)
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
8 sample_group=(`cat $1 | cut -f3 | sed ':a;N;$!ba;s/\n/ /g'`)
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
9
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
10
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
11 group=('#')
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
12 sample=('#Feature')
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
13
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
14 touch anno.tmp
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
15 touch count.tmp
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
16
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
17 nsamples=`expr ${#sample_data[@]} - 1`
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
18
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
19 for i in `seq 0 1 $nsamples`; do
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
20 group+=(${sample_group[i]}:${sample_group[i]})
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
21 sample+=(${sample_name[i]})
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
22
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
23 cat ${sample_data[i]} | tail -n+3 > dataWithoutHeader 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
24
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
25 cat dataWithoutHeader | sort -k1 > dataWithoutHeader.sorted 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
26
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
27 cat dataWithoutHeader.sorted | awk '{print $1}' > anno.sample 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
28 cat dataWithoutHeader.sorted | awk '{print $5}' > count.sample 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
29
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
30 paste -d"\t" count.tmp count.sample > count 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
31 paste -d"\t" anno.tmp anno.sample > anno 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
32
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
33 cat count > count.tmp 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
34 cat anno > anno.tmp 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
35
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
36 done
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
37
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
38 echo ${group[*]} | sed -e 's/ /\t/g' > count.matrix 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
39 echo ${sample[*]} | sed -e 's/ /\t/g' >> count.matrix 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
40
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
41 cat count | cut -f 2- > count.tmp 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
42
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
43 paste -d"\t" anno.sample count.tmp >> count.matrix 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
44
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
45 cat anno.tmp | cut -f 2- | awk '{for (i=2; i<=NF; i++){if ($1!=$i){print "error"; break}}}' > control.data 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
46
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
47 echo -e "gene_ID\tstart_coord\tend_coord" > annotation 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
48 cat dataWithoutHeader.sorted | awk '{print $1"\t"$2"\t"$3}' >> annotation 2>> script.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
49
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
50 if [[ -s control.data ]]; then
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
51 echo "kolumny nie sa w odpowiedniej kolejnosci" > error.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
52 echo "" > count.matrix
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
53 echo "" > annotation
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
54 else
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
55 echo "" > error.log
c5a812cdf478 planemo upload
marpiech
parents:
diff changeset
56 fi