@Override protected IStereoElement<IAtom, IAtom> create(IAtom focus, List<IAtom> carriers, int config) { return new TetrahedralChirality(focus, carriers.toArray(new IAtom[4]), config); }
@Test public void testGetStereo() { TetrahedralChirality chirality = new TetrahedralChirality(molecule.getAtom(1), ligands, Stereo.CLOCKWISE); Assert.assertNotNull(chirality); Assert.assertEquals(molecule.getAtom(1), chirality.getChiralAtom()); for (int i = 0; i < ligands.length; i++) { Assert.assertEquals(ligands[i], chirality.getLigands()[i]); } Assert.assertEquals(TetrahedralChirality.Stereo.CLOCKWISE, chirality.getStereo()); }
/** * Returns a {@link String} representation of this chiral element. * * @return the String representation */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Tetrahedral{").append(this.hashCode()).append(", "); builder.append(this.getStereo()).append(", "); builder.append("c:").append(this.getChiralAtom()).append(", "); IAtom[] ligands = this.getLigands(); for (int i = 0; i < ligands.length; i++) { builder.append(i + 1).append(':').append(ligands[i]).append(", "); } builder.append('}'); return builder.toString(); } }
@Test public void testBuilder() { TetrahedralChirality chirality = new TetrahedralChirality(molecule.getAtom(1), ligands, Stereo.CLOCKWISE); chirality.setBuilder(DefaultChemObjectBuilder.getInstance()); Assert.assertEquals(DefaultChemObjectBuilder.getInstance(), chirality.getBuilder()); }
@Test public void testGetChiralAtom() { TetrahedralChirality chirality = new TetrahedralChirality(molecule.getAtom(1), ligands, Stereo.CLOCKWISE); Assert.assertNotNull(chirality); Assert.assertEquals(molecule.getAtom(1), chirality.getChiralAtom()); }
@Test public void testGetLigands() { TetrahedralChirality chirality = new TetrahedralChirality(molecule.getAtom(1), ligands, Stereo.CLOCKWISE); Assert.assertNotNull(chirality); for (int i = 0; i < ligands.length; i++) { Assert.assertEquals(ligands[i], chirality.getLigands()[i]); } }
@Test public void testToString() { TetrahedralChirality chirality = new TetrahedralChirality(molecule.getAtom(1), ligands, Stereo.CLOCKWISE); String stringRepr = chirality.toString(); Assert.assertNotSame(0, stringRepr.length()); Assert.assertFalse(stringRepr.contains("\n")); } }
!((TetrahedralChirality) se).getChiralAtom().getFlag(CDKConstants.VISITED)) { this.addStereoElement(se); } else if (se instanceof DoubleBondStereochemistry &&
/** * Returns a {@link String} representation of this chiral element. * * @return the String representation */ @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Tetrahedral{").append(this.hashCode()).append(", "); builder.append(this.getStereo()).append(", "); builder.append("c:").append(this.getChiralAtom()).append(", "); IAtom[] ligands = this.getLigands(); for (int i = 0; i < ligands.length; i++) { builder.append(i + 1).append(':').append(ligands[i]).append(", "); } builder.append('}'); return builder.toString(); } }
!((TetrahedralChirality) se).getChiralAtom().getFlag(CDKConstants.VISITED)) { this.addStereoElement(se); } else if (se instanceof DoubleBondStereochemistry &&
@Override protected IStereoElement<IAtom, IAtom> create(IAtom focus, List<IAtom> carriers, int config) { return new TetrahedralChirality(focus, carriers.toArray(new IAtom[4]), config); }
@Test public void testAtomParity() throws Exception { String cmlString = "<molecule><atomArray><atom id='a1' elementType='C'><atomParity atomRefs4='a2 a3 a5 a4'>1</atomParity></atom>" + "<atom id='a2' elementType='Br'/><atom id='a3' elementType='Cl'/><atom id='a4' elementType='F'/><atom id='a5' elementType='I'/></atomArray>" + "<bondArray><bond atomRefs2='a1 a2' order='1'/><bond atomRefs2='a1 a3' order='1'/><bond atomRefs2='a1 a4' order='1'/><bond atomRefs2='a1 a5' order='1'/></bondArray></molecule>"; IChemFile chemFile = parseCMLString(cmlString); IAtomContainer mol = checkForSingleMoleculeFile(chemFile); Assert.assertEquals(5, mol.getAtomCount()); IAtom atom = mol.getAtom(0); Assert.assertEquals("C", atom.getSymbol()); IStereoElement stereo = mol.stereoElements().iterator().next(); Assert.assertTrue(stereo instanceof TetrahedralChirality); Assert.assertEquals(((TetrahedralChirality) stereo).getChiralAtom().getID(), "a1"); IAtom[] ligandAtoms = ((TetrahedralChirality) stereo).getLigands(); Assert.assertEquals(4, ligandAtoms.length); Assert.assertEquals(ligandAtoms[0].getID(), "a2"); Assert.assertEquals(ligandAtoms[1].getID(), "a3"); Assert.assertEquals(ligandAtoms[2].getID(), "a5"); Assert.assertEquals(ligandAtoms[3].getID(), "a4"); Assert.assertEquals(((TetrahedralChirality) stereo).getStereo(), Stereo.CLOCKWISE); }
!((TetrahedralChirality) se).getChiralAtom().getFlag(CDKConstants.VISITED)) { this.addStereoElement(se); } else if (se instanceof DoubleBondStereochemistry &&
/** * Creates a tetrahedral element for the given configuration. Currently only * tetrahedral centres with 4 explicit atoms are handled. * * @param u central atom * @param vs neighboring atom indices (in order) * @param atoms array of the CDK atoms (pre-converted) * @param c the configuration of the neighbors (vs) for the order they * are given * @return tetrahedral stereo element for addition to an atom container */ private IStereoElement newTetrahedral(int u, int[] vs, IAtom[] atoms, Configuration c) { // no way to handle tetrahedral configurations with implicit // hydrogen or lone pair at the moment if (vs.length != 4) { // sanity check if (vs.length != 3) return null; // there is an implicit hydrogen (or lone-pair) we insert the // central atom in sorted position vs = insert(u, vs); } // @TH1/@TH2 = anti-clockwise and clockwise respectively Stereo stereo = c == Configuration.TH1 ? Stereo.ANTI_CLOCKWISE : Stereo.CLOCKWISE; return new TetrahedralChirality(atoms[u], new IAtom[]{atoms[vs[0]], atoms[vs[1]], atoms[vs[2]], atoms[vs[3]]}, stereo); }
!((TetrahedralChirality) se).getChiralAtom().getFlag(CDKConstants.VISITED)) { this.addStereoElement(se); } else if (se instanceof DoubleBondStereochemistry &&
/** * * @param centralAtom * @param atomContainer * @param angleMap * @return */ @Override public IStereoElement execute(IAtom centralAtom, IAtomContainer atomContainer, SortedMap<Double, IBond> angleMap) { int[] permutation = getMatchPermutation(); List<IBond> bonds = new ArrayList<>(angleMap.values()); IAtom[] ligandAtoms = new IAtom[4]; for (int index = 0; index < 4; index++) { IBond bond = bonds.get(permutation[index]); ligandAtoms[index] = bond.getOther(centralAtom); } ITetrahedralChirality.Stereo chirality = ANTI_CLOCKWISE; return new TetrahedralChirality(centralAtom, ligandAtoms, chirality); } }
/** * * @param centralAtom * @param atomContainer * @param angleMap * @return */ @Override public IStereoElement execute(IAtom centralAtom, IAtomContainer atomContainer, SortedMap<Double, IBond> angleMap) { int[] permutation = getMatchPermutation(); List<IBond> bonds = new ArrayList<>(angleMap.values()); IAtom[] ligandAtoms = new IAtom[4]; for (int index = 0; index < 4; index++) { IBond bond = bonds.get(permutation[index]); ligandAtoms[index] = bond.getOther(centralAtom); } ITetrahedralChirality.Stereo chirality = CLOCKWISE; return new TetrahedralChirality(centralAtom, ligandAtoms, chirality); } }
/** * * @param centralAtom * @param atomContainer * @param angleMap * @return */ @Override public IStereoElement execute(IAtom centralAtom, IAtomContainer atomContainer, SortedMap<Double, IBond> angleMap) { int[] permutation = getMatchPermutation(); List<IBond> bonds = new ArrayList<>(angleMap.values()); IAtom[] ligandAtoms = new IAtom[4]; for (int index = 0; index < 4; index++) { IBond bond = bonds.get(permutation[index]); ligandAtoms[index] = bond.getOther(centralAtom); } return new TetrahedralChirality(centralAtom, ligandAtoms, getStereo()); }
IAtom[] ligands = new IAtom[]{n1, n2, n3, n4}; ITetrahedralChirality stereoCenter = new TetrahedralChirality(atom, ligands, stereo); CIP_CHIRALITY chirality = getCIPChirality(atomContainer, stereoCenter); if (getNoneAssigments || chirality != CIP_CHIRALITY.NONE) {
/**{@inheritDoc} */ @Override ITetrahedralChirality createTetrahedral(int v, Stereocenters stereocenters) { if (!stereocenters.isStereocenter(v)) return null; IAtom focus = container.getAtom(v); if (hasUnspecifiedParity(focus)) return null; IAtom[] neighbors = new IAtom[4]; neighbors[3] = focus; int n = 0; for (int w : graph[v]) neighbors[n++] = container.getAtom(w); // too few/many neighbors if (n < 3 || n > 4) return null; // TODO: verify valid wedge/hatch configurations using similar procedure // to NonPlanarBonds in the cdk-sdg package int parity = parity(neighbors); Stereo winding = parity > 0 ? Stereo.ANTI_CLOCKWISE : Stereo.CLOCKWISE; return new TetrahedralChirality(focus, neighbors, winding); }