public void TestMapping() { var type = new HyperconjugationReaction(); var setOfReactants = GetExampleReactants(); var molecule = setOfReactants[0]; /* automatic search of the center active */ var paramList = new List <IParameterReaction>(); var param = new SetReactionCenter(); param.IsSetParameter = false; paramList.Add(param); type.ParameterList = paramList; /* initiate */ var setOfReactions = type.Initiate(setOfReactants, null); var product1 = setOfReactions[0].Products[0]; var product2 = setOfReactions[0].Products[1]; Assert.AreEqual(3, setOfReactions.Count); Assert.AreEqual(2, setOfReactions[0].Products.Count); // if these assertions fail the atom order may have changed var mappedProductA1 = (IAtom)ReactionManipulator.GetMappedChemObject(setOfReactions[0], molecule.Atoms[1]); Assert.AreEqual(mappedProductA1, product1.Atoms[1]); mappedProductA1 = (IAtom)ReactionManipulator.GetMappedChemObject(setOfReactions[0], molecule.Atoms[2]); Assert.AreEqual(mappedProductA1, product1.Atoms[2]); mappedProductA1 = (IAtom)ReactionManipulator.GetMappedChemObject(setOfReactions[0], molecule.Atoms[6]); Assert.AreEqual(mappedProductA1, product2.Atoms[0]); }
public override void TestInitiate_IAtomContainerSet_IAtomContainerSet() { var type = new HyperconjugationReaction(); var setOfReactants = CDK.Builder.NewAtomContainerSet(); /* [C+]CC */ var molecule = builder.NewAtomContainer(); molecule.Atoms.Add(builder.NewAtom("C")); molecule.Atoms[0].FormalCharge = 1; molecule.Atoms.Add(builder.NewAtom("C")); molecule.AddBond(molecule.Atoms[0], molecule.Atoms[1], BondOrder.Single); molecule.Atoms.Add(builder.NewAtom("C")); molecule.AddBond(molecule.Atoms[1], molecule.Atoms[2], BondOrder.Single); AddExplicitHydrogens(molecule); setOfReactants.Add(molecule); /* automatic search of the center active */ var paramList = new List <IParameterReaction>(); var param = new SetReactionCenter(); param.IsSetParameter = false; paramList.Add(param); type.ParameterList = paramList; /* initiate */ MakeSureAtomTypesAreRecognized(molecule); var setOfReactions = type.Initiate(setOfReactants, null); Assert.AreEqual(2, setOfReactions.Count); Assert.AreEqual(2, setOfReactions[0].Products.Count); var product = setOfReactions[0].Products[0]; /* C=CC */ var molecule2 = builder.NewAtomContainer(); molecule2.Atoms.Add(builder.NewAtom("C")); molecule2.Atoms.Add(builder.NewAtom("C")); molecule2.AddBond(molecule2.Atoms[0], molecule2.Atoms[1], BondOrder.Double); molecule2.Atoms.Add(builder.NewAtom("C")); molecule2.AddBond(molecule2.Atoms[1], molecule2.Atoms[2], BondOrder.Single); AddExplicitHydrogens(molecule2); Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule2, product)); product = setOfReactions[0].Products[1]; /* [H+] */ molecule2 = builder.NewAtomContainer(); molecule2.Atoms.Add(builder.NewAtom("H")); molecule2.Atoms[0].FormalCharge = 1; Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule2, product)); }
public void TestWithNegativeCharge() { var type = new HyperconjugationReaction(); var setOfReactants = GetExampleReactants(); /* automatic search of the center active */ var paramList = new List <IParameterReaction>(); var param = new SetReactionCenter(); param.IsSetParameter = false; paramList.Add(param); type.ParameterList = paramList; /* initiate */ var setOfReactions = type.Initiate(setOfReactants, null); Assert.AreEqual(3, setOfReactions.Count); Assert.AreEqual(2, setOfReactions[0].Products.Count); var product = setOfReactions[0].Products[0]; var molecule2 = GetExpectedProducts()[0]; var queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(molecule2); Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(product, queryAtom)); product = setOfReactions[0].Products[1]; molecule2 = builder.NewAtomContainer(); molecule2.Atoms.Add(builder.NewAtom("H")); molecule2.Atoms[0].FormalCharge = 1; queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(product); Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule2, queryAtom)); }
public void TestCDKConstants_REACTIVE_CENTER() { var type = new HyperconjugationReaction(); var setOfReactants = GetExampleReactants(); var molecule = setOfReactants[0]; /* manually put the reactive center */ molecule.Atoms[1].IsReactiveCenter = true; molecule.Atoms[2].IsReactiveCenter = true; molecule.Atoms[6].IsReactiveCenter = true; molecule.Bonds[1].IsReactiveCenter = true; molecule.Bonds[5].IsReactiveCenter = true; var paramList = new List <IParameterReaction>(); var param = new SetReactionCenter(); param.IsSetParameter = true; paramList.Add(param); type.ParameterList = paramList; /* initiate */ var setOfReactions = type.Initiate(setOfReactants, null); IAtomContainer reactant1 = setOfReactions[0].Reactants[0]; Assert.IsTrue(molecule.Atoms[1].IsReactiveCenter); Assert.IsTrue(reactant1.Atoms[1].IsReactiveCenter); Assert.IsTrue(molecule.Atoms[2].IsReactiveCenter); Assert.IsTrue(reactant1.Atoms[2].IsReactiveCenter); Assert.IsTrue(molecule.Atoms[6].IsReactiveCenter); Assert.IsTrue(reactant1.Atoms[6].IsReactiveCenter); Assert.IsTrue(molecule.Bonds[1].IsReactiveCenter); Assert.IsTrue(reactant1.Bonds[1].IsReactiveCenter); Assert.IsTrue(molecule.Bonds[5].IsReactiveCenter); Assert.IsTrue(reactant1.Bonds[5].IsReactiveCenter); }
public void TestManuallyCentreActive() { var type = new HyperconjugationReaction(); var setOfReactants = GetExampleReactants(); var molecule = setOfReactants[0]; /* manually put the center active */ molecule.Atoms[1].IsReactiveCenter = true; molecule.Atoms[2].IsReactiveCenter = true; molecule.Atoms[6].IsReactiveCenter = true; molecule.Bonds[1].IsReactiveCenter = true; molecule.Bonds[5].IsReactiveCenter = true; var paramList = new List <IParameterReaction>(); var param = new SetReactionCenter(); param.IsSetParameter = true; paramList.Add(param); type.ParameterList = paramList; /* initiate */ var setOfReactions = type.Initiate(setOfReactants, null); Assert.AreEqual(1, setOfReactions.Count); Assert.AreEqual(2, setOfReactions[0].Products.Count); var product = setOfReactions[0].Products[0]; var molecule2 = GetExpectedProducts()[0]; var queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(product); Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule2, queryAtom)); }