annotate chromeister/bin/index_chromeister_solo.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=".fasta"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
17
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
18 # data is like
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
19 # HOMSA.Chr.10.fasta
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
20
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
21
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
22
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
23 if [ $# != 4 ]; then
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
24 echo "***ERROR*** Use: $0 <directory> <out> <fastas_directory_1> <fastas_directory_2>"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
25 exit -1
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
26 fi
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
27
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
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
34 IFS='-', read -a splits <<< "$elem" # yields MUSMU.Chr.8.fasta and MUSMU.Chr.Y.fasta
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
35 IFS='.', read -a getnum <<< "$elem" # yields MUSMU Chr 8 fasta and MUSMU Chr Y fasta
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
36
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
37 scorepath=$(basename $elem .mat).$EXTSCORE
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
38
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
39 sed -i "/X.*/d" $DIR/$scorepath
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
40 sed -i "s/\[1\]//g" $DIR/$scorepath
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
41
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
42 score=$( head -1 $DIR/$scorepath)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
43 len1=$( head -1 $DIR/$elem.mat.events.txt | awk -F="," '{print $1}')
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
44 len2=$( head -1 $DIR/$elem.mat.events.txt | awk -F="," '{print $2}')
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
45
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
46
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
47
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
48 file1=${splits[0]}
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
49 file2=$(basename ${splits[1]} .mat)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
50
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
51 ID1=$(head -1 $FASTAS1/$file1)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
52 ID2=$(head -1 $FASTAS2/$file2)
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
53
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
54
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
55 #scorepath="$(basename $elem .mat).$EXTSCORE"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
56 #score="$(head -1 $DIR/$scorepath)"
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
57
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
58 counter=0
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
59 numX=${getnum[2]}
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
60 numY=${getnum[5]}
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
61
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
62
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
63
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
64
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
65 echo "$(basename ${splits[0]} $EXTGENERAL),$(basename ${splits[1]} ${EXTGENERAL}),$ID1,$ID2,$elem.$EXT.filt.png,$numX,$numY,$score,$len1 $len2" >> $OUT
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 sort -k5,5n -k6,6n -o $OUT $OUT
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
70
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
71
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
72 sed -i '1iSpX, SpY, IDX, IDY, IMG, CHNumberX, CHNumberY, Score, LengthX, LengthY' $OUT
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
73
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
74 rm index.csv.temp
7fdf47a0bae8 Uploaded
alvarofaure
parents:
diff changeset
75