source: util/src/SortByRings.sh.in@ a3ffb44

Last change on this file since a3ffb44 was c1fb07, checked in by Frederik Heber <heber@…>, 17 years ago

BUGFIX: SortbyRings now works with current script convertHessian.

  • Property mode set to 100755
File size: 1.7 KB
Line 
1#!@SHELL@
2#
3# Uses molecuilder's DFS to find rings and creates map for sorting molecules first by atom number, then by number of rings and finally sorts the lines of the fail accordingly
4
5exec_prefix="@prefix@"
6database="@bindir@"
7MOLECUILDER="@bindir@/molecuilder"
8
9if [ -z $1 ]; then
10 echo "Usage: $0 <file>"
11 exit 1
12else
13 file=$1
14fi
15
16echo "Creating mapping ... "
17echo -e "#Nr.\tMolecule\tNo.rings\tMinLength\tMaxLength\tAtoms" >MoleculesRing.dat
18nr=1
19for i in *.xyz; do
20 mol=${i/.xyz/}
21 atoms=`head -n 1 $i | sed -e "s#\([0-9]*\).*#\1#"`
22 echo "Current molecule: ${mol}"
23 echo -e -n "$nr\t$mol\t" >>MoleculesRing.dat
24 rings=(`${MOLECUILDER} ${mol}/${mol}.conf -e ${database} -c 5. 5. 5. -D 2. 2>/dev/null | grep -E "Found ring contains" | awk -F" of " {'print $2'} | awk -F"." {'print $1'}`)
25 i=0
26 Max=0
27 Min=1000
28 while [ $i -lt ${#rings[@]} ]; do
29 if [ $Max -lt ${rings[$i]} ]; then
30 Max=${rings[$i]}
31 fi
32 if [ $Min -gt ${rings[$i]} ]; then
33 Min=${rings[$i]}
34 fi
35 let i=$i+1
36 done
37 if [ ! $Max -eq $Min ]; then # there were no rings at all
38 Min=0
39 fi
40 echo -e -n "${#rings[@]}\t$Max\t$Min\t$atoms\n" >>MoleculesRing.dat
41 let nr=$nr+1
42done
43sort -g -t $'\t' +2 -3 +3n -4 +4n -5 +5n -6 MoleculesRing.dat > MoleculesRingSorted.dat
44
45# now parsing file
46rm -f ${file}_sorted
47OLDIFS=$IFS
48IFS='
49'
50lines=(`cat <$file`)
51map=(`cat <MoleculesRingSorted.dat`)
52i=1
53echo "${lines[0]}" >>${file}_sorted
54while [ $i -lt ${#lines[@]} ]; do
55 #echo "lines: ${lines[$i]}"
56 #echo "Map: ${map[$i]} -> $i"
57 let j=`echo ${map[$i]} | awk -F" " {'print $1'}`
58 name=`echo "${lines[$j]}" | awk -F" " {'print $2'}`
59 echo -e -n "$i\t$name\t" >> ${file}_sorted
60 echo "${lines[$j]}" | sed -e "s#[0-9]*\t[0-9a-zA-Z,_\-]*\t##" >>${file}_sorted
61 let i=$i+1
62done
63IFS=$OLDIFS
64
65
66
67exit 0
Note: See TracBrowser for help on using the repository browser.