comparison tools/scrsh.sh @ 0:c5a812cdf478 draft

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