Skip to content

Commit

Permalink
Fixed bond order assignment when using the SilentCOB
Browse files Browse the repository at this point in the history
Change-Id: Ic6427e6399d645b600f5e6f1c0f438335cd91298
Signed-off-by: ngn <jeliazkova.nina@gmail.com>
  • Loading branch information
egonw committed Apr 3, 2012
1 parent fb37eab commit 1e936d0
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java
Expand Up @@ -26,13 +26,8 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

import org.openscience.cdk.Atom;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.Molecule;
import org.openscience.cdk.Ring;
import org.openscience.cdk.RingSet;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector;
Expand Down Expand Up @@ -371,7 +366,7 @@ private void sixMemberedRingPossibilities(IMolecule m, IRing r, List MasterList)
// 6 possibilities for placing 2 double bonds
// 6 possibilities for placing 1 double bonds

IAtom [] ringatoms = new Atom [6];
IAtom [] ringatoms = new IAtom [6];

ringatoms[0] = r.getAtom(0);

Expand Down Expand Up @@ -477,7 +472,7 @@ private void sixMemberedRingPossibilities(IMolecule m, IRing r, List MasterList)
private void sevenMemberedRingPossibilities(IMolecule m, IRing r, List MasterList) {
// for now only consider case where have 3 double bonds

IAtom[] ringatoms = new Atom[7];
IAtom[] ringatoms = new IAtom[7];

ringatoms[0] = r.getAtom(0);

Expand Down Expand Up @@ -584,7 +579,7 @@ private int getBadCount(IMolecule molecule, IRingSet ringSet) {

private boolean inRingSet(IAtom atom, IRingSet ringSet) {
for (int i = 0; i < ringSet.getAtomContainerCount(); i++) {
Ring ring = (Ring) ringSet.getAtomContainer(i);
IRing ring = (IRing) ringSet.getAtomContainer(i);
if (ring.contains(atom)) return true;
}
return false;
Expand Down Expand Up @@ -621,7 +616,7 @@ private IMolecule loop(long starttime, IMolecule molecule, int index,

IMolecule mnew = null;
try {
mnew = (Molecule) molecule.clone();
mnew = (IMolecule) molecule.clone();
} catch (Exception e) {
logger.error("Failed to clone molecule: ", e.getMessage());
logger.debug(e);
Expand Down Expand Up @@ -688,13 +683,13 @@ private boolean isStructureOK(IMolecule molecule) {
molecule.getAtom(i).setFlag(CDKConstants.ISAROMATIC, false);
}
for (int i = 0; i <= ringSet.getAtomContainerCount() - 1; i++) {
Ring r = (Ring) ringSet.getAtomContainer(i);
IRing r = (IRing) ringSet.getAtomContainer(i);
r.setFlag(CDKConstants.ISAROMATIC, false);
}
// now, detect aromaticity from cratch, and mark rings as aromatic too (if ...)
CDKHueckelAromaticityDetector.detectAromaticity(molecule);
for (int i = 0; i <= ringSet.getAtomContainerCount() - 1; i++) {
Ring ring = (Ring) ringSet.getAtomContainer(i);
IRing ring = (IRing) ringSet.getAtomContainer(i);
RingManipulator.markAromaticRings(ring);
}

Expand All @@ -706,7 +701,7 @@ private boolean isStructureOK(IMolecule molecule) {
// }

for (int i = 0; i <= ringSet.getAtomContainerCount() - 1; i++) {
Ring ring = (Ring) ringSet.getAtomContainer(i);
IRing ring = (IRing) ringSet.getAtomContainer(i);

//logger.debug(k+"\t"+r.getAtomCount()+"\t"+r.getFlag(CDKConstants.ISAROMATIC));
//javax.swing.JOptionPane.showMessageDialog(null,i + " " + ring.getFlag(CDKConstants.ISAROMATIC));
Expand Down Expand Up @@ -754,7 +749,7 @@ private IRingSet removeExtraRings(IMolecule m) {
iloop:
for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) {

IRing r = (Ring) rs.getAtomContainer(i);
IRing r = (IRing) rs.getAtomContainer(i);


if (r.getAtomCount() > 7 || r.getAtomCount() < 5) {
Expand Down Expand Up @@ -794,7 +789,7 @@ private IRingSet removeExtraRings(IMolecule m) {
return rs;

} catch (Exception e) {
return new RingSet();
return m.getBuilder().newInstance(IRingSet.class);
}
}

Expand All @@ -809,7 +804,7 @@ private boolean[] findRingsToCheck(IRingSet rs) {

for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) {

IRing r = (Ring) rs.getAtomContainer(i);
IRing r = (IRing) rs.getAtomContainer(i);

if (r.getAtomCount() > 7) {
Check[i] = false;
Expand Down Expand Up @@ -967,7 +962,7 @@ private Integer getRingGroupNumber(List<List<Integer>> ringGroups, Integer ringI
private IMolecule combineRetMols(List<IMolecule> retMols){
IMolecule combi = null;
try {
combi = (Molecule) retMols.get(0).clone();
combi = (IMolecule) retMols.get(0).clone();
} catch (Exception e) {
logger.error("Failed to clone molecule: ", e.getMessage());
logger.debug(e);
Expand Down

0 comments on commit 1e936d0

Please sign in to comment.