Skip to content

CheckIfAromaticWithoutAssigningAromaticity

dstoeckel edited this page Mar 16, 2015 · 2 revisions

How can I check aromaticity without actually assigning aromaticity?

Use the BALL's AromaticityProcessor and set its option OVERWRITE_BOND_ORDERS to false.

#include <BALL/QSAR/ringPerceptionProcessor.h>
#include <BALL/QSAR/aromaticityProcessor.h>
#include <BALL/FORMAT/MOL2File.h>
#include <BALL/KERNEL/system.h>
#include <BALL/KERNEL/atom.h>

using namespace BALL;

...

// read a mol2 file
System sys;
MOL2File mol_in(argv[1], std::ios::in);
mol_in >> sys;

// compute aromatic bonds for the original system
vector<vector<Atom*> > rings;
RingPerceptionProcessor rpp;
rpp.calculateSSSR(rings, sys);

// set the aromatic rings	
AromaticityProcessor ap;
ap.options.setBool(AromaticityProcessor::Option::OVERWRITE_BOND_ORDERS, false); 
ap.aromatize(rings,sys);

// check, if there is an aromatic bond   
AtomIterator at_it = sys.beginAtom();
for ( ; at_it != sys.endAtom(); ++at_it)
{
   Atom::BondIterator b_it = at_it->beginBond(); 
   for ( ; b_it != at_it->endBond(); ++b_it)
   {
      if (b_it->getProperty("IsAromatic").getBool())
      {
         // do something more interesting than 
         std::cout << b_it->getOrder () << " is aromatic." << std::endl;
      }
   }
}
Clone this wiki locally