Technical Support Forum Index
Technical Support Forum
Access ChemAxon scientists and developers here. For registration and login issues contact website support.

Support Ticket System is replacing forum

This forum was converted into a searchable archive. You cannot add posts here any more. For support please use our new Ticket System.

Create your first ticket
valence error error
To watch this topic for replies  Register (enables digests) or give email address:
This topic is locked: you cannot edit posts or make replies.
Display posts from previous:   
    View previous topic :: View next topic    
Author Message
Bob

Joined: 15 Jun 2004
Posts: 2629

View user's profile

Back to top
Link to postPosted: Tue Sep 02, 2008 6:00 pmPost subject: valence error error Reply with quote

In the following compound, Marvin should realize the N has a valence error, because it has a total electron count of 9 electrons, but it doesn't.

Code:
<?xml version="1.0" ?>
<MDocument>
  <MChemicalStruct>
    <molecule molID="m1">
      <atomArray
          atomID="a1 a2 a3 a4 a5 a6"
          elementType="C Br N H H H"
          radical="0 monovalent monovalent 0 0 0"
          x2="-8.285764546394347 -0.8745140957832334 -6.446805090904235 -5.805139036178589 -6.286388964653015 -3.976389021873474"
          y2="6.70152818163236 6.701527943213781 7.048611198862394 8.92256868382295 4.495069866379103 6.516319637497267"
          />
      <bondArray>
        <bond atomRefs2="a1 a3" order="1" />
        <bond atomRefs2="a3 a4" order="1" />
        <bond atomRefs2="a3 a5" order="1" />
        <bond atomRefs2="a3 a6" order="1" />
      </bondArray>
    </molecule>
  </MChemicalStruct>
</MDocument>


Likewise, the C atom in this compound:

Code:
<?xml version="1.0" ?>
<MDocument>
  <MChemicalStruct>
    <molecule molID="m1">
      <atomArray
          atomID="a1 a2 a3 a4 a5"
          elementType="C H H H H"
          formalCharge="-1 0 0 0 0"
          radical="monovalent 0 0 0 0"
          x2="-6.746597763299942 -5.233315241299588 -8.286597763299941 -7.145179092757823 -6.746597763299942"
          y2="8.000590329368908 8.28620547008846 8.000590329368908 9.488116101854073 6.460590329368908"
          />
      <bondArray>
        <bond atomRefs2="a1 a2" order="1" />
        <bond atomRefs2="a1 a3" order="1" />
        <bond atomRefs2="a1 a4" order="1" />
        <bond atomRefs2="a1 a5" order="1" />
      </bondArray>
    </molecule>
  </MChemicalStruct>
</MDocument>


This error occurs in Marvin 5.1.1 as well as earlier versions back to at least Marvin 4.1.14.
Tamas
ChemAxon personnel
Joined: 21 May 2004
Posts: 2171

View user's profile

Back to top
Link to postPosted: Wed Sep 03, 2008 11:07 amPost subject: Reply with quote

We will check it.
Akos
ChemAxon personnel
Joined: 09 Mar 2007
Posts: 864

View user's profile

Back to top
Link to postPosted: Thu Sep 04, 2008 2:52 pmPost subject: valence error on radicals Reply with quote

Hi Bob,

We will fix this bug soon. Thank you again for the bug report.

Best regards,

Akos
Bob

Joined: 15 Jun 2004
Posts: 2629

View user's profile

Back to top
Link to postPosted: Wed Mar 10, 2010 10:05 pmPost subject: Reply with quote

This bug remains in JChem 5.3.1.

Akos
ChemAxon personnel
Joined: 09 Mar 2007
Posts: 864

View user's profile

Back to top
Link to postPosted: Thu Mar 11, 2010 11:45 amPost subject: Reply with quote

Yes, because it requires a significant change in the valence check algorithm, for which we had no capacity yet :(

We will check if a workaround is possible until that.

Best regards,

Akos

Bob

Joined: 15 Jun 2004
Posts: 2629

View user's profile

Back to top
Link to postPosted: Thu Mar 11, 2010 3:12 pmPost subject: Reply with quote

Oh, we've already had a workaround for years.  I was hoping it was no longer necessary.  Here's our code:

    public static final boolean INCLUDE_EXPLICIT_H = true;
    public static final boolean USE_BOND_ORDERS = false;

    public static void checkValence(Molecule mol) throws ValenceException {
        final String SELF = "ChemUtils.checkValence: ";
        // check for valence errors
        mol.valenceCheck();
        final String VALENCE_ERROR = "At least one of the atoms in your response "
                + "has an invalid valence.  If you don't see an atom underlined "
                + "in red, look for an atom that violates the octet rule, or "
                + "try expanding your shortcut groups.  ";
        for (int atomNum = 0; atomNum < mol.getAtomCount(); atomNum++) {
            final MolAtom atom = mol.getAtom(atomNum);
            if (atom.hasValenceError()) {
                throw new ValenceException(VALENCE_ERROR);
            } // if valence error
            // workaround for valence check bug for atoms with radical flag
            // such as 9-electron radicals
            int unsharedElecCt = mol.getLonePairCount(atomNum);
            final int radState = atom.getRadical();
            switch (radState) {
                case MolAtom.RAD1:
                    unsharedElecCt += 1; break;
                case MolAtom.RAD2:
                case MolAtom.RAD2_SINGLET:
                case MolAtom.RAD2_TRIPLET:
                    unsharedElecCt += 2; break;
                case MolAtom.RAD3:
                case MolAtom.RAD3_DOUBLET:
                case MolAtom.RAD3_QUARTET:
                    unsharedElecCt += 3; break;
                default: continue;
            } // radical state
            final int totalElecCt = unsharedElecCt
                    + atom.twicesumbonds(INCLUDE_EXPLICIT_H, USE_BOND_ORDERS)
                    + atom.getImplicitHcount() * 2;
            final int maxOuter = getMaxOuterElectrons(atom);
            if (totalElecCt > maxOuter) {
                throw new ValenceException(VALENCE_ERROR);
            } // if too many electrons
        } // for each atom
        // check for pentavalent N, as in nitro group
        final String PENTACOORD_N = "[$(*=,#[NX3]=,#*),$(*:n(=,#*):*),$(*=,#N#*)]";
        try {
            final Molecule pentacoordN = MolImporter.importMol(PENTACOORD_N);
            if (MolFunctions.containsSubstruct(mol, pentacoordN)) {
                throw new ValenceException(VALENCE_ERROR);
            } // if molecule contains pentavalent N
        } catch (MolFormatException e) { // unlikely
            ; // do nothing
        } // try
    } // checkValence(Molecule)

    public static int getMaxOuterElectrons(MolAtom atom) {
        return getMaxOuterElectrons(atom.getAtno());
    } // getMaxOuterElectrons(MolAtom)

    public static int getMaxOuterElectrons(int atno) {
        final int row = PeriodicSystem.getRow(atno);
        final int column = PeriodicSystem.getColumn(atno);
        if (row == 0) return 0; // unknown element
        else if (row == 1) return 2;
        else if (row == 2) return 8;
        else if (row == 3 || column >= 13) return 12; // hypervalent Si, S, etc.
        else if (row == 4 || row == 5 || column >= 4) return 18;
        else return 32;
    } // getMaxOuterElectrons(int)

MolFunctions.containsSubstruct() does a standard JChem substructure search.

Tamas
ChemAxon personnel
Joined: 21 May 2004
Posts: 2171

View user's profile

Back to top
Link to postPosted: Fri Mar 19, 2010 6:38 pmPost subject: Reply with quote

Thanks for sharing your workaround.

Akos
ChemAxon personnel
Joined: 09 Mar 2007
Posts: 864

View user's profile

Back to top
Link to postPosted: Wed Mar 24, 2010 5:35 pmPost subject: Reply with quote

Hi Bob,

We also found a workaround (but thanks for yours again), but we cannot push this fix into 5.3.2, because it is already in testing phase. The patch release coming next month will contain it though.

Best regards,

Akos

Bob

Joined: 15 Jun 2004
Posts: 2629

View user's profile

Back to top
Link to postPosted: Mon May 24, 2010 2:12 amPost subject: Reply with quote

Has this bug been fixed in Marvin 5.3.3?

Erika
ChemAxon personnel
Joined: 12 Oct 2005
Posts: 293

View user's profile

Back to top
Link to postPosted: Mon May 24, 2010 9:14 amPost subject: Reply with quote

Hi Bob,

We have a long weekend due to our national holiday here, but Ákos will reply you soon.

Regards,
Erika.

Jozsef
ChemAxon personnel
Joined: 25 May 2004
Posts: 568

View user's profile

Back to top
Link to postPosted: Tue May 25, 2010 12:22 pmPost subject: Reply with quote

Hi,

 

This fix is not included in the 5.3.3 version.

I fixed this bug. I think it will be available in the next patch release.

 

Jozsi

This topic is locked: you cannot edit posts or make replies.
Page 1 of 1


To watch this topic for replies   Register (enables digests) or give email address  
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum