class RadicalSiteRrBetaReaction extends ReactionEngine implements IReactionProcess {

    @Override
    public IReactionSet initiate(IAtomContainerSet reactants, IAtomContainerSet agents) throws CDKException {

        logger.debug("initiate reaction: RadicalSiteRrBetaReaction");

        if (reactants.getAtomContainerCount() != 1) {
            throw new CDKException("RadicalSiteRrBetaReaction only expects one reactant");
        }
        if (agents != null) {
            throw new CDKException("RadicalSiteRrBetaReaction don't expects agents");
        }

        IReactionSet setOfReactions = reactants.getBuilder().newInstance(IReactionSet.class);
        IAtomContainer reactant = reactants.getAtomContainer(0);

        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(reactant);
        Aromaticity.cdkLegacy().apply(reactant);
        AllRingsFinder arf = new AllRingsFinder();
        IRingSet ringSet = arf.findAllRings(reactant);
        for (int ir = 0; ir < ringSet.getAtomContainerCount(); ir++) {
            IRing ring = (IRing) ringSet.getAtomContainer(ir);
            for (int jr = 0; jr < ring.getAtomCount(); jr++) {
                IAtom aring = ring.getAtom(jr);
                aring.setFlag(CDKConstants.ISINRING, true);
            }
        }
        /*
         * if the parameter hasActiveCenter is not fixed yet, set the active
         * centers
         */
        IParameterReact ipr = super.getParameterClass(SetReactionCenter.class);
        if (ipr != null && !ipr.isSetParameter()) setActiveCenters(reactant);

        HOSECodeGenerator hcg = new HOSECodeGenerator();
        Iterator<IAtom> atomis = reactant.atoms().iterator();
        while (atomis.hasNext()) {
            IAtom atomi = atomis.next();
            if (atomi.getFlag(CDKConstants.REACTIVE_CENTER) && reactant.getConnectedSingleElectronsCount(atomi) == 1) {

                hcg.getSpheres(reactant, atomi, 2, true);
                List<IAtom> atom1s = hcg.getNodesInSphere(2);

                hcg.getSpheres(reactant, atomi, 3, true);
                Iterator<IAtom> atomls = hcg.getNodesInSphere(3).iterator();
                while (atomls.hasNext()) {
                    IAtom atoml = atomls.next();
                    if (atoml != null && atoml.getFlag(CDKConstants.REACTIVE_CENTER)
                            && !atoml.getFlag(CDKConstants.ISINRING)
                            && (atoml.getFormalCharge() == CDKConstants.UNSET ? 0 : atoml.getFormalCharge()) == 0
                            && !atoml.getSymbol().equals("H") && reactant.getMaximumBondOrder(atoml) == IBond.Order.SINGLE) {

                        Iterator<IAtom> atomRs = reactant.getConnectedAtomsList(atoml).iterator();
                        while (atomRs.hasNext()) {
                            IAtom atomR = atomRs.next();
                            if (atom1s.contains(atomR)) continue;
                            if (reactant.getBond(atomR, atoml).getFlag(CDKConstants.REACTIVE_CENTER)
                                    && atomR.getFlag(CDKConstants.REACTIVE_CENTER)
                                    && (atomR.getFormalCharge() == CDKConstants.UNSET ? 0 : atomR.getFormalCharge()) == 0) {

                                ArrayList<IAtom> atomList = new ArrayList<IAtom>();
                                atomList.add(atomR);
                                atomList.add(atomi);
                                atomList.add(atoml);
                                ArrayList<IBond> bondList = new ArrayList<IBond>();
                                bondList.add(reactant.getBond(atomR, atoml));

                                IAtomContainerSet moleculeSet = reactant.getBuilder().newInstance(
                                        IAtomContainerSet.class);
                                moleculeSet.addAtomContainer(reactant);
                                IReaction reaction = mechanism.initiate(moleculeSet, atomList, bondList);
                                if (reaction == null)
                                    continue;
                                else
                                    setOfReactions.addReaction(reaction);

                            }

                        }

                    }
                }
            }
        }
        return setOfReactions;
    }

    public  RadicalSiteRrBetaReaction();

}