annotate chromeister/bin/index_chromeister.sh @ 0:7fdf47a0bae8 draft

Uploaded
author alvarofaure
date Wed, 12 Dec 2018 07:18:40 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
1 #!/usr/bin/env bash
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
2 DIR=$1
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
3 FASTAS1=$3
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
4 FASTAS2=$4
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
5 OUT=$2
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
6
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
7 echo "Computing index CSV..." > index.csv.temp
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
8
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
9 while [ "$(find . -size 0 | wc -l)" -ne 0 ]; do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
10 sleep 10s
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
11 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
12
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
13
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
14 EXT="mat"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
15 EXTSCORE="scr.txt"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
16 EXTGENERAL=".fa.fasta"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
17
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
18
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
19
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
20 if [ $# != 4 ]; then
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
21 echo "***ERROR*** Use: $0 <directory> <out> <fastas_directory_1> <fastas_directory_2>"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
22 exit -1
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
23 fi
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
24
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
25 rm $DIR/*.log
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
26
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
27 for i in $DIR/*.scr; do mv $i $i.txt; done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
28
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
29 rm $OUT
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
30
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
31 for elem in $(ls -d $DIR/*.$EXT | awk -F "/" '{print $NF}' | awk -F ".$EXT" '{print $1}')
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
32 do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
33 IFS='-', read -a splits <<< "$elem"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
34 IFS='.', read -a getnum <<< "$elem"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
35
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
36 scorepath=$(basename $elem .mat).$EXTSCORE
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
37
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
38 sed -i "/X.*/d" $DIR/$scorepath
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
39 sed -i "s/\[1\]//g" $DIR/$scorepath
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
40
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
41 score=$( head -1 $DIR/$scorepath)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
42
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
43 file1=${splits[0]}
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
44 file2=$(basename ${splits[1]} .mat)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
45
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
46 ID1=$(head -1 $FASTAS1/$file1)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
47 ID2=$(head -1 $FASTAS2/$file2)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
48
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
49
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
50 #scorepath="$(basename $elem .mat).$EXTSCORE"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
51 #score="$(head -1 $DIR/$scorepath)"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
52
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
53 counter=0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
54 numX=0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
55 numY=0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
56 for i in "${getnum[@]}"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
57 do
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
58 counter=`expr $counter + 1`
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
59 if [ "$numX" -eq 0 ] && [ "$i" == "chromosome" ]; then
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
60 numX=$counter
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
61 continue
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
62 fi
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
63 if [ "$numX" -ne 0 ] && [ "$i" == "chromosome" ]; then
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
64 numY=$counter
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
65 fi
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
66
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
67 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
68
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
69
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
70 echo "$(basename ${splits[0]} $EXTGENERAL),$(basename ${splits[1]} ${EXTGENERAL}.mat),$ID1,$ID2,$elem.$EXT.filt.png,${getnum[${numX}]},${getnum[${numY}]},$score" >> $OUT
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
71
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
72 done
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
73
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
74 sort -k5,5n -k6,6n -o $OUT $OUT
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
75
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
76
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
77 sed -i '1iSpX, SpY, IDX, IDY, IMG, CHNumberX, CHNumberY, Score' $OUT
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
78
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
79 rm index.csv.temp
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
80