comparison chromeister/bin/index_chromeister.sh @ 1:3d1fbde7e0cc draft default tip

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