示例#1
0
        public override void TestInitiate_IAtomContainerSet_IAtomContainerSet()
        {
            var type = new RearrangementAnionReaction();

            /* [C-]-C=C-C */

            var setOfReactants = GetExampleReactants();
            var molecule       = setOfReactants[0];
            /* initiate */

            var paramList = new List <IParameterReaction>();
            var param     = new SetReactionCenter();

            param.IsSetParameter = false;
            paramList.Add(param);
            type.ParameterList = paramList;
            var setOfReactions = type.Initiate(setOfReactants, null);

            Assert.AreEqual(1, setOfReactions.Count);
            Assert.AreEqual(1, setOfReactions[0].Products.Count);

            var product = setOfReactions[0].Products[0];

            Assert.AreEqual(-1, product.Atoms[2].FormalCharge.Value);
            Assert.AreEqual(0, product.GetConnectedLonePairs(product.Atoms[1]).Count());

            /* C=C-[C-]-C */
            var molecule2 = GetExpectedProducts()[0];

            var queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(product);

            Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule2, queryAtom));
        }
示例#2
0
        public void TestMapping()
        {
            var type = new RearrangementAnionReaction();

            var setOfReactants = GetExampleReactants();
            var molecule       = setOfReactants[0];

            molecule.LonePairs.Add(CDK.Builder.NewLonePair(molecule.Atoms[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 product = setOfReactions[0].Products[0];

            Assert.AreEqual(11, setOfReactions[0].Mappings.Count);
            var mappedProductA1 = (IAtom)ReactionManipulator.GetMappedChemObject(setOfReactions[0], molecule.Atoms[0]);

            Assert.AreEqual(mappedProductA1, product.Atoms[0]);
            mappedProductA1 = (IAtom)ReactionManipulator.GetMappedChemObject(setOfReactions[0], molecule.Atoms[1]);
            Assert.AreEqual(mappedProductA1, product.Atoms[1]);
            mappedProductA1 = (IAtom)ReactionManipulator.GetMappedChemObject(setOfReactions[0], molecule.Atoms[2]);
            Assert.AreEqual(mappedProductA1, product.Atoms[2]);
        }
示例#3
0
        public void TestManuallyCentreActive()
        {
            var type = new RearrangementAnionReaction();

            var setOfReactants = GetExampleReactants();
            var molecule       = setOfReactants[0];

            /* manually put the center active */
            molecule.Atoms[0].IsReactiveCenter = true;
            molecule.Bonds[0].IsReactiveCenter = true;
            molecule.Atoms[1].IsReactiveCenter = true;
            molecule.Bonds[1].IsReactiveCenter = true;
            molecule.Atoms[2].IsReactiveCenter = true;
            molecule.Bonds[2].IsReactiveCenter = true;
            molecule.Atoms[3].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(1, setOfReactions[0].Products.Count);

            var product = setOfReactions[0].Products[0];

            /* C=C-[C-]-C */
            var molecule2 = GetExpectedProducts()[0];

            var queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(product);

            Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule2, queryAtom));
        }
示例#4
0
        public void TestCDKConstants_REACTIVE_CENTER()
        {
            var type = new RearrangementAnionReaction();

            var setOfReactants = GetExampleReactants();
            var molecule       = setOfReactants[0];

            /* manually put the reactive center */
            molecule.Atoms[0].IsReactiveCenter = true;
            molecule.Atoms[1].IsReactiveCenter = true;
            molecule.Atoms[2].IsReactiveCenter = true;
            molecule.Bonds[0].IsReactiveCenter = true;
            molecule.Bonds[1].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);

            var reactant = setOfReactions[0].Reactants[0];

            Assert.IsTrue(molecule.Atoms[0].IsReactiveCenter);
            Assert.IsTrue(reactant.Atoms[0].IsReactiveCenter);
            Assert.IsTrue(molecule.Atoms[1].IsReactiveCenter);
            Assert.IsTrue(reactant.Atoms[1].IsReactiveCenter);
            Assert.IsTrue(molecule.Atoms[2].IsReactiveCenter);
            Assert.IsTrue(reactant.Atoms[2].IsReactiveCenter);
            Assert.IsTrue(molecule.Bonds[0].IsReactiveCenter);
            Assert.IsTrue(reactant.Bonds[0].IsReactiveCenter);
            Assert.IsTrue(molecule.Bonds[1].IsReactiveCenter);
            Assert.IsTrue(reactant.Bonds[1].IsReactiveCenter);
        }
示例#5
0
        public void TestRearrangementAnionReaction()
        {
            var type = new RearrangementAnionReaction();

            Assert.IsNotNull(type);
        }
示例#6
0
        public void TestAutomaticSearchCentreActiveExample3()
        {
            var type = new RearrangementAnionReaction();

            /* [F+]=C1-[C-]-C=C-C=C1 */
            var molecule = builder.NewAtomContainer();

            molecule.Atoms.Add(builder.NewAtom("F"));
            molecule.Atoms[0].FormalCharge = 1;
            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.AddBond(molecule.Atoms[0], molecule.Atoms[1], BondOrder.Double);
            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.Atoms[2].FormalCharge = -1;
            molecule.LonePairs.Add(CDK.Builder.NewLonePair(molecule.Atoms[0]));
            molecule.AddBond(molecule.Atoms[1], molecule.Atoms[2], BondOrder.Single);
            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.AddBond(molecule.Atoms[2], molecule.Atoms[3], BondOrder.Single);
            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.AddBond(molecule.Atoms[3], molecule.Atoms[4], BondOrder.Double);
            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.AddBond(molecule.Atoms[4], molecule.Atoms[5], BondOrder.Single);
            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.AddBond(molecule.Atoms[5], molecule.Atoms[6], BondOrder.Double);
            molecule.AddBond(molecule.Atoms[6], molecule.Atoms[1], BondOrder.Single);

            AddExplicitHydrogens(molecule);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule);
            CDK.LonePairElectronChecker.Saturate(molecule);

            var setOfReactants = CDK.Builder.NewAtomContainerSet();

            setOfReactants.Add(molecule);

            /* initiate */
            MakeSureAtomTypesAreRecognized(molecule);

            var paramList = new List <IParameterReaction>();
            var param     = new SetReactionCenter();

            param.IsSetParameter = false;
            paramList.Add(param);
            type.ParameterList = paramList;
            var setOfReactions = type.Initiate(setOfReactants, null);

            Assert.AreEqual(2, setOfReactions.Count);
            Assert.AreEqual(1, setOfReactions[0].Products.Count);

            var product1 = setOfReactions[1].Products[0];

            /* [F+]=C1-[C=]-C-[C-]-C=C1 */
            var molecule2 = builder.NewAtomContainer();

            molecule2.Atoms.Add(builder.NewAtom("F"));
            molecule2.Atoms[0].FormalCharge = 1;
            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);
            molecule2.Atoms.Add(builder.NewAtom("C"));
            molecule2.AddBond(molecule2.Atoms[2], molecule2.Atoms[3], BondOrder.Double);
            molecule2.Atoms.Add(builder.NewAtom("C"));
            molecule2.Atoms[4].FormalCharge = -1;
            molecule2.AddBond(molecule2.Atoms[3], molecule2.Atoms[4], BondOrder.Single);
            molecule2.Atoms.Add(builder.NewAtom("C"));
            molecule2.AddBond(molecule2.Atoms[4], molecule2.Atoms[5], BondOrder.Single);
            molecule2.Atoms.Add(builder.NewAtom("C"));
            molecule2.AddBond(molecule2.Atoms[5], molecule2.Atoms[6], BondOrder.Double);
            molecule2.AddBond(molecule2.Atoms[6], molecule2.Atoms[1], BondOrder.Single);

            AddExplicitHydrogens(molecule2);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule2);
            CDK.LonePairElectronChecker.Saturate(molecule2);
            MakeSureAtomTypesAreRecognized(molecule2);
            var queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(product1);

            Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule2, queryAtom));

            //////////////////////////////////////////////////

            var product2 = setOfReactions[0].Products[0];

            /* F=c1ccccc1 */
            var molecule3 = builder.NewAtomContainer();

            molecule3.Atoms.Add(builder.NewAtom("F"));
            molecule3.Atoms.Add(builder.NewAtom("C"));
            molecule3.AddBond(molecule3.Atoms[0], molecule3.Atoms[1], BondOrder.Single);
            molecule3.Atoms.Add(builder.NewAtom("C"));
            molecule3.AddBond(molecule3.Atoms[1], molecule3.Atoms[2], BondOrder.Double);
            molecule3.Atoms.Add(builder.NewAtom("C"));
            molecule3.AddBond(molecule3.Atoms[2], molecule3.Atoms[3], BondOrder.Single);
            molecule3.Atoms.Add(builder.NewAtom("C"));
            molecule3.AddBond(molecule3.Atoms[3], molecule3.Atoms[4], BondOrder.Double);
            molecule3.Atoms.Add(builder.NewAtom("C"));
            molecule3.AddBond(molecule3.Atoms[4], molecule3.Atoms[5], BondOrder.Single);
            molecule3.Atoms.Add(builder.NewAtom("C"));
            molecule3.AddBond(molecule3.Atoms[5], molecule3.Atoms[6], BondOrder.Double);
            molecule3.AddBond(molecule3.Atoms[6], molecule3.Atoms[1], BondOrder.Single);

            AddExplicitHydrogens(molecule3);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule3);
            CDK.LonePairElectronChecker.Saturate(molecule3);
            MakeSureAtomTypesAreRecognized(molecule3);
            queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(product2);
            Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(molecule3, queryAtom));

            Assert.AreEqual(12, setOfReactions[0].Mappings.Count);
        }