User 870ab5b546
02-09-2008 17:00:24
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.
ChemAxon 990acf0dec
04-09-2008 13:52:36
Hi Bob,
We will fix this bug soon. Thank you again for the bug report.
Best regards,
Akos
User 870ab5b546
10-03-2010 21:05:44
This bug remains in JChem 5.3.1.
ChemAxon 990acf0dec
11-03-2010 10:45:30
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
User 870ab5b546
11-03-2010 14:12:43
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.
ChemAxon 7c2d26e5cf
19-03-2010 17:38:31
Thanks for sharing your workaround.
ChemAxon 990acf0dec
24-03-2010 16:35:48
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
User 870ab5b546
24-05-2010 01:12:25
Has this bug been fixed in Marvin 5.3.3?
ChemAxon e500b51457
24-05-2010 08:14:22
Hi Bob,
We have a long weekend due to our national holiday here, but Ákos will reply you soon.
Regards,
Erika.
User 851ac690a0
25-05-2010 11:22:36
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