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
|
#! /bin/bash
# This script creates SMILES chains for all cif files existing in the present
# folder that are listed in the file ciflist. The results are stored in
# the smi folder.
# SMILES are computed without and with the "-aB" option of Open Babel.
# If both outputs are not identical, the user has the choice to select one
# of them.
# A logfile is created (normally, is not too useful).
[ -d ../smi ] || mkdir ../smi
for i in `cat ciflist` ; do
nombre=`echo $i | cut -c-7`
echo $nombre
echo $nombre >> smilog
nobondcif=`babel --title $nombre $nombre.cif -o smi 2>> smilog`
nobondcif=`echo $nobondcif | cut -d' ' -f1`
# The following lines try to bootstrap a common Open Babel error that appears
# when a line starting with an underscore character appears inside a text
# field delimited with semicolons. Apparently Open Babel thinks it is a
# CIF tag. When it is detected, the user is invited to edit the CIF file to
# remove such line and the SMILES is computed again.
echo $nobondcif | grep olon && {
vi $nombre.cif
nobondcif=`babel --title $nombre $nombre.cif -o smi 2>> smilog`
nobondcif=`echo $nobondcif | cut -d' ' -f1`
}
# ....
bondcif=`babel -aB --title $nombre $nombre.cif -o smi 2>> smilog`
bondcif=`echo $bondcif | cut -d' ' -f1`
if [ "$nobondcif" == "$bondcif" ]; then
echo -n $nobondcif > ../smi/$nombre.smi
echo -e "\t"$nombre >> ../smi/$nombre.smi
else
echo $nobondcif
echo $bondcif
echo 'Keep the added bonds? '
read answer
if [ "$answer" != n ]; then
echo -n $bondcif > ../smi/$nombre.smi
echo -e "\t"$nombre >> ../smi/$nombre.smi
else
echo -n $nobondcif > ../smi/$nombre.smi
echo -e "\t"$nombre >> ../smi/$nombre.smi
fi
fi
done
|