void OBAtomTyper::AssignImplicitValence(OBMol &mol) { // FF Make sure that valence has not been perceived if(mol.HasImplicitValencePerceived()) return; if (!_init) Init(); mol.SetImplicitValencePerceived(); obErrorLog.ThrowError(__FUNCTION__, "Ran OpenBabel::AssignImplicitValence", obAuditMsg); // FF Ensure that the aromatic typer will not be called int oldflags = mol.GetFlags(); // save the current state flags mol.SetAromaticPerceived(); // and set the aromatic perceived flag on OBAtom *atom; vector<OBAtom*>::iterator k; for (atom = mol.BeginAtom(k);atom;atom = mol.NextAtom(k)) atom->SetImplicitValence(atom->GetValence()); vector<vector<int> >::iterator j; vector<pair<OBSmartsPattern*,int> >::iterator i; for (i = _vimpval.begin();i != _vimpval.end();++i) if (i->first->Match(mol)) { _mlist = i->first->GetMapList(); for (j = _mlist.begin();j != _mlist.end();++j) mol.GetAtom((*j)[0])->SetImplicitValence(i->second); } if (!mol.HasAromaticCorrected()) CorrectAromaticNitrogens(mol); for (atom = mol.BeginAtom(k);atom;atom = mol.NextAtom(k)) { if (atom->GetImplicitValence() < atom->GetValence()) atom->SetImplicitValence(atom->GetValence()); } // FF Come back to the initial flags mol.SetFlags(oldflags); return; }