Skip to content

Commit

Permalink
Do no pass stereo information when none (null) was read
Browse files Browse the repository at this point in the history
Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Oct 16, 2010
1 parent 7a6fb30 commit 986e02f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
21 changes: 14 additions & 7 deletions src/main/org/openscience/cdk/io/MDLReader.java
Expand Up @@ -541,15 +541,22 @@ private IMolecule readMolecule(IMolecule molecule) throws CDKException {
IAtom a1 = molecule.getAtom(atom1 - 1);
IAtom a2 = molecule.getAtom(atom2 - 1);
IBond newBond = null;
if (order == 1) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE, stereo);
} else if (order == 2) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.DOUBLE, stereo);
} else if (order == 3) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.TRIPLE, stereo);
if (order >= 1 && order <= 3) {
IBond.Order cdkOrder = IBond.Order.SINGLE;
if (order == 2) cdkOrder = IBond.Order.DOUBLE;
if (order == 3) cdkOrder = IBond.Order.TRIPLE;
if (stereo != null) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, cdkOrder, stereo);
} else {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, cdkOrder);
}
} else if (order == 4) {
// aromatic bond
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE, stereo);
if (stereo != null) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE, stereo);
} else {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
}
// mark both atoms and the bond as aromatic
newBond.setFlag(CDKConstants.ISAROMATIC, true);
a1.setFlag(CDKConstants.ISAROMATIC, true);
Expand Down
21 changes: 14 additions & 7 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -657,15 +657,22 @@ private IMolecule readMolecule(IMolecule molecule) throws CDKException {
IAtom a1 = molecule.getAtom(atom1 - 1);
IAtom a2 = molecule.getAtom(atom2 - 1);
IBond newBond = null;
if (order == 1) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE, stereo);
} else if (order == 2) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.DOUBLE, stereo);
} else if (order == 3) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.TRIPLE, stereo);
if (order >= 1 && order <= 3) {
IBond.Order cdkOrder = IBond.Order.SINGLE;
if (order == 2) cdkOrder = IBond.Order.DOUBLE;
if (order == 3) cdkOrder = IBond.Order.TRIPLE;
if (stereo != null) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, cdkOrder, stereo);
} else {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, cdkOrder);
}
} else if (order == 4) {
// aromatic bond
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE, stereo);
if (stereo != null) {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE, stereo);
} else {
newBond = molecule.getBuilder().newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
}
// mark both atoms and the bond as aromatic
newBond.setFlag(CDKConstants.ISAROMATIC, true);
a1.setFlag(CDKConstants.ISAROMATIC, true);
Expand Down

0 comments on commit 986e02f

Please sign in to comment.