AtomTetrahedralLigandPlacer3D { public void add3DCoordinatesForSinglyBondedLigands(IAtomContainer atomContainer) throws CDKException { IAtom refAtom = null; IAtom atomC = null; int nwanted = 0; for (int i = 0; i < atomContainer.getAtomCount(); i++) { refAtom = atomContainer.getAtom(i); if (!refAtom.getSymbol().equals("H") && hasUnsetNeighbour(refAtom, atomContainer)) { IAtomContainer noCoords = getUnsetAtomsInAtomContainer(refAtom, atomContainer); IAtomContainer withCoords = getPlacedAtomsInAtomContainer(refAtom, atomContainer); if (withCoords.getAtomCount() > 0) { atomC = getPlacedHeavyAtomInAtomContainer(withCoords.getAtom(0), refAtom, atomContainer); } if (refAtom.getFormalNeighbourCount() == 0 && refAtom.getSymbol().equals("C")) { nwanted = noCoords.getAtomCount(); } else if (refAtom.getFormalNeighbourCount() == 0 && !refAtom.getSymbol().equals("C")) { nwanted = 4; } else { nwanted = refAtom.getFormalNeighbourCount() - withCoords.getAtomCount(); } Point3d[] newPoints = get3DCoordinatesForLigands(refAtom, noCoords, withCoords, atomC, nwanted, DEFAULT_BOND_LENGTH_H, -1); for (int j = 0; j < noCoords.getAtomCount(); j++) { IAtom ligand = noCoords.getAtom(j); Point3d newPoint = rescaleBondLength(refAtom, ligand, newPoints[j]); ligand.setPoint3d(newPoint); ligand.setFlag(CDKConstants.ISPLACED, true); } noCoords.removeAllElements(); withCoords.removeAllElements(); } } } AtomTetrahedralLigandPlacer3D(); void setParameterSet(Map moleculeParameter); void add3DCoordinatesForSinglyBondedLigands(IAtomContainer atomContainer); Point3d rescaleBondLength(IAtom atom1, IAtom atom2, Point3d point2); Point3d[] get3DCoordinatesForLigands(IAtom refAtom, IAtomContainer noCoords, IAtomContainer withCoords,
            IAtom atomC, int nwanted, double length, double angle); Point3d get3DCoordinatesForSPLigands(IAtom refAtom, IAtomContainer withCoords, double length, double angle); Point3d[] get3DCoordinatesForSP2Ligands(IAtom refAtom, IAtomContainer noCoords, IAtomContainer withCoords,
            IAtom atomC, double length, double angle); Point3d[] get3DCoordinatesForSP3Ligands(IAtom refAtom, IAtomContainer noCoords, IAtomContainer withCoords,
            IAtom atomC, int nwanted, double length, double angle); Point3d[] calculate3DCoordinates0(Point3d aPoint, int nwanted, double length); Point3d[] calculate3DCoordinates1(Point3d aPoint, Point3d bPoint, Point3d cPoint, int nwanted,
            double length, double angle); Point3d[] calculate3DCoordinates2(Point3d aPoint, Point3d bPoint, Point3d cPoint, int nwanted,
            double length, double angle); Point3d calculate3DCoordinates3(Point3d aPoint, Point3d bPoint, Point3d cPoint, Point3d dPoint, double length); Point3d calculate3DCoordinatesSP2_1(Point3d aPoint, Point3d bPoint, Point3d cPoint, double length,
            double angle); Point3d[] calculate3DCoordinatesSP2_2(Point3d aPoint, Point3d bPoint, Point3d cPoint, double length,
            double angle); static Vector3d rotate(Vector3d vector, Vector3d axis, double angle); double getAngleValue(String id1, String id2, String id3); int makeStereocenter(Point3d atomA, IBond ax, Point3d atomB, Point3d atomC, Point3d[] branchPoints); double getSpatproduct(Vector3d a, Vector3d b, Vector3d c); double getTorsionAngle(Point3d a, Point3d b, Point3d c, Point3d d); IAtomContainer getPlacedAtomsInAtomContainer(IAtom atom, IAtomContainer ac); IAtomContainer getUnsetAtomsInAtomContainer(IAtom atom, IAtomContainer ac); boolean hasUnsetNeighbour(IAtom atom, IAtomContainer ac); IAtom getPlacedHeavyAtomInAtomContainer(IAtom atomA, IAtom atomB, IAtomContainer ac); final static double DEFAULT_BOND_LENGTH_H; final static double TETRAHEDRAL_ANGLE; }
@Test public void testAdd3DCoordinatesForSinglyBondedLigands_IAtomContainer() throws Exception { IAtom atom1 = new Atom("C"); atom1.setPoint3d(new Point3d(1, 1, 1)); IAtom atom2 = new Atom("H"); IAtom atom3 = new Atom("H"); IAtom atom4 = new Atom("H"); IAtom atom5 = new Atom("H"); IBond bond1 = new Bond(atom1, atom2); IBond bond2 = new Bond(atom1, atom3); IBond bond3 = new Bond(atom1, atom4); IBond bond4 = new Bond(atom1, atom5); IAtomContainer ac = atom1.getBuilder().newInstance(IAtomContainer.class); atom1.setFormalNeighbourCount(4); atom2.setFormalNeighbourCount(1); atom3.setFormalNeighbourCount(1); atom4.setFormalNeighbourCount(1); atom5.setFormalNeighbourCount(1); ac.addAtom(atom1); ac.addAtom(atom2); ac.addAtom(atom3); ac.addAtom(atom4); ac.addAtom(atom5); ac.addBond(bond1); ac.addBond(bond2); ac.addBond(bond3); ac.addBond(bond4); new AtomTetrahedralLigandPlacer3D().add3DCoordinatesForSinglyBondedLigands(ac); ModelBuilder3DTest.checkAverageBondLength(ac); }