Get all molecule of a {@link IReaction}: reactants + products.

@param reaction  The IReaction
@return The IAtomContainerSet
320410
public static IAtomContainerSet getAllMolecules(IReaction reaction) {
        IAtomContainerSet moleculeSet = reaction.getBuilder().newInstance(IAtomContainerSet.class);

        moleculeSet.add(getAllReactants(reaction));
        moleculeSet.add(getAllAgents(reaction));
        moleculeSet.add(getAllProducts(reaction));

        return moleculeSet;
    }
799052
@Override
    public void setScale(IReactionSet reactionSet) {
        double bondLength = AverageBondLengthCalculator.calculateAverageBondLength(reactionSet);
        double scale = this.calculateScaleForBondLength(bondLength);

        // store the scale so that other components can access it
        this.rendererModel.getParameter(Scale.class).setValue(scale);
    }
319797
public static IAtom[] getAtomArray(IAtomContainer container) {
        IAtom[] ret = new IAtom[container.getAtomCount()];
        for (int i = 0; i < ret.length; ++i)
            ret[i] = container.getAtom(i);
        return ret;
    }
122467
public static IReaction getRelevantReaction(IChemModel chemModel, IAtom atom) {
        IReaction reaction = null;
        if (chemModel.getReactionSet() != null) {
            IReactionSet reactionSet = chemModel.getReactionSet();
            reaction = ReactionSetManipulator.getRelevantReaction(reactionSet, atom);
        }
        return reaction;
    }
471539
public static IReactionSet getAllReactions(IReactionScheme scheme) {
        IReactionSet reactionSet = scheme.getBuilder().newInstance(IReactionSet.class);

        // A ReactionScheme can contain other IRreactionSet objects
        if (scheme.getReactionSchemeCount() != 0) for (IReactionScheme schemeInt : scheme.reactionSchemes()) {
            for (IReaction reaction : getAllReactions(schemeInt).reactions())
                reactionSet.addReaction(reaction);
        }
        for (IReaction reaction : scheme.reactions())
            reactionSet.addReaction(reaction);

        return reactionSet;
    }
681136
private IAtomContainer toFragment(int[] vertices) {

        int n = vertices.length;

        Set<IAtom> atoms = new HashSet<IAtom>(n > 3 ? n + 1 + n / 3 : n);
        List<IBond> bonds = new ArrayList<IBond>();

        // fill the atom set
        for (int v : vertices) {
            atoms.add(container.getAtom(v));
        }

        // include bonds that have both atoms in the atoms set
        for (IBond bond : container.bonds()) {
            IAtom either = bond.getBegin();
            IAtom other = bond.getEnd();
            if (atoms.contains(either) && atoms.contains(other)) {
                bonds.add(bond);
            }
        }

        IAtomContainer fragment = container.getBuilder().newInstance(IAtomContainer.class, 0, 0, 0, 0);

        fragment.setAtoms(atoms.toArray(new IAtom[n]));
        fragment.setBonds(bonds.toArray(new IBond[bonds.size()]));

        return fragment;
    }
1358257
@Override
    public Collection<List<IAtom>> findRings(IAtomContainer molecule) {
        if (molecule == null) return null;
        rings.clear();
        PathGraph graph = new PathGraph(molecule);

        for (int i = 0; i < molecule.getAtomCount(); i++) {
            List<PathEdge> edges = graph.remove(molecule.getAtom(i));

            for (PathEdge edge : edges) {
                List<IAtom> ring = edge.getAtoms();
                rings.add(ring);
            }
        }

        return rings;
    }
1353324
def compose(self):
        
        rr = self.__reagents + self.__reactants
        if rr:
            if not all(isinstance(x, (MoleculeContainer, CGRContainer)) for x in rr):
                raise TypeError('Queries not composable')
            r = reduce(or_, rr)
        else:
            r = MoleculeContainer()
        if self.__products:
            if not all(isinstance(x, (MoleculeContainer, CGRContainer)) for x in self.__products):
                raise TypeError('Queries not composable')
            p = reduce(or_, self.__products)
        else:
            p = MoleculeContainer()
        return r ^ p
864705
public static List<IReaction> getAllReactions(IChemFile file) {
        List<IReaction> reactonList = new ArrayList<IReaction>();
        List<IChemModel> chemModel = getAllChemModels(file);
        for (int f = 0; f < chemModel.size(); f++) {
            for (IReaction reaction : chemModel.get(f).getReactionSet().reactions()) {
                reactonList.add(reaction);
            }
        }
        return reactonList;
    }
1149754
public IAtom getNextUnplacedHeavyAtomWithAliphaticPlacedNeighbour(IAtomContainer molecule) {
        Iterator<IBond> bonds = molecule.bonds().iterator();
        while (bonds.hasNext()) {
            IBond bond = bonds.next();
            if (bond.getBegin().getFlag(CDKConstants.ISPLACED) && !(bond.getEnd().getFlag(CDKConstants.ISPLACED))) {
                if (isAliphaticHeavyAtom(bond.getEnd())) {
                    return bond.getEnd();
                }
            }
            if (bond.getEnd().getFlag(CDKConstants.ISPLACED) && !(bond.getBegin().getFlag(CDKConstants.ISPLACED))) {
                if (isAliphaticHeavyAtom(bond.getBegin())) {
                    return bond.getBegin();
                }
            }
        }
        return null;
    }
274766
public static List<IChemObject> getAllChemObjects(IAtomContainerSet set) {
        ArrayList<IChemObject> list = new ArrayList<IChemObject>();
        list.add(set);
        for (IAtomContainer atomContainer : set.atomContainers()) {
            list.add(atomContainer);
        }
        return list;
    }
567106
def _convert_reaction(self, reaction):
        if not (reaction['reactants'] or reaction['products'] or reaction['reagents']):
            raise ValueError('empty reaction')
        maps = {'reactants': [], 'products': [], 'reagents': []}
        for i, tmp in maps.items():
            for molecule in reaction[i]:
                used = set()
                for atom in molecule['atoms']:
                    m = atom['mapping']
                    if m:
                        if m in used:
                            if not self._ignore:
                                raise MappingError('mapping in molecules should be unique')
                            warning(f'non-unique mapping in molecule: {m}')
                        else:
                            used.add(m)
                    tmp.append(m)

        length = count(max(max(maps['products'], default=0), max(maps['reactants'], default=0),
                           max(maps['reagents'], default=0)) + 1)

        ''' 
        '''
        for i, tmp in maps.items():
            used = set()
            maps[i] = remap = []
            for m in tmp:
                if not m:
                    remap.append(next(length))
                elif m in used:
                    if not self._ignore:
                        raise MappingError('mapping in reagents or products or reactants should be unique')
                    # force remap non unique atoms in molecules.
                    remap.append(next(length))
                    warning(f'mapping changed: {m} to {remap[-1]}')
                else:
                    remap.append(m)
                    used.add(m)

        if maps['reagents']:
            tmp = (set(maps['reactants']) | set(maps['products'])) & set(maps['reagents'])
            if tmp:
                e = f'reagents has map intersection with reactants or products: {tmp}'
                if not self._ignore:
                    raise MappingError(e)
                warning(e)
                maps['reagents'] = [x if x not in tmp else next(length) for x in maps['reagents']]

        ''' find breaks in map. e.g. 1,2,5,6. 3,4 - skipped
        '''
        if self.__remap:
            lose = sorted(set(range(1, next(length))) - set(maps['reactants']) - set(maps['products']) -
                          set(maps['reagents']), reverse=True)
            if lose:
                for i, tmp in maps.items():
                    if not tmp:
                        continue
                    for j in lose:
                        maps[i] = tmp = [x if x < j else x - 1 for x in tmp]
        ''' end
        '''
        rc = ReactionContainer(meta=reaction['meta'])
        for i, tmp in maps.items():
            shift = 0
            for j in reaction[i]:
                atom_len = len(j['atoms'])
                remapped = {x: y for x, y in enumerate(tmp[shift: atom_len + shift])}
                shift += atom_len
                g = self.__convert_structure(j, remapped)
                rc[i].append(g)
        return rc
625504
public static boolean has2DCoordinates(IReaction reaction) {
        for (IAtomContainer mol : reaction.getReactants().atomContainers())
            if (!has2DCoordinates(mol))
                return false;
        for (IAtomContainer mol : reaction.getProducts().atomContainers())
            if (!has2DCoordinates(mol))
                return false;
        for (IAtomContainer mol : reaction.getAgents().atomContainers())
            if (!has2DCoordinates(mol))
                return false;
        return true;
    }
1269110
public static Set<IBond> findMappedBonds(IReaction reaction) {
        Set<IBond> mapped = new HashSet<>();

        // first we collect the occurrance of mapped bonds from reacants then products
        Set<IntTuple> mappedReactantBonds = new HashSet<>();
        Set<IntTuple> mappedProductBonds  = new HashSet<>();
        for (IAtomContainer reactant : reaction.getReactants().atomContainers()) {
            for (IBond bond : reactant.bonds()) {
                Integer begidx = bond.getBegin().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                Integer endidx = bond.getEnd().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                if (begidx != null && endidx != null)
                    mappedReactantBonds.add(new IntTuple(begidx, endidx));
            }
        }
        // fail fast
        if (mappedReactantBonds.isEmpty())
            return Collections.emptySet();

        for (IAtomContainer product : reaction.getProducts().atomContainers()) {
            for (IBond bond : product.bonds()) {
                Integer begidx = bond.getBegin().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                Integer endidx = bond.getEnd().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                if (begidx != null && endidx != null)
                    mappedProductBonds.add(new IntTuple(begidx, endidx));
            }
        }
        // fail fast
        if (mappedProductBonds.isEmpty())
            return Collections.emptySet();

        // repeat above but now store any that are different or unmapped as being mapped
        for (IAtomContainer reactant : reaction.getReactants().atomContainers()) {
            for (IBond bond : reactant.bonds()) {
                Integer begidx = bond.getBegin().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                Integer endidx = bond.getEnd().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                if (begidx != null && endidx != null && mappedProductBonds.contains(new IntTuple(begidx, endidx)))
                    mapped.add(bond);
            }
        }
        for (IAtomContainer product : reaction.getProducts().atomContainers()) {
            for (IBond bond : product.bonds()) {
                Integer begidx = bond.getBegin().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                Integer endidx = bond.getEnd().getProperty(CDKConstants.ATOM_ATOM_MAPPING);
                if (begidx != null && endidx != null && mappedReactantBonds.contains(new IntTuple(begidx, endidx)))
                    mapped.add(bond);
            }
        }
        return mapped;
    }
836084
public static List<IAtomContainer> getAllAtomContainers(IRingSet set) {
        List<IAtomContainer> atomContainerList = new ArrayList<IAtomContainer>();
        for (IAtomContainer atomContainer : set.atomContainers()) {
            atomContainerList.add(atomContainer);
        }
        return atomContainerList;
    }
320873
public static List<IChemObject> getAllChemObjects(IChemModel chemModel) {
        List<IChemObject> list = new ArrayList<IChemObject>();
        // list.add(chemModel); // only add ChemObjects contained within
        ICrystal crystal = chemModel.getCrystal();
        if (crystal != null) {
            list.add(crystal);
        }
        IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
        if (moleculeSet != null) {
            list.add(moleculeSet);
            List<IChemObject> current = MoleculeSetManipulator.getAllChemObjects(moleculeSet);
            for (IChemObject chemObject : current) {
                if (!list.contains(chemObject)) list.add(chemObject);
            }
        }
        IReactionSet reactionSet = chemModel.getReactionSet();
        if (reactionSet != null) {
            list.add(reactionSet);
            List<IChemObject> current = ReactionSetManipulator.getAllChemObjects(reactionSet);
            for (IChemObject chemObject : current) {
                if (!list.contains(chemObject)) list.add(chemObject);
            }
        }
        return list;
    }
163485
@Override
    public IAtomContainer get(int i) {
        Point3d[] tmp = coordinates.get(i);
        for (int j = 0; j < atomContainer.getAtomCount(); j++) {
            IAtom atom = atomContainer.getAtom(j);
            atom.setPoint3d(tmp[j]);
        }
        return atomContainer;
    }