private static void SetActiveCenters(IAtomContainer reactant, BondCheck bondChecker) { foreach (var bondi in reactant.Bonds) { IAtom atom1 = bondi.Begin; IAtom atom2 = bondi.End; if (bondChecker(bondi) && (atom1.FormalCharge ?? 0) == 0 && (atom2.FormalCharge ?? 0) == 0 && !reactant.GetConnectedSingleElectrons(atom1).Any() && !reactant.GetConnectedSingleElectrons(atom2).Any()) { bondi.IsReactiveCenter = true; atom1.IsReactiveCenter = true; atom2.IsReactiveCenter = true; } } }
private static void SetActiveCenters(IAtomContainer reactant, BondCheck bondCheck) { foreach (var bond in reactant.Bonds) { var atom1 = bond.Begin; var atom2 = bond.End; if ((bondCheck == null || bondCheck(bond)) && (atom1.FormalCharge ?? 0) == 0 && (atom2.FormalCharge ?? 0) == 0 && !reactant.GetConnectedSingleElectrons(atom1).Any() && !reactant.GetConnectedSingleElectrons(atom2).Any()) { atom1.IsReactiveCenter = true; atom2.IsReactiveCenter = true; bond.IsReactiveCenter = true; } } }
internal IReactionSet Initiate(IChemObjectSet <IAtomContainer> reactants, IChemObjectSet <IAtomContainer> agents, BondCheck bondChecker) { CheckInitiateParams(reactants, agents); IReactionSet setOfReactions = reactants.Builder.NewReactionSet(); IAtomContainer reactant = reactants[0]; // if the parameter hasActiveCenter is not fixed yet, set the active centers IParameterReaction ipr = base.GetParameterClass(typeof(SetReactionCenter)); if (ipr != null && !ipr.IsSetParameter) { SetActiveCenters(reactant, bondChecker); } foreach (var bondi in reactant.Bonds) { IAtom atom1 = bondi.Begin; IAtom atom2 = bondi.End; if (bondi.IsReactiveCenter && bondChecker(bondi) && atom1.IsReactiveCenter && atom2.IsReactiveCenter && (atom1.FormalCharge ?? 0) == 0 && (atom2.FormalCharge ?? 0) == 0 && !reactant.GetConnectedSingleElectrons(atom1).Any() && !reactant.GetConnectedSingleElectrons(atom2).Any()) { for (int j = 0; j < 2; j++) { var atomList = new List <IAtom>(); if (j == 0) { atomList.Add(atom1); atomList.Add(atom2); } else { atomList.Add(atom2); atomList.Add(atom1); } var bondList = new List <IBond> { bondi }; IChemObjectSet <IAtomContainer> moleculeSet = reactant.Builder.NewAtomContainerSet(); moleculeSet.Add(reactant); IReaction reaction = Mechanism.Initiate(moleculeSet, atomList, bondList); if (reaction == null) { continue; } else { setOfReactions.Add(reaction); } } } } return(setOfReactions); }