private void rubricTetrahedralsCdk() { for (IStereoElement se : mol.stereoElements()) { if (se.getConfigClass() == IStereoElement.Tetrahedral) { @SuppressWarnings("unchecked") final IStereoElement<IAtom, IAtom> th = (IStereoElement<IAtom, IAtom>) se; final IAtom focus = th.getFocus(); final List<IAtom> carriers = th.getCarriers(); int[] adj = new int[4]; for (int i = 0; i < 4; i++) { if (focus.equals(carriers.get(i))) adj[i] = -1; // impl H else adj[i] = mol.indexOf(carriers.get(i)); } switch (th.getConfigOrder()) { case IStereoElement.LEFT: int i = adj[2]; adj[2] = adj[3]; adj[3] = i; tetra[mol.indexOf(focus)] = adj; break; case IStereoElement.RIGHT: tetra[mol.indexOf(focus)] = adj; break; default: } } } }
List<IStereoElement> newStereo = null; for (IStereoElement se : stereoElements()) { if (se.contains(oldAtom)) { if (oldStereo == null) { oldStereo = new ArrayList<>(); Map<IAtom, IAtom> amap = Collections.singletonMap(oldAtom, atom); Map<IBond, IBond> bmap = Collections.emptyMap(); newStereo.add(se.map(amap, bmap));
private boolean flipStereo(IAtom atom) { List<IBond> bonds = nbrs.get(atom); for (IStereoElement se : mol.stereoElements()) { if (se.getConfigClass() == IStereoElement.TH && se.getFocus().equals(atom)) { @SuppressWarnings("unchecked") List<IAtom> src = (List<IAtom>) se.getCarriers(); List<IAtom> dst = new ArrayList<>(); for (IBond bond : bonds) dst.add(bond.getOther(atom)); if (dst.size() == 3) { if (avisit.contains(dst.get(0))) dst.add(1, atom); else dst.add(0, atom); } return parity4(src.toArray(new IAtom[4]), dst.toArray(new IAtom[4])) == 1; } } // no enough info return false; }
private void setBondDirs(IAtomContainer mol) { adjToDb = new HashSet<>(); ses = new HashMap<>(); bvisit = new HashSet<>(); for (IStereoElement se : mol.stereoElements()) { if (se.getConfigClass() == IStereoElement.CisTrans) { ses.put(se.getFocus(), se); } } for (IBond bond : mol.bonds()) { Expr expr = ((QueryBond) BondRef.deref(bond)).getExpression(); int flags = getBondStereoFlag(expr); if (flags != BSTEREO_ANY) { adjToDb.add(bond.getBegin()); adjToDb.add(bond.getEnd()); } } // first we set and propagate for (IBond bond : mol.bonds()) { if (!bvisit.contains(bond)) propagateBondStereo(bond, false); } // now set the complex ones for (IBond bond : mol.bonds()) { if (!bvisit.contains(bond)) propagateBondStereo(bond, true); } }
int nIncorrectStereo = 0; for (IStereoElement se : macrocycle.stereoElements()) { if (se.getConfigClass() == IStereoElement.CisTrans) { IBond bond = (IBond) se.getFocus(); IAtom beg = bond.getBegin(); IAtom end = bond.getEnd(); cfg = IStereoElement.OPPOSITE; if (cfg == se.getConfigOrder()) { nCorrectStereo++; } else {
stereos.put(se.getFocus(), se); List<IStereoElement> qstereo = new ArrayList<>(); se.getConfigClass() == IStereoElement.TH && optset.contains(STEREOCHEMISTRY)) { expr.and(new Expr(STEREOCHEMISTRY, se.getConfigOrder())); qstereo.add(se); if (se != null && optset.contains(STEREOCHEMISTRY)) { expr.and(new Expr(STEREOCHEMISTRY, se.getConfigOrder())); qstereo.add(se); query.addStereoElement(se.map(mapping));
IStereoElement s1 = stereoUp.get(0); IStereoElement s2 = stereoDown.get(0); assertThat(s1.getFocus(), is(s2.getFocus())); assertThat(s1.getCarriers(), is(s2.getCarriers())); assertThat(s1.getConfigOrder(), is(IStereoElement.RIGHT)); assertThat(s2.getConfigOrder(), is(IStereoElement.LEFT)); assertThat(stereoUpOther.size(), is(1)); IStereoElement s3 = stereoUpOther.get(0); assertThat(s3.getFocus(), is(s2.getFocus())); assertThat(s3.getCarriers(), is(s2.getCarriers())); assertThat(s3.getConfigOrder(), is(s2.getConfigOrder())); assertThat(stereoDownOther.size(), is(1)); IStereoElement s4 = stereoDownOther.get(0); assertThat(s4.getFocus(), is(s1.getFocus())); assertThat(s4.getCarriers(), is(s1.getCarriers())); assertThat(s4.getConfigOrder(), is(s1.getConfigOrder()));
/** * Access the parity (odd/even) parity of the double bond configuration ( * together/opposite). * * @param element double bond element * @return together = -1, opposite = +1 */ private static int parity(IStereoElement element) { switch (element.getConfigOrder()) { case IStereoElement.TOGETHER: return -1; case IStereoElement.OPPOSITE: return +1; default: return 0; } }
clone.addStereoElement(element.map(atomMap, bondMap));
if (element.contains(atom)) atomElements.add(element);
@Test public void roundTripExtendedCisTrans() throws CDKException { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("C/C=C=C=C/C"); assertThat(new SmilesGenerator(SmiFlavor.Stereo).create(mol), is("C/C=C=C=C/C")); for (IStereoElement se : mol.stereoElements()) { se.setConfigOrder(se.getConfigOrder() ^ 0x3); // flip } assertThat(new SmilesGenerator(SmiFlavor.Stereo).create(mol), is("C/C=C=C=C\\C")); }
IChemObject focus = stereo.getFocus(); if (focus instanceof IAtom) { if (componentsMap.containsKey(focus))
if (se.getCarriers().contains(bBond) != se.getCarriers().contains(eBond)) { switch (flags) { case BSTEREO_CIS:
int nIncorrectStereo = 0; for (IStereoElement se : macrocycle.stereoElements()) { if (se.getConfigClass() == IStereoElement.CisTrans) { IBond bond = (IBond) se.getFocus(); IAtom beg = bond.getBegin(); IAtom end = bond.getEnd(); cfg = IStereoElement.OPPOSITE; if (cfg == se.getConfigOrder()) { nCorrectStereo++; } else {
/** * Access the parity (odd/even) parity of the double bond configuration ( * together/opposite). * * @param element double bond element * @return together = -1, opposite = +1 */ private static int parity(IStereoElement element) { switch (element.getConfigOrder()) { case IStereoElement.TOGETHER: return -1; case IStereoElement.OPPOSITE: return +1; default: return 0; } }
clone.addStereoElement(element.map(atomMap, bondMap));
if (element.contains(atom)) atomElements.add(element);
if (se.getConfigClass() == IStereoElement.CisTrans) { IBond stereoBond = (IBond) se.getFocus(); IBond firstCarrier = (IBond) se.getCarriers().get(0); IBond secondCarrier = (IBond) se.getCarriers().get(1); for (IRingSet ringSet : ringSystems) { for (IAtomContainer ring : ringSet.atomContainers()) { continue; boolean flipped = begBonds.contains(firstCarrier) != endBonds.contains(secondCarrier); int cfg = flipped ? se.getConfigOrder() ^ 0x3 : se.getConfigOrder(); ring.addStereoElement(new DoubleBondStereochemistry(stereoBond, new IBond[]{begBonds.get(0), endBonds.get(0)},
List<IStereoElement> newStereo = null; for (IStereoElement se : stereoElements()) { if (se.contains(oldAtom)) { if (oldStereo == null) { oldStereo = new ArrayList<>(); Map<IAtom, IAtom> amap = Collections.singletonMap(oldAtom, atom); Map<IBond, IBond> bmap = Collections.emptyMap(); newStereo.add(se.map(amap, bmap));
@Test public void oh8() throws Exception { IAtomContainer mol = load("C[Co@OH8](F)(Br)(Cl)(I)S"); Iterator<IStereoElement> ses =mol.stereoElements().iterator(); assertTrue(ses.hasNext()); IStereoElement se = ses.next(); assertThat(se, instanceOf(Octahedral.class)); assertThat(se.getConfigOrder(), is(8)); }