On Mon, Oct 08, 2012 at 03:00:30PM +0200, David van der Spoel wrote:
> On 2012-10-08 14:45, David van der Spoel wrote:
> > On 2012-10-08 10:55, David van der Spoel wrote:
> >> Hi,
> >>
> > To answer my own question: I now installed trunk, the development
> > version. The gaussian files now work fine, but the fulvene.pdb file
> > still gives problems:

Yes that is also what I observed in previous mail. Are you not
subscribed to the list?

> >
> > % babel --version
> > No output file or format spec!
> > Open Babel 2.3.2 -- Oct  8 2012 -- 14:31:48
> >
> > % babel -ipdb fulvene.pdb -oinchi ---errorlevel 2
> > ==============================
> > *** Open Babel Information  in NewPerceiveKekuleBonds
> >     Kekulize: Huckel rule not satisfied for molecule fulvene.pdb
> >
> > ==============================
> > *** Open Babel Information  in NewPerceiveKekuleBonds
> >     Kekulize: Huckel rule not satisfied for molecule fulvene.pdb
> > Kekulize: Cannot get an even number of electron for molecule fulvene.pdb
> >
> > InChI=1S/C6H8/c1-6-4-2-3-5-6/h2-4H,5H2,1H3
> >
> > It adds TWO H for InChi output, not for SDF output, but it only produces
> > two double bonds (out of three). I guess these are related?

Yes, they are. It is bond order perception fail (together with
kekulization). More about it below.

> > Thanks for reading,
> >
> Sorry for spamming but I have to correct this, the gaussian files 
> produce the right inchi but not the correct bondorder!
> 
> % wget http://folding.bmc.uu.se/fulvene-g4.log.gz
> % babel -ig09 fulvene-g4.log.gz -osdf fulvene.sdf
> % open fulvene.sdf (in Avogadro)
> Look at the bonds.

Actually tetracene also is failing to properly set bond orders
in one of the cases. It looks like a kekulization algorithm
fails to find optimal solution or some rings are not found and
marked approprietly.

As for the bond perception fail, the issue is that bond order
perception trigers kekulization which in turn relies on bond
orders to select some parameters. So it is a bit of chicken and
egg problem.

I have a patch which tries to fix it by adding extra logic in
kekulization to make sure that it is working also in case when
bond perception has not finished, but it breaks canonstable test
in such a way that I have to ask if those tests were correct to
begin with.

For example this one:
4: ref = CCN(CCNc1ccc2c3c1c(=O)c1c(n3NN2)ccc(c1)[N+](=O)[O-])CC
4: can = CCN(CCNc1ccc2c3c1c(=O)c1cc(ccc1n3[nH][nH]2)[N+](=O)[O-])CC

First of all I'm not a SMILES expert, but I think there is a
confusion about which rings are aromatic. In contrast to what
reference SMILES suggest I think the 5member ring with 3
nitrogens might be aromatic since in at least one resonance
structure it has 10 pi electrons (6 from Ns and 4 from Cs which
are part of pi system). Also the middle ringe has some resonance
structures where Huckels law (4n+2) holds and some where it
doesn't. So the quiestion is, which of these SMILES is correct
one or maybe both of them are wrong?

Also is fulvene aromatic? The cycle has 6 electrons if those
from adjasent double bond count.

Below is the patch that seems to fix remaining original issues.


Reinis

diff --git a/src/kekulize.cpp b/src/kekulize.cpp
index 283c7bf..4e9c358 100644
--- a/src/kekulize.cpp
+++ b/src/kekulize.cpp
@@ -360,6 +360,33 @@ namespace OpenBabel
                 electron[j] = 0;
               }
             }
+            // Also check if there is a potential double bond
+            if (!bond->IsInRing()
+                && bond->GetNbrAtom(atom)->GetHyb() < 3
+                && bond->GetNbrAtom(atom)->IsCarbon()) {
+              bool nbrHasDouble = false;
+              std::vector<OBBond*>::iterator bit;
+              OBBond* nb;
+              for (nb = bond->GetNbrAtom(atom)->BeginBond(bit); nb; nb = 
bond->GetNbrAtom(atom)->NextBond(bit)) {
+                if (nb->GetBO() > 1) {
+                  nbrHasDouble = true;
+                }
+              }
+              if (!nbrHasDouble) {
+                OBAtom *atom2 = bond->GetNbrAtom(atom);
+                int fcharge = atom->GetFormalCharge();
+                int fcharge2 = atom2->GetFormalCharge();
+                if(atom->IsNitrogen() && atom2->IsOxygen()
+                   && fcharge == 0 && fcharge2 == 0) { //n=O to [n+][O-]
+                  atom->SetFormalCharge(1);
+                  atom2->SetFormalCharge(-1);
+                  bond->SetKSingle();
+                  bond->SetBO(1);
+                } else {
+                  electron[j] = 0;
+                }
+              }
+            }
           }
           // count the number of electrons
           if (!doubleBondInRing) {

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
OpenBabel-discuss mailing list
OpenBabel-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-discuss

Reply via email to