Search in sources :

Example 1 with Conformation

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation in project ambit-mirror by ideaconsult.

the class StereoChemUtils method restoreDBStereo.

public static DoubleBondStereochemistry restoreDBStereo(IAtomContainer target, DoubleBondStereochemistry dbsc, StereoChange stChange) {
    IBond[] newLigandBonds = dbsc.getBonds().clone();
    boolean FlagInvertStereo = false;
    if (stChange.ligand0Deleted) {
        IAtom at = dbsc.getStereoBond().getAtom(0);
        // Searching for a neighbor with a single bond
        for (IBond bo : target.getConnectedBondsList(at)) {
            if (bo.getOrder() == IBond.Order.SINGLE) {
                newLigandBonds[0] = bo;
                FlagInvertStereo = !FlagInvertStereo;
                break;
            }
        }
        if (newLigandBonds[0] == null)
            // Restoration not possible
            return null;
    }
    if (stChange.ligand1Deleted) {
        IAtom at = dbsc.getStereoBond().getAtom(1);
        // Searching for a neighbor with a single bond
        for (IBond bo : target.getConnectedBondsList(at)) {
            if (bo.getOrder() == IBond.Order.SINGLE) {
                newLigandBonds[1] = bo;
                FlagInvertStereo = !FlagInvertStereo;
                break;
            }
        }
        if (newLigandBonds[1] == null)
            // Restoration not possible
            return null;
    }
    Conformation stereo;
    if (FlagInvertStereo)
        stereo = dbsc.getStereo().invert();
    else
        stereo = dbsc.getStereo();
    return new DoubleBondStereochemistry(dbsc.getStereoBond(), newLigandBonds, stereo);
}
Also used : DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) Conformation(org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation)

Example 2 with Conformation

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation in project ambit-mirror by ideaconsult.

the class SMIRKSManager method applyStereoTransformAtLocation.

public void applyStereoTransformAtLocation(IAtomContainer target, List<IAtom> rMap, List<IAtom> newProdAtoms, SMIRKSReaction reaction) {
    // System.out.println("**** applyStereoTransformAtLocation");
    // Stereo transformation will be performed by means of removeList and addList
    List<IStereoElement> removeList = new ArrayList<IStereoElement>();
    List<IStereoElement> addList = new ArrayList<IStereoElement>();
    for (StereoDBTransformation dbTr : reaction.steroDBTransformations) {
        // System.out.println(dbTr.toString());
        switch(dbTr.prodDBStereo) {
            case UNDEFINED:
                {
                    // Remove stereo element (if left)
                    // In this case both reactant atoms must be mapped so the target bond is taken from rMap
                    IBond tStereoBo = target.getBond(rMap.get(dbTr.reactDBAt1), rMap.get(dbTr.reactDBAt2));
                    if (tStereoBo != null) {
                        DoubleBondStereochemistry dbsc = StereoChemUtils.findDBStereoElementByStereoBond(tStereoBo, target);
                        if (dbsc != null)
                            removeList.add(dbsc);
                    }
                }
                break;
            case OPPOSITE_OR_UNDEFINED:
                // TODO some special treatment
                break;
            case TOGETHER_OR_UNDEFINED:
                // TODO some special treatment
                break;
            case OPPOSITE:
            case TOGETHER:
                {
                    // System.out.println("  ** StereoDBTransformation product TOGETHER or OPPOSITE");
                    // Getting the target atoms for the db stereo bond
                    // If atom is mapped (i.e. reactDBAt1/2 != -1) it is taken form rMap otherwise
                    // it is a newly created product atom
                    IAtom ta1, ta2;
                    if (dbTr.reactDBAt1 == -1)
                        ta1 = getNewProductAtomOnTargetByNumber(dbTr.prodDBAt1, /*target,*/
                        newProdAtoms, reaction);
                    else
                        ta1 = rMap.get(dbTr.reactDBAt1);
                    if (dbTr.reactDBAt2 == -1)
                        ta2 = getNewProductAtomOnTargetByNumber(dbTr.prodDBAt2, /*target,*/
                        newProdAtoms, reaction);
                    else
                        ta2 = rMap.get(dbTr.reactDBAt2);
                    // System.out.println(" **" + ta1 + "  " + ta2);
                    IBond tStereoBo = target.getBond(ta1, ta2);
                    if (tStereoBo != null) {
                        DoubleBondStereochemistry dbsc = StereoChemUtils.findDBStereoElementByStereoBond(tStereoBo, target);
                        // Deleting existing stereo element
                        if (dbsc != null)
                            removeList.add(dbsc);
                        IAtom tLig1, tLig2;
                        if (dbTr.prodLigand1ReactMap == -1)
                            // product ligand is unmapped i.e. it is a newly created atom
                            tLig1 = getNewProductAtomOnTargetByNumber(dbTr.prodLigand1, /*target,*/
                            newProdAtoms, reaction);
                        else
                            tLig1 = rMap.get(dbTr.prodLigand1ReactMap);
                        if (dbTr.prodLigand2ReactMap == -1)
                            // product ligand is unmapped i.e. it is a newly created atom
                            tLig2 = getNewProductAtomOnTargetByNumber(dbTr.prodLigand2, /*target,*/
                            newProdAtoms, reaction);
                        else
                            tLig2 = rMap.get(dbTr.prodLigand2ReactMap);
                        // Creating new double bond stereo element
                        if ((tLig1 != null) && (tLig2 != null)) {
                            // System.out.println("  ** Creating new double bond stereo element ");
                            IBond[] newBonds = new IBond[2];
                            // Other wise CDKToBeam.addGeometricConfiguration() throws NullPointer Exception
                            if (ta1 == tStereoBo.getAtom(0)) {
                                newBonds[0] = target.getBond(ta1, tLig1);
                                newBonds[1] = target.getBond(ta2, tLig2);
                            } else {
                                newBonds[1] = target.getBond(ta1, tLig1);
                                newBonds[0] = target.getBond(ta2, tLig2);
                            }
                            if ((newBonds[0] != null) && newBonds[1] != null) {
                                Conformation newStereo;
                                if (dbTr.prodDBStereo == DBStereo.OPPOSITE)
                                    newStereo = Conformation.OPPOSITE;
                                else
                                    newStereo = Conformation.TOGETHER;
                                DoubleBondStereochemistry newDbsc = new DoubleBondStereochemistry(tStereoBo, newBonds, newStereo);
                                addList.add(newDbsc);
                            }
                        }
                    }
                }
                break;
        }
    }
    for (StereoChiralAtTransformation chirTransf : reaction.chiralAtTransformations) {
        switch(chirTransf.prodChirality) {
            case SmartsConst.ChC_Unspec:
                {
                    // Remove stereo element (if left)
                    // In this case chiral center is mapped so the target bond is taken from rMap
                    IAtom tChirAt = rMap.get(chirTransf.reactChiralAtom);
                    if (tChirAt != null) {
                        // TODO Check for extended chirality + handling
                        TetrahedralChirality thc = StereoChemUtils.findTetrahedralChiralityByChiralCenter(tChirAt, target);
                        if (thc != null)
                            removeList.add(thc);
                    }
                }
                break;
            case SmartsConst.ChC_AntiClock:
            case SmartsConst.ChC_Clock:
                {
                    // Getting the target chiral atom
                    // If atom is mapped it is taken form rMap otherwise
                    // it is a newly created product atom
                    IAtom tChirAt;
                    if (chirTransf.reactChiralAtom == -1)
                        tChirAt = getNewProductAtomOnTargetByNumber(chirTransf.prodChiralAtom, /*target,*/
                        newProdAtoms, reaction);
                    else
                        tChirAt = rMap.get(chirTransf.reactChiralAtom);
                    if (tChirAt != null) {
                        // TODO Check for extended chirality + handling
                        TetrahedralChirality thc = StereoChemUtils.findTetrahedralChiralityByChiralCenter(tChirAt, target);
                        if (thc != null)
                            removeList.add(thc);
                        IAtom[] newLigands = new IAtom[chirTransf.prodLigands.length];
                        for (int i = 0; i < chirTransf.prodLigands.length; i++) {
                            if (chirTransf.prodLigandsReactMap[i] == -1)
                                // product ligand is unmapped i.e. it is a newly created
                                newLigands[i] = getNewProductAtomOnTargetByNumber(chirTransf.prodLigands[i], /*target,*/
                                newProdAtoms, reaction);
                            else
                                newLigands[i] = rMap.get(chirTransf.prodLigandsReactMap[i]);
                        }
                        Stereo newStereo;
                        if (chirTransf.prodChirality == SmartsConst.ChC_Clock)
                            newStereo = Stereo.CLOCKWISE;
                        else
                            newStereo = Stereo.ANTI_CLOCKWISE;
                        TetrahedralChirality newThc = new TetrahedralChirality(tChirAt, newLigands, newStereo);
                        addList.add(newThc);
                    }
                }
                break;
        }
    }
    // Set new stereo according to the removeList and addList info
    List<IStereoElement> newStereo = new ArrayList<IStereoElement>();
    for (IStereoElement el : target.stereoElements()) {
        if (removeList.contains(el))
            continue;
        else
            newStereo.add(el);
    }
    for (IStereoElement el : addList) newStereo.add(el);
    target.setStereoElements(newStereo);
}
Also used : TetrahedralChirality(org.openscience.cdk.stereo.TetrahedralChirality) DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) ArrayList(java.util.ArrayList) IBond(org.openscience.cdk.interfaces.IBond) Stereo(org.openscience.cdk.interfaces.ITetrahedralChirality.Stereo) DBStereo(ambit2.smarts.DoubleBondStereoInfo.DBStereo) IStereoElement(org.openscience.cdk.interfaces.IStereoElement) IAtom(org.openscience.cdk.interfaces.IAtom) Conformation(org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation)

Example 3 with Conformation

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation in project cdk by cdk.

the class SmartsQueryVisitor method visit.

public Object visit(ASTGroup node, Object data) {
    IAtomContainer fullQuery = (IAtomContainer) data;
    if (fullQuery == null)
        fullQuery = new QueryAtomContainer(builder);
    // keeps track of component grouping
    int[] components = fullQuery.getProperty("COMPONENT.GROUPING") != null ? fullQuery.getProperty("COMPONENT.GROUPING", int[].class) : new int[0];
    int maxId = 0;
    if (components.length > 0) {
        for (int id : components) if (id > maxId)
            maxId = id;
    }
    for (int i = 0; i < node.jjtGetNumChildren(); i++) {
        ASTSmarts smarts = (ASTSmarts) node.jjtGetChild(i);
        ringAtoms = new RingIdentifierAtom[10];
        query = new QueryAtomContainer(builder);
        smarts.jjtAccept(this, null);
        // update component info
        if (components.length > 0 || smarts.componentId() > 0) {
            components = Arrays.copyOf(components, 1 + fullQuery.getAtomCount() + query.getAtomCount());
            int id = smarts.componentId();
            Arrays.fill(components, fullQuery.getAtomCount(), components.length, id);
            if (id > maxId)
                maxId = id;
        }
        fullQuery.add(query);
    }
    // only store if there was a component grouping
    if (maxId > 0) {
        // we left space to store how many groups there were
        components[components.length - 1] = maxId;
        fullQuery.setProperty("COMPONENT.GROUPING", components);
    }
    // create tetrahedral elements
    for (IAtom atom : neighbors.keySet()) {
        List<IAtom> localNeighbors = neighbors.get(atom);
        if (localNeighbors.size() == 4) {
            fullQuery.addStereoElement(new TetrahedralChirality(atom, localNeighbors.toArray(new IAtom[4]), // <- to be modified later
            ITetrahedralChirality.Stereo.CLOCKWISE));
        } else if (localNeighbors.size() == 5) {
            // remove central atom (which represented implicit part)
            localNeighbors.remove(atom);
            fullQuery.addStereoElement(new TetrahedralChirality(atom, localNeighbors.toArray(new IAtom[4]), // <- to be modified later
            ITetrahedralChirality.Stereo.CLOCKWISE));
        }
    }
    // handle logical bonds i.e. C/C-,=C/C
    for (IBond bond : doubleBonds) {
        IAtom left = bond.getBegin();
        IAtom right = bond.getEnd();
        StereoBond leftBond = findStereoBond(left);
        StereoBond rightBond = findStereoBond(right);
        if (leftBond == null || rightBond == null)
            continue;
        Conformation conformation = leftBond.direction(left) == rightBond.direction(right) ? Conformation.TOGETHER : Conformation.OPPOSITE;
        fullQuery.addStereoElement(new DoubleBondStereochemistry(bond, new IBond[] { leftBond, rightBond }, conformation));
    }
    return fullQuery;
}
Also used : ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) TetrahedralChirality(org.openscience.cdk.stereo.TetrahedralChirality) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) IBond(org.openscience.cdk.interfaces.IBond) QueryAtomContainer(org.openscience.cdk.isomorphism.matchers.QueryAtomContainer) IQueryAtomContainer(org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) StereoBond(org.openscience.cdk.isomorphism.matchers.smarts.StereoBond) Conformation(org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation)

Example 4 with Conformation

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation in project cdk by cdk.

the class CIPTool method getCIPChirality.

public static CIP_CHIRALITY getCIPChirality(IAtomContainer container, IDoubleBondStereochemistry stereoCenter) {
    IBond stereoBond = stereoCenter.getStereoBond();
    IBond leftBond = stereoCenter.getBonds()[0];
    IBond rightBond = stereoCenter.getBonds()[1];
    // the following variables are usd to label the atoms - makes things
    // a little more concise
    // 
    // x       y       x
    // \     /         \
    // u = v    or     u = v
    // \
    // y
    // 
    IAtom u = stereoBond.getBegin();
    IAtom v = stereoBond.getEnd();
    IAtom x = leftBond.getOther(u);
    IAtom y = rightBond.getOther(v);
    Conformation conformation = stereoCenter.getStereo();
    ILigand[] leftLigands = getLigands(u, container, v);
    ILigand[] rightLigands = getLigands(v, container, u);
    if (leftLigands.length > 2 || rightLigands.length > 2)
        return CIP_CHIRALITY.NONE;
    // invert if x/y aren't in the first position
    if (!leftLigands[0].getLigandAtom().equals(x))
        conformation = conformation.invert();
    if (!rightLigands[0].getLigandAtom().equals(y))
        conformation = conformation.invert();
    int p = permParity(leftLigands) * permParity(rightLigands);
    if (p == 0)
        return CIP_CHIRALITY.NONE;
    if (p < 0)
        conformation = conformation.invert();
    if (conformation == Conformation.TOGETHER)
        return CIP_CHIRALITY.Z;
    if (conformation == Conformation.OPPOSITE)
        return CIP_CHIRALITY.E;
    return CIP_CHIRALITY.NONE;
}
Also used : IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) Conformation(org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation)

Example 5 with Conformation

use of org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation in project cdk by cdk.

the class AtomContainerManipulator method suppressHydrogens.

/**
 * Suppress any explicit hydrogens in the provided container. Only hydrogens
 * that can be represented as a hydrogen count value on the atom are
 * suppressed. The container is updated and no elements are copied, please
 * use either {@link #copyAndSuppressedHydrogens} if you would to preserve
 * the old instance.
 *
 * @param org the container from which to remove hydrogens
 * @return the input for convenience
 * @see #copyAndSuppressedHydrogens
 */
public static IAtomContainer suppressHydrogens(IAtomContainer org) {
    boolean anyHydrogenPresent = false;
    for (IAtom atom : org.atoms()) {
        if (atom.getAtomicNumber() == IElement.H) {
            anyHydrogenPresent = true;
            break;
        }
    }
    if (!anyHydrogenPresent)
        return org;
    // crossing atoms, positional variation atoms etc
    Set<IAtom> xatoms = Collections.emptySet();
    Collection<Sgroup> sgroups = org.getProperty(CDKConstants.CTAB_SGROUPS);
    if (sgroups != null) {
        xatoms = new HashSet<>();
        for (Sgroup sgroup : sgroups) {
            for (IBond bond : sgroup.getBonds()) {
                xatoms.add(bond.getBegin());
                xatoms.add(bond.getEnd());
            }
        }
    }
    // we need fast adjacency checks (to check for suppression and
    // update hydrogen counts)
    GraphUtil.EdgeToBondMap bondmap = GraphUtil.EdgeToBondMap.withSpaceFor(org);
    final int[][] graph = GraphUtil.toAdjList(org, bondmap);
    final int nOrgAtoms = org.getAtomCount();
    final int nOrgBonds = org.getBondCount();
    int nCpyAtoms = 0;
    int nCpyBonds = 0;
    final Set<IAtom> hydrogens = new HashSet<>(nOrgAtoms);
    final Set<IBond> bondsToHydrogens = new HashSet<>();
    final IAtom[] cpyAtoms = new IAtom[nOrgAtoms];
    // be suppressed
    for (int v = 0; v < nOrgAtoms; v++) {
        final IAtom atom = org.getAtom(v);
        if (suppressibleHydrogen(org, graph, bondmap, v) && !xatoms.contains(atom)) {
            hydrogens.add(atom);
            incrementImplHydrogenCount(org.getAtom(graph[v][0]));
        } else {
            cpyAtoms[nCpyAtoms++] = atom;
        }
    }
    // none of the hydrogens could be suppressed - no changes need to be made
    if (hydrogens.isEmpty())
        return org;
    // we now update the bonds - we have auxiliary variable remaining that
    // bypasses the set membership checks if all suppressed bonds are found
    IBond[] cpyBonds = new IBond[nOrgBonds - hydrogens.size()];
    int remaining = hydrogens.size();
    for (final IBond bond : org.bonds()) {
        if (remaining > 0 && (hydrogens.contains(bond.getBegin()) || hydrogens.contains(bond.getEnd()))) {
            bondsToHydrogens.add(bond);
            remaining--;
            continue;
        }
        cpyBonds[nCpyBonds++] = bond;
    }
    // same number of bonds otherwise the containers is a strange
    if (nCpyBonds != cpyBonds.length)
        throw new IllegalArgumentException("number of removed bonds was less than the number of removed hydrogens");
    List<IStereoElement> elements = new ArrayList<>();
    for (IStereoElement se : org.stereoElements()) {
        if (se instanceof ITetrahedralChirality) {
            ITetrahedralChirality tc = (ITetrahedralChirality) se;
            IAtom focus = tc.getChiralAtom();
            IAtom[] neighbors = tc.getLigands();
            boolean updated = false;
            for (int i = 0; i < neighbors.length; i++) {
                if (hydrogens.contains(neighbors[i])) {
                    neighbors[i] = focus;
                    updated = true;
                }
            }
            // no changes
            if (!updated) {
                elements.add(tc);
            } else {
                TetrahedralChirality e = new TetrahedralChirality(focus, neighbors, tc.getStereo());
                e.setGroupInfo(tc.getGroupInfo());
                elements.add(e);
            }
        } else if (se instanceof ExtendedTetrahedral) {
            ExtendedTetrahedral tc = (ExtendedTetrahedral) se;
            IAtom focus = tc.getFocus();
            IAtom[] carriers = tc.getCarriers().toArray(new IAtom[4]);
            IAtom[] ends = ExtendedTetrahedral.findTerminalAtoms(org, focus);
            boolean updated = false;
            for (int i = 0; i < carriers.length; i++) {
                if (hydrogens.contains(carriers[i])) {
                    if (org.getBond(carriers[i], ends[0]) != null)
                        carriers[i] = ends[0];
                    else
                        carriers[i] = ends[1];
                    updated = true;
                }
            }
            // no changes
            if (!updated) {
                elements.add(tc);
            } else {
                elements.add(new ExtendedTetrahedral(focus, carriers, tc.getConfigOrder()));
            }
        } else if (se instanceof IDoubleBondStereochemistry) {
            IDoubleBondStereochemistry db = (IDoubleBondStereochemistry) se;
            Conformation conformation = db.getStereo();
            IBond orgStereo = db.getStereoBond();
            IBond orgLeft = db.getBonds()[0];
            IBond orgRight = db.getBonds()[1];
            // we use the following variable names to refer to the
            // double bond atoms and substituents
            // x       y
            // \     /
            // u = v
            IAtom u = orgStereo.getBegin();
            IAtom v = orgStereo.getEnd();
            IAtom x = orgLeft.getOther(u);
            IAtom y = orgRight.getOther(v);
            // if xNew == x and yNew == y we don't need to find the
            // connecting bonds
            IAtom xNew = x;
            IAtom yNew = y;
            if (hydrogens.contains(x)) {
                conformation = conformation.invert();
                xNew = findSingleBond(org, u, x);
            }
            if (hydrogens.contains(y)) {
                conformation = conformation.invert();
                yNew = findSingleBond(org, v, y);
            }
            // is removed. example [2H]/C=C/[H]
            if (x == null || y == null || xNew == null || yNew == null)
                continue;
            // no changes
            if (x.equals(xNew) && y.equals(yNew)) {
                elements.add(db);
                continue;
            }
            // XXX: may perform slow operations but works for now
            IBond cpyLeft = !Objects.equals(xNew, x) ? org.getBond(u, xNew) : orgLeft;
            IBond cpyRight = !Objects.equals(yNew, y) ? org.getBond(v, yNew) : orgRight;
            elements.add(new DoubleBondStereochemistry(orgStereo, new IBond[] { cpyLeft, cpyRight }, conformation));
        } else if (se instanceof ExtendedCisTrans) {
            ExtendedCisTrans db = (ExtendedCisTrans) se;
            int config = db.getConfigOrder();
            IBond focus = db.getFocus();
            IBond orgLeft = db.getCarriers().get(0);
            IBond orgRight = db.getCarriers().get(1);
            // we use the following variable names to refer to the
            // extended double bond atoms and substituents
            // x       y
            // \     /
            // u===v
            IAtom[] ends = ExtendedCisTrans.findTerminalAtoms(org, focus);
            IAtom u = ends[0];
            IAtom v = ends[1];
            IAtom x = orgLeft.getOther(u);
            IAtom y = orgRight.getOther(v);
            // if xNew == x and yNew == y we don't need to find the
            // connecting bonds
            IAtom xNew = x;
            IAtom yNew = y;
            if (hydrogens.contains(x)) {
                config ^= 0x3;
                xNew = findSingleBond(org, u, x);
            }
            if (hydrogens.contains(y)) {
                config ^= 0x3;
                yNew = findSingleBond(org, v, y);
            }
            // is removed. example [2H]/C=C/[H]
            if (x == null || y == null || xNew == null || yNew == null)
                continue;
            // no changes
            if (x.equals(xNew) && y.equals(yNew)) {
                elements.add(db);
                continue;
            }
            // XXX: may perform slow operations but works for now
            IBond cpyLeft = !Objects.equals(xNew, x) ? org.getBond(u, xNew) : orgLeft;
            IBond cpyRight = !Objects.equals(yNew, y) ? org.getBond(v, yNew) : orgRight;
            elements.add(new ExtendedCisTrans(focus, new IBond[] { cpyLeft, cpyRight }, config));
        } else if (se instanceof Atropisomeric) {
            // can not have any H's
            elements.add(se);
        }
    }
    org.setAtoms(Arrays.copyOf(cpyAtoms, nCpyAtoms));
    org.setBonds(cpyBonds);
    org.setStereoElements(elements);
    if (org.getSingleElectronCount() > 0) {
        Set<ISingleElectron> remove = new HashSet<>();
        for (ISingleElectron se : org.singleElectrons()) {
            if (hydrogens.contains(se.getAtom()))
                remove.add(se);
        }
        for (ISingleElectron se : remove) {
            org.removeSingleElectron(se);
        }
    }
    if (org.getLonePairCount() > 0) {
        Set<ILonePair> remove = new HashSet<>();
        for (ILonePair lp : org.lonePairs()) {
            if (hydrogens.contains(lp.getAtom()))
                remove.add(lp);
        }
        for (ILonePair lp : remove) {
            org.removeLonePair(lp);
        }
    }
    if (sgroups != null) {
        for (Sgroup sgroup : sgroups) {
            if (sgroup.getValue(SgroupKey.CtabParentAtomList) != null) {
                Collection<IAtom> pal = sgroup.getValue(SgroupKey.CtabParentAtomList);
                pal.removeAll(hydrogens);
            }
            for (IAtom hydrogen : hydrogens) sgroup.removeAtom(hydrogen);
            for (IBond bondToHydrogen : bondsToHydrogens) sgroup.removeBond(bondToHydrogen);
        }
        org.setProperty(CDKConstants.CTAB_SGROUPS, sgroups);
    }
    return org;
}
Also used : ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) TetrahedralChirality(org.openscience.cdk.stereo.TetrahedralChirality) ILonePair(org.openscience.cdk.interfaces.ILonePair) IBond(org.openscience.cdk.interfaces.IBond) ArrayList(java.util.ArrayList) Sgroup(org.openscience.cdk.sgroup.Sgroup) ISingleElectron(org.openscience.cdk.interfaces.ISingleElectron) DoubleBondStereochemistry(org.openscience.cdk.stereo.DoubleBondStereochemistry) IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) IAtom(org.openscience.cdk.interfaces.IAtom) HashSet(java.util.HashSet) IDoubleBondStereochemistry(org.openscience.cdk.interfaces.IDoubleBondStereochemistry) Atropisomeric(org.openscience.cdk.stereo.Atropisomeric) GraphUtil(org.openscience.cdk.graph.GraphUtil) ITetrahedralChirality(org.openscience.cdk.interfaces.ITetrahedralChirality) ExtendedTetrahedral(org.openscience.cdk.stereo.ExtendedTetrahedral) IStereoElement(org.openscience.cdk.interfaces.IStereoElement) ExtendedCisTrans(org.openscience.cdk.stereo.ExtendedCisTrans) Conformation(org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation)

Aggregations

IBond (org.openscience.cdk.interfaces.IBond)6 Conformation (org.openscience.cdk.interfaces.IDoubleBondStereochemistry.Conformation)6 IAtom (org.openscience.cdk.interfaces.IAtom)5 DoubleBondStereochemistry (org.openscience.cdk.stereo.DoubleBondStereochemistry)5 ArrayList (java.util.ArrayList)3 TetrahedralChirality (org.openscience.cdk.stereo.TetrahedralChirality)3 IStereoElement (org.openscience.cdk.interfaces.IStereoElement)2 ITetrahedralChirality (org.openscience.cdk.interfaces.ITetrahedralChirality)2 ExtendedCisTrans (org.openscience.cdk.stereo.ExtendedCisTrans)2 DBStereo (ambit2.smarts.DoubleBondStereoInfo.DBStereo)1 HashSet (java.util.HashSet)1 List (java.util.List)1 GraphUtil (org.openscience.cdk.graph.GraphUtil)1 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)1 IDoubleBondStereochemistry (org.openscience.cdk.interfaces.IDoubleBondStereochemistry)1 ILonePair (org.openscience.cdk.interfaces.ILonePair)1 ISingleElectron (org.openscience.cdk.interfaces.ISingleElectron)1 Stereo (org.openscience.cdk.interfaces.ITetrahedralChirality.Stereo)1 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)1 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)1