Dear Noel,
thanks for your fast and helpful answer. I still have an unanswered problem:
I'm looking for a method that e.g. for the following two molecules:
I: C(=O)3
II: O=C(OH)2
recognizes the first molecule with 6 bonds per carbon as "inconsistent" and
the second as "consistent".
So meanwhile I implemented a method getTypicalValence() below. This seems
to work, but do I understand from your answer that I'm looking for
something that I shouldnt be looking for ?
regards,
Rafel
unsigned int getTypicalValence(unsigned int atomNum) {
OpenBabel::OBMol mol;
mol.BeginModify();
mol.NewAtom(1) -> SetAtomicNum(atomNum);
mol.AddHydrogens();
mol.EndModify();
return mol.GetAtomById(1)->GetValence();
}
On Thu, Nov 7, 2013 at 10:43 AM, Noel O'Boyle <baoille...@gmail.com> wrote:
> AFAIK, all OBMol's are self-consistent.
>
> I'm guessing this is not the answer you are looking for. Perhaps the
> following is (taken from my notes at
> https://gist.github.com/baoilleach/4232459):
>
> """
> In the Open Babel world, the "valence" methods of an atom refer to the
> number of bonds, rather than the sum of BOs (which is actual valence).
>
> GetValence() -> Num explicit bonds
> GetImplicitValence() -> Num explicit bonds plus num implicit bonds
> (i.e. total number of bonds) (_impval property on OBAtom)
> GetHvyAtomValence() -> Num explicit bonds to non-H atoms
>
> To find the number of implicit Hs, GetImplicitValence() - GetValence()
>
> BOSum() -> The sum of the BOs of explicit bonds (otherwise known as
> ExplicitValence)
>
> To find the actual valence: BOSum() + GetImplicitHydrogenCount()
> """
>
> - Noel
>
> On 7 November 2013 09:23, Rafel Israels <rafelisra...@googlemail.com>
> wrote:
> > Hello,
> >
> > what would be the correct method to check the consistency of bonds in a
> > molecule ?
> >
> > My first try (below) is wrong: e.g. Aspirin fails this test and if I
> > understand correctly the reason seems that I compare total number of
> bonds
> > (i.e. counting double bonds twice) with maximum/expected number of
> > neighbors, which (for me unexpected but probably correct) considers
> > hybridization and equals 3 for SP2-carbons ?
> >
> > Is there something like atom->GetImplicitBOSum() and/or what would be the
> > correct implementation to check basic chemistry rules ?
> >
> > regards,
> >
> > Rafel
> >
> >
> > FOR_ATOMS_OF_MOL(atom, obMol)
> > if (atom->BOSum() > atom->GetImplicitValence())
> > return false;
> > return true;
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > November Webinars for C, C++, Fortran Developers
> > Accelerate application performance with scalable programming models.
> Explore
> > techniques for threading, error checking, porting, and tuning. Get the
> most
> > from the latest Intel processors and coprocessors. See abstracts and
> > register
> >
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> > _______________________________________________
> > OpenBabel-discuss mailing list
> > OpenBabel-discuss@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/openbabel-discuss
> >
>
------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss