use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.
the class QueryStereoFilter method indexElements.
/**
* Index the stereo elements of the {@code container} into the the {@code
* elements} and {@code types} arrays. The {@code map} is used for looking
* up the index of atoms.
*
* @param map index of atoms
* @param elements array to fill with stereo elements
* @param types type of stereo element indexed
* @param container the container to index the elements of
* @return indices of atoms involved in stereo configurations
*/
private static int[] indexElements(Map<IAtom, Integer> map, IStereoElement[] elements, Type[] types, IAtomContainer container) {
int[] indices = new int[container.getAtomCount()];
int nElements = 0;
for (IStereoElement element : container.stereoElements()) {
if (element instanceof ITetrahedralChirality) {
ITetrahedralChirality tc = (ITetrahedralChirality) element;
int idx = map.get(tc.getChiralAtom());
elements[idx] = element;
types[idx] = Type.Tetrahedral;
indices[nElements++] = idx;
} else if (element instanceof IDoubleBondStereochemistry) {
IDoubleBondStereochemistry dbs = (IDoubleBondStereochemistry) element;
int idx1 = map.get(dbs.getStereoBond().getBegin());
int idx2 = map.get(dbs.getStereoBond().getEnd());
elements[idx2] = elements[idx1] = element;
types[idx1] = types[idx2] = Type.Geometric;
// only visit the first atom
indices[nElements++] = idx1;
}
}
return Arrays.copyOf(indices, nElements);
}
use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.
the class StereoMatch method indexElements.
/**
* Index the stereo elements of the {@code container} into the the {@code
* elements} and {@code types} arrays. The {@code map} is used for looking
* up the index of atoms.
*
* @param map index of atoms
* @param elements array to fill with stereo elements
* @param types type of stereo element indexed
* @param container the container to index the elements of
* @return indices of atoms involved in stereo configurations
*/
private static int[] indexElements(Map<IAtom, Integer> map, IStereoElement[] elements, Type[] types, IAtomContainer container) {
int[] indices = new int[container.getAtomCount()];
int nElements = 0;
for (IStereoElement element : container.stereoElements()) {
if (element instanceof ITetrahedralChirality) {
ITetrahedralChirality tc = (ITetrahedralChirality) element;
int idx = map.get(tc.getChiralAtom());
elements[idx] = element;
types[idx] = Type.Tetrahedral;
indices[nElements++] = idx;
} else if (element instanceof IDoubleBondStereochemistry) {
IDoubleBondStereochemistry dbs = (IDoubleBondStereochemistry) element;
int idx1 = map.get(dbs.getStereoBond().getBegin());
int idx2 = map.get(dbs.getStereoBond().getEnd());
elements[idx2] = elements[idx1] = element;
types[idx1] = types[idx2] = Type.Geometric;
// only visit the first atom
indices[nElements++] = idx1;
}
}
return Arrays.copyOf(indices, nElements);
}
use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.
the class StereoElementFactoryTest method e_but2ene.
@Test
public void e_but2ene() {
IAtomContainer m = new AtomContainer(4, 3, 0, 0);
m.addAtom(atom("C", 1, -2.19d, 1.64d));
m.addAtom(atom("C", 1, -1.36d, 1.64d));
m.addAtom(atom("C", 3, -2.60d, 0.92d));
m.addAtom(atom("C", 3, -0.95d, 2.35d));
m.addBond(0, 1, IBond.Order.DOUBLE);
m.addBond(0, 2, IBond.Order.SINGLE);
m.addBond(1, 3, IBond.Order.SINGLE);
StereoElementFactory factory = StereoElementFactory.using2DCoordinates(m);
IDoubleBondStereochemistry element = factory.createGeometric(m.getBond(0), null);
assertNotNull(element);
assertThat(element.getStereo(), is(OPPOSITE));
}
use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.
the class StereoElementFactoryTest method z_but2ene_3d.
@Test
public void z_but2ene_3d() {
IAtomContainer m = new AtomContainer(4, 3, 0, 0);
m.addAtom(atom("C", 1, 0.05d, -1.28d, 0.13d));
m.addAtom(atom("C", 1, -0.72d, -0.58d, -0.72d));
m.addAtom(atom("C", 3, 1.11d, -0.74d, 0.95d));
m.addAtom(atom("C", 3, -0.65d, 0.85d, -0.94d));
m.addBond(0, 1, IBond.Order.DOUBLE);
m.addBond(0, 2, IBond.Order.SINGLE);
m.addBond(1, 3, IBond.Order.SINGLE);
StereoElementFactory factory = StereoElementFactory.using3DCoordinates(m);
IDoubleBondStereochemistry element = factory.createGeometric(m.getBond(0), null);
assertNotNull(element);
assertThat(element.getStereo(), is(TOGETHER));
}
use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry in project cdk by cdk.
the class InChIGeneratorTest method testDoubleBondStereochemistry.
@Test
public void testDoubleBondStereochemistry() throws Exception {
// (E)-1,2-dichloroethene
IAtomContainer acE = new AtomContainer();
IAtom a1E = new Atom("C");
IAtom a2E = new Atom("C");
IAtom a3E = new Atom("Cl");
IAtom a4E = new Atom("Cl");
a1E.setImplicitHydrogenCount(1);
a2E.setImplicitHydrogenCount(1);
acE.addAtom(a1E);
acE.addAtom(a2E);
acE.addAtom(a3E);
acE.addAtom(a4E);
acE.addBond(new Bond(a1E, a2E, Order.DOUBLE));
acE.addBond(new Bond(a1E, a3E, Order.SINGLE));
acE.addBond(new Bond(a2E, a4E, Order.SINGLE));
IBond[] ligands = new IBond[2];
ligands[0] = acE.getBond(1);
ligands[1] = acE.getBond(2);
IDoubleBondStereochemistry stereo = new DoubleBondStereochemistry(acE.getBond(0), ligands, org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation.OPPOSITE);
acE.addStereoElement(stereo);
InChIGenerator genE = getFactory().getInChIGenerator(acE);
Assert.assertEquals(INCHI_RET.OKAY, genE.getReturnStatus());
Assert.assertEquals("InChI=1S/C2H2Cl2/c3-1-2-4/h1-2H/b2-1+", genE.getInchi());
}
Aggregations