|  | 
| 67 | 67 | import org.RDKit.RDKFuncs; | 
| 68 | 68 | import org.RDKit.ROMol; | 
| 69 | 69 | import org.RDKit.RWMol; | 
|  | 70 | +import org.RDKit.Bond; | 
| 70 | 71 | import org.apache.batik.anim.dom.SAXSVGDocumentFactory; | 
| 71 | 72 | import org.apache.batik.util.XMLResourceDescriptor; | 
| 72 | 73 | import org.knime.base.data.xml.SvgProvider; | 
| @@ -568,6 +569,37 @@ public static int compute2DCoords(ROMol mol, boolean bUseCoordGen, boolean bNorm | 
| 568 | 569 | return compute2DCoords(mol, (Int_Point2D_Map)null, bUseCoordGen, bNormalize); | 
| 569 | 570 | } | 
| 570 | 571 | 
 | 
|  | 572 | +/** | 
|  | 573 | + * Clears the single bond direction flags of the passed in molecule. | 
|  | 574 | + * If bOnlyWedgeFlags is true, only the wedge flags are cleared, otherwise | 
|  | 575 | + * all single bond direction flags are cleared. | 
|  | 576 | + * FIXME: This method can be replaced with the native clearSingleBondDirFlags | 
|  | 577 | + * method once the RDKit version is updated to 2025_03_4 or later | 
|  | 578 | + * @param mol Molecule to clear the single bond direction flags for. Can be null to do nothing. | 
|  | 579 | + * @param bOnlyWedgeFlags If true, only the wedge flags are cleared, otherwise | 
|  | 580 | + * all single bond direction flags are cleared. | 
|  | 581 | + */ | 
|  | 582 | +public static void clearSingleBondDirFlags(ROMol mol, boolean bOnlyWedgeFlags) { | 
|  | 583 | +if (mol == null) { | 
|  | 584 | +return; | 
|  | 585 | +} | 
|  | 586 | +for (int i = 0; i < mol.getNumBonds(); ++i) { | 
|  | 587 | +final Bond bond = mol.getBondWithIdx(i); | 
|  | 588 | +if (bond.getBondType() == Bond.BondType.SINGLE) { | 
|  | 589 | +if (bond.getBondDir() == Bond.BondDir.UNKNOWN) { | 
|  | 590 | +bond.setProp("_UnknownStereo", "1"); | 
|  | 591 | +} | 
|  | 592 | + | 
|  | 593 | +if (!bOnlyWedgeFlags || | 
|  | 594 | +(bond.getBondDir() != Bond.BondDir.ENDDOWNRIGHT && | 
|  | 595 | +bond.getBondDir() != Bond.BondDir.ENDUPRIGHT)) { | 
|  | 596 | +bond.setBondDir(Bond.BondDir.NONE); | 
|  | 597 | +} | 
|  | 598 | +} | 
|  | 599 | +} | 
|  | 600 | +} | 
|  | 601 | + | 
|  | 602 | + | 
| 571 | 603 | /** | 
| 572 | 604 |  * Calls the compute2DCoords method on the passed in ROMol object (if not null) | 
| 573 | 605 |  * and passes default parameters except for the last boolean parameter, which | 
| @@ -608,7 +640,7 @@ public static int compute2DCoords(ROMol mol, Int_Point2D_Map mapTemplate, boolea | 
| 608 | 640 | // canonicalization may flip the molecule around the Z axis, | 
| 609 | 641 | // so we recompute bond wedging to make sure the stereochemistry | 
| 610 | 642 | // is depicted correctly (KNIME-1692) | 
| 611 |  | -mol.ClearSingleBondDirFlags(); | 
|  | 643 | +clearSingleBondDirFlags(mol, true); | 
| 612 | 644 | mol.WedgeMolBonds(mol.getConformer()); | 
| 613 | 645 | } | 
| 614 | 646 | } | 
|  | 
0 commit comments