Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 06, 2014
@johnmay johnmay Triplet = 2 unpaired electrons, not currently represented.
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
658546d
@johnmay johnmay Unpaired electrons affect hydrogen count.
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
36e2bcc
View
11 storage/io/src/main/java/org/openscience/cdk/io/MDLV2000Reader.java
@@ -465,7 +465,9 @@ else if (!hasZ) {
if (valence < 0) {
hasQueryBonds = true; // also counts aromatic bond as query
} else {
- applyMDLValenceModel(outputContainer.getAtom(i), valence);
+ applyMDLValenceModel(outputContainer.getAtom(i),
+ valence,
+ outputContainer.getConnectedSingleElectronsCount(outputContainer.getAtom(i)));
}
}
@@ -509,10 +511,11 @@ else if (!hasZ) {
* @param atom the atom to apply the model to
* @param explicitValence the explicit valence (bond order sum)
*/
- private void applyMDLValenceModel(IAtom atom, int explicitValence) {
+ private void applyMDLValenceModel(IAtom atom, int explicitValence, int unpaired) {
+
if (atom.getValency() != null) {
if (atom.getValency() >= explicitValence)
- atom.setImplicitHydrogenCount(atom.getValency() - explicitValence);
+ atom.setImplicitHydrogenCount(atom.getValency() - explicitValence - unpaired);
else
atom.setImplicitHydrogenCount(0);
}
@@ -532,7 +535,7 @@ private void applyMDLValenceModel(IAtom atom, int explicitValence) {
}
else {
atom.setValency(implicitValence);
- atom.setImplicitHydrogenCount(implicitValence - explicitValence);
+ atom.setImplicitHydrogenCount(implicitValence - explicitValence - unpaired);
}
}
}
View
2  storage/io/src/main/java/org/openscience/cdk/io/MDLV2000Writer.java
@@ -112,7 +112,7 @@
NONE(0, 0),
SINGLET(2, 1),
DOUBLET(1, 2),
- TRIPLET(3, 3);
+ TRIPLET(3, 2);
// the radical SDF value
private final int value;
View
13 storage/io/src/main/resources/org/openscience/cdk/io/structure-with-radical.mol
@@ -0,0 +1,13 @@
+
+ Mrv0541 03281420122D
+
+ 4 3 0 0 0 0 999 V2000
+ -1.7900 4.4564 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
+ -2.2025 3.7420 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -1.7900 3.0275 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ -3.0275 3.7420 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
+ 1 2 1 0 0 0 0
+ 2 3 1 0 0 0 0
+ 2 4 2 0 0 0 0
+M RAD 1 1 2
+M END
View
9 storage/io/src/test/java/org/openscience/cdk/io/MDLV2000ReaderTest.java
@@ -1083,7 +1083,7 @@ public void testSingleTripletRadical() throws Exception {
molecule = reader.read(molecule);
reader.close();
- assertThat(molecule.getConnectedSingleElectronsCount(molecule.getAtom(1)), is(3));
+ assertThat(molecule.getConnectedSingleElectronsCount(molecule.getAtom(1)), is(2));
}
@Test
@@ -1333,6 +1333,13 @@ public void testMultipleRadicals() throws Exception {
is(MDLV2000Reader.CTabVersion.UNSPECIFIED));
}
+ @Test public void radicalsReflectedInHydrogenCount() throws Exception {
+ MDLV2000Reader r = new MDLV2000Reader(getClass().getResourceAsStream("structure-with-radical.mol"));
+ IAtomContainer m = r.read(new AtomContainer());
+ assertThat(m.getAtom(0).getAtomicNumber(), is(8));
+ assertThat(m.getAtom(0).getImplicitHydrogenCount(), is(0));
+ }
+
/**
* @cdk.bug 1326
*/
View
5 storage/io/src/test/java/org/openscience/cdk/io/MDLV2000WriterTest.java
@@ -596,6 +596,8 @@ public void testSingleDoubletRadical() throws Exception {
}
+ // XXX: information loss, CDK does not distinquish between divalence
+ // singlet and triplet and only stores the unpaired electrons
@Test
public void testSingleTripletRadical() throws Exception {
@@ -612,10 +614,11 @@ public void testSingleTripletRadical() throws Exception {
String[] lines = sw.toString().split("\n");
+
assertThat("incorrect file length",
lines.length, is(9));
assertThat("incorrect radical output",
- lines[7], is("M RAD 1 2 3"));
+ lines[7], is("M RAD 1 2 1"));
}
@Test

No commit comments for this range

Something went wrong with that request. Please try again.