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
|
#! /bin/bash
# This script reads all *.smi files in the current folder,
# separate each chain in their component moieties and display them in the
# screen, to check if the SMILES may be simplified. This is intended for
# structures with Z' > 1 and possibly repeated molecules. The user may
# choose between keeping only the first moiety (pressing "1"), select which
# moieties should be retained (pressing "k" and afterwards the identifiers
# of the chosen moieties and just ENTER to finish) or "n" to keep the whole
# SMILES unchanged. The modified SMILES are stored in the "passed" folder
# and the unchanged ones are stored in the "partial" folder.
[ -d passed ] || mkdir passed
[ -d partial ] || mkdir partial
declare -a moiety
for i in `ls *.smi` ; do
tmp=`cat $i | cut -f1`
key=`cat $i | cut -f2`
res="${tmp//[^.]}"
puntos="${#res}"
((puntos++))
for (( j=1; j<=$puntos; j++ )) do
moiety[$j]=`echo $tmp | cut -d"." -f$j`
done
echo $key
for (( j=1; j<=$puntos; j++ )) do
echo -n $j"..."
echo ${moiety[$j]}
done
echo -n '1=just molecule 1, k=keep several moieties, n=leave unchanged '
read answer
if [ "$answer" == 1 ]; then
echo -n ${moiety[1]} > passed/$i
echo -e "\t"$key >> passed/$i
rm -f $i
elif [ "$answer" == k ]; then
echo "Enter the number of the moieties to be kept, pressing [ENTER]"
echo " after each one. Press just [ENTER] to finish."
read mm
total=""
while [ "$mm" != "" ]; do
total="$total${moiety[$mm]}"
read mm
if [ "$mm" != "" ]; then
total="$total."
fi
done
echo -n $total > passed/$i
echo -e "\t"$key >> passed/$i
rm -f $i
else mv $i partial
fi
done
|