#! /bin/bash
# Moves to another directory all SMILES containing a carbon atom which
# appears not to be tetravalent. These SMILES should be checked to see if
# they are organometallic compounds, they contain bonds with wrong bond orders
# or are genuine radicals (quite infrequent).

[ -d ../working ] || mkdir ../working
for i in `ls *.smi` ; do
   dato=`cat $i | grep [[]C[]]`
   if [ "$dato" != "" ]; then
     mv $i ../working
   else  
     dato=`cat $i | grep [[]CH[]]`
     if [ "$dato" != "" ]; then
       mv $i ../working
     else
       dato=`cat $i | grep [[]CH2[]]`
       if [ "$dato" != "" ]; then
         mv $i ../working
       else
         dato=`cat $i | grep [[]CH3[]]`
         if [ "$dato" != "" ]; then
           mv $i ../working
         fi
       fi
     fi
   fi
done
