#!@SHELL@ # # 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 exec_prefix="@prefix@" database="@bindir@" MOLECUILDER="@bindir@/molecuilder" if [ -z $1 ]; then echo "Usage: $0 " exit 1 else file=$1 fi echo "Creating mapping ... " echo -e "#Nr.\tMolecule\tNo.rings\tMinLength\tMaxLength\tAtoms" >MoleculesRing.dat nr=1 for i in *.xyz; do mol=${i/.xyz/} atoms=`head -n 1 $i | sed -e "s#\([0-9]*\).*#\1#"` echo "Current molecule: ${mol}" echo -e -n "$nr\t$mol\t" >>MoleculesRing.dat 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'}`) i=0 Max=0 Min=1000 while [ $i -lt ${#rings[@]} ]; do if [ $Max -lt ${rings[$i]} ]; then Max=${rings[$i]} fi if [ $Min -gt ${rings[$i]} ]; then Min=${rings[$i]} fi let i=$i+1 done if [ ! $Max -eq $Min ]; then # there were no rings at all Min=0 fi echo -e -n "${#rings[@]}\t$Max\t$Min\t$atoms\n" >>MoleculesRing.dat let nr=$nr+1 done sort -g -t $'\t' +2 -3 +3n -4 +4n -5 +5n -6 MoleculesRing.dat > MoleculesRingSorted.dat # now parsing file rm -f ${file}_sorted OLDIFS=$IFS IFS=' ' lines=(`cat <$file`) map=(`cat $i" name=`echo "${lines[$j]}" | awk -F" " {'print $1'}` echo -e -n "$name\t$i\t" >> ${file}_sorted echo "${lines[$j]}" | sed -e "s#[0-9a-zA-Z,_\-]*\t[0-9]*\t##" >>${file}_sorted let i=$i+1 done IFS=$OLDIFS exit 0