-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_cartoon.sh
executable file
·111 lines (96 loc) · 3.65 KB
/
make_cartoon.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh
#
# make_cartoon.sh - make SVG and PNG cartoon for a PDB file
#
# Usage: make_cartoon.sh pdbfile
#
# Runs ptgraph2.py, Dunnart and svg2png.sh to make the .svg and .png
# versions of the cartoon for given PDB file. The PDB file can be
# in any directory, but output is in cwd.
#
#
# $Id: make_cartoon.sh 4290 2012-05-16 02:06:14Z astivala $
#
#PTGRAPH2_OPTIONS="-r35 -t dssp -k purple -l crossing:black,red,green,navy,blue -b sequential -j -e auto -f auto -o gradient -p ddomain"
#PTGRAPH2_OPTIONS="-r35 -t dssp -k purple -l crossing:black,red,green,navy,blue -b sequential -j -e auto -f auto -o gradient -p cath:/local/munk/proorigami-test/cath/CathDomall.v3.3.0"
PTGRAPH2_OPTIONS="-r35 -t dssp -k purple -l crossing:black,red,green,navy,blue -b sequential -j -e auto -f auto -o gradient -p none -v"
#DUNNART=$HOME/dunnart/trunk/dunnart
DUNNART=/local/munk/proorigami-prod/dunnart/trunk/dunnart
# time in seconds to limit Dunnart CPU time to before assuming failure
DUNNART_CPUTIME_LIMIT=150
DUNNART_OPTS="-b -y -w4 -z100"
# this uses the null video device driver in SDL
export SDL_VIDEODRIVER=dummy
if [ $# -ne 1 ]; then
echo "usage $0 pdbfile" >&2
exit 1
fi
pdbfile=$1
tmpfile=/var/tmp/mkptg$$
ptgraph2.py $PTGRAPH2_OPTIONS $pdbfile > $tmpfile
if [ $? -ne 0 ]; then
echo "ptgraph2.py failed"
rm $tmpfile
exit 1
fi
filelist=`grep 'writing file' $tmpfile | cut -d' ' -f3`
dunnart_failed=0
for svgfile in $filelist ; do
(ulimit -t ${DUNNART_CPUTIME_LIMIT} ; $DUNNART $DUNNART_OPTS ${svgfile} ) > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo dunnart failed on $svgfile >&2
dunnart_failed=1
else
cp $svgfile ${svgfile}.orig
fi
done
restore_list=""
for svgfile in $filelist ; do
if [ $dunnart_failed -eq 0 ]; then
overlapcount=`grep count $svgfile | sed 's/.*count="\([0-9]*\).*/\1/'`
echo "overlap count for $svgfile (default) is $overlapcount"
else
overlapcount=999999 # force nonzero overlap count for while loop
fi
orig_overlapcount=$overlapcount
# rerun with progressively larger gap sizes until we get no overlaps
# or gap size is 'too big'
gapsize=56 # starts at default 55
while [ $overlapcount -gt 0 -a $gapsize -le 80 ];
do
ptgraph2.py $PTGRAPH2_OPTIONS -g $gapsize $pdbfile > $tmpfile
if [ $? -ne 0 ]; then
echo "ptgraph2.py failed"
rm $tmpfile
exit 9
fi
(ulimit -t ${DUNNART_CPUTIME_LIMIT} ; $DUNNART $DUNNART_OPTS ${svgfile} ) > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo dunnart failed on $svgfile >&2
overlapcount=999999 # force 'no improvement' case
else
overlapcount=`grep count $svgfile | sed 's/.*count="\([0-9]*\).*/\1/'`
echo "overlap count for $svgfile (-g $gapsize) is $overlapcount"
if [ ! -f ${svgfile}.orig ]; then
cp $svgfile ${svgfile}.orig
orig_overlapcount=$overlapcount
echo "overlap count for $svgfile (first success at -g $gapsize) is $overlapcount"
fi
fi
gapsize=`expr $gapsize + 1`
done
# if there was no improvement, just use default gapsize version
if [ $overlapcount -ge $orig_overlapcount ]; then
old_overlapcount=`grep count ${svgfile}.orig | sed 's/.*count="\([0-9]*\).*/\1/'`
echo "going back to to default gapsize (overlap count $old_overlapcount) for $svgfile"
restore_list="${restore_list} ${svgfile}"
fi
done
for restore_file in $restore_list ; do
cp ${restore_file}.orig ${restore_file}
done
for svgfile in $filelist ; do
svg2png.sh $svgfile
rm ${svgfile}.orig
done
rm $tmpfile