Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,24 @@ else if (amol != mol)

for (IAtom atom : atomset) {
for (IBond bond : mol.getConnectedBondsList(atom)) {
if (!atomset.contains(bond.getOther(atom)))
sgroup.addBond(bond);
IAtom nbor = bond.getOther(atom);
if (!atomset.contains(nbor)) {
boolean crossing = true;

// check for variable attachments see https://github.com/cdk/depict/issues/36
if (cxstate.positionVar != null) {
List<Integer> ends = cxstate.positionVar.get(mol.indexOf(nbor));
if (ends != null) {
for (Integer end : ends) {
if (atomset.contains(mol.getAtom(end)))
crossing = false;
}
}
}

if (crossing)
sgroup.addBond(bond);
}
}
sgroup.addAtom(atom);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@

import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Assert;
import org.junit.Test;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.exception.InvalidSmilesException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.interfaces.IReaction;
import org.openscience.cdk.interfaces.IStereoElement;
import org.openscience.cdk.sgroup.Sgroup;
import org.openscience.cdk.sgroup.SgroupType;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.tools.manipulator.ReactionManipulator;

Expand Down Expand Up @@ -370,6 +374,23 @@ public void hydrogenAndCoordinationBondingSkipped() {
is("R1"));
}

@Test public void variableAttachCrossingBonds() throws CDKException {
SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance());
IAtomContainer mol = smipar.parseSmiles("[H]OCCO.C* |lp:1:2,4:2,m:6:3.2,Sg:n:1,2,3,5::ht|");
List<Sgroup> sgroups = mol.getProperty(CDKConstants.CTAB_SGROUPS);
Sgroup sru = null;
for (Sgroup sgroup : sgroups) {
if (sgroup.getType() == SgroupType.CtabStructureRepeatUnit) {
sru = sgroup;
break;
}
}
Assert.assertNotNull(sru);
Assert.assertEquals(4, sru.getAtoms().size());
Assert.assertEquals(2, sru.getBonds().size());
}


/**
* Custom matcher for checking an array of doubles closely matches (epsilon=0.01)
* an expected value.
Expand Down