-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmummer2ggplot
executable file
·50 lines (42 loc) · 1.13 KB
/
mummer2ggplot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -e
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd`
popd > /dev/null
if [[ $# -lt 2 ]]; then
echo "usage: mummer2ggplot inputprefix outputdir"
exit 1
fi
inputprefix=$1
outputdir=$2
# make coords
cat ${inputprefix}.[fr]plot \
| awk '/^[1-9]/' \
| awk '
NR%2==1 {a=$1;b=$2}
NR%2==0 {if($2>b) {
print a,b,$1,$2,$3,"+"
}else{
print a,b,$1,$2,$3,"-"
}}' \
| sort -n \
> ${inputprefix}.ggplot
# make ticks
sed ':a;N;$!ba;s/\\\n//g' ${inputprefix}.gp \
| awk '/^set ytics/' \
| sed 's/set ytics ( //' \
| sed 's/ )//' \
| sed 's/, /\n/g' \
| sed 's/ /,/' \
| awk '{gsub(/"/, "", $1); print $1,$2;}' \
> ${inputprefix}.yticks
sed ':a;N;$!ba;s/\\\n//g' ${inputprefix}.gp \
| awk '/^set xtics/' \
| sed 's/set xtics rotate ( //' \
| sed 's/ )//' \
| sed 's/, /\n/g' \
| sed 's/ /,/' \
| awk '{gsub(/"/, "", $1); print $1,$2;}' \
> ${inputprefix}.xticks
Rscript ${SCRIPTPATH}/mummerplot.R ${outputdir}/$(basename ${inputprefix}) \
${inputprefix}.ggplot ${inputprefix}.xticks ${inputprefix}.yticks