Esempio n. 1
0
        public override void TestInitiate_IAtomContainerSet_IAtomContainerSet()
        {
            /* Ionize(>C=O): C=CCC(=O)CC -> C=CCC(=O*)CC , set the reactive center */

            var reactant = builder.NewAtomContainer();//CreateFromSmiles("C=CCC(=O)CC")

            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("O"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.AddBond(reactant.Atoms[0], reactant.Atoms[1], BondOrder.Double);
            reactant.AddBond(reactant.Atoms[1], reactant.Atoms[2], BondOrder.Single);
            reactant.AddBond(reactant.Atoms[2], reactant.Atoms[3], BondOrder.Single);
            reactant.AddBond(reactant.Atoms[3], reactant.Atoms[4], BondOrder.Double);
            reactant.AddBond(reactant.Atoms[3], reactant.Atoms[5], BondOrder.Single);
            reactant.AddBond(reactant.Atoms[5], reactant.Atoms[6], BondOrder.Single);
            AddExplicitHydrogens(reactant);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(reactant);
            CDK.LonePairElectronChecker.Saturate(reactant);

            foreach (var atom in reactant.Atoms)
            {
                if (reactant.GetConnectedLonePairs(atom).Count() > 0)
                {
                    atom.IsReactiveCenter = true;
                }
            }

            var setOfReactants = CDK.Builder.NewAtomContainerSet();

            setOfReactants.Add(reactant);

            /* initiate */
            MakeSureAtomTypesAreRecognized(reactant);

            var type      = new ElectronImpactNBEReaction();
            var paramList = new List <IParameterReaction>();
            var param     = new SetReactionCenter
            {
                IsSetParameter = true
            };

            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 molecule = setOfReactions[0].Products[0];

            Assert.AreEqual(1, molecule.Atoms[4].FormalCharge.Value);
            Assert.AreEqual(1, molecule.GetConnectedSingleElectrons(molecule.Atoms[4]).Count());

            Assert.IsTrue(setOfReactions[0].Mappings.Any());
        }
Esempio n. 2
0
        public void TestMapping()
        {
            var type           = new ElectronImpactNBEReaction();
            var setOfReactants = GetExampleReactants();
            var molecule       = setOfReactants[0];

            /* automatic search of the center active */
            var paramList = new List <IParameterReaction>();
            var param     = new SetReactionCenter
            {
                IsSetParameter = false
            };

            paramList.Add(param);
            type.ParameterList = paramList;

            var setOfReactions = type.Initiate(setOfReactants, null);

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

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

            Assert.AreEqual(mappedProductA1, product.Atoms[1]);
        }
Esempio n. 3
0
        public void TestCDKConstants_REACTIVE_CENTER()
        {
            var type = new ElectronImpactNBEReaction();

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

            /* manually put the reactive center */
            molecule.Atoms[1].IsReactiveCenter = true;

            var paramList = new List <IParameterReaction>();
            var param     = new SetReactionCenter
            {
                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 reactant = setOfReactions[0].Reactants[0];

            Assert.IsTrue(molecule.Atoms[1].IsReactiveCenter);
            Assert.IsTrue(reactant.Atoms[1].IsReactiveCenter);
        }
Esempio n. 4
0
        public void TestAutomatic_Set_Active_Atom()
        {
            // Ionize(>C=O): C=CCC(=O)CC -> C=CCC(=O*)CC, without setting the
            // reactive center
            var reactant = builder.NewAtomContainer();//CreateFromSmiles("C=CCC(=O)CC")

            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("O"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.Atoms.Add(builder.NewAtom("C"));
            reactant.AddBond(reactant.Atoms[0], reactant.Atoms[1], BondOrder.Double);
            reactant.AddBond(reactant.Atoms[1], reactant.Atoms[2], BondOrder.Single);
            reactant.AddBond(reactant.Atoms[2], reactant.Atoms[3], BondOrder.Single);
            reactant.AddBond(reactant.Atoms[3], reactant.Atoms[4], BondOrder.Double);
            reactant.AddBond(reactant.Atoms[3], reactant.Atoms[5], BondOrder.Single);
            reactant.AddBond(reactant.Atoms[5], reactant.Atoms[6], BondOrder.Single);
            AddExplicitHydrogens(reactant);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(reactant);
            CDK.LonePairElectronChecker.Saturate(reactant);

            var setOfReactants = CDK.Builder.NewAtomContainerSet();

            setOfReactants.Add(reactant);

            /* initiate */
            MakeSureAtomTypesAreRecognized(reactant);

            var type           = new ElectronImpactNBEReaction();
            var setOfReactions = type.Initiate(setOfReactants, null);

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

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

            Assert.AreEqual(1, molecule.Atoms[4].FormalCharge.Value);
            Assert.AreEqual(1, molecule.GetConnectedSingleElectrons(molecule.Atoms[4]).Count());
        }
Esempio n. 5
0
        public void TestElectronImpactNBEReaction()
        {
            var type = new ElectronImpactNBEReaction();

            Assert.IsNotNull(type);
        }
Esempio n. 6
0
        public void TestFspSingleB()
        {
            //CreateFromSmiles("FC")
            var molecule = builder.NewAtomContainer();

            molecule.Atoms.Add(builder.NewAtom("F"));
            molecule.Atoms.Add(builder.NewAtom("C"));
            molecule.AddBond(molecule.Atoms[0], molecule.Atoms[1], BondOrder.Single);
            molecule.Atoms.Add(builder.NewAtom("H"));
            molecule.Atoms.Add(builder.NewAtom("H"));
            molecule.Atoms.Add(builder.NewAtom("H"));
            molecule.AddBond(molecule.Atoms[1], molecule.Atoms[2], BondOrder.Single);
            molecule.AddBond(molecule.Atoms[1], molecule.Atoms[3], BondOrder.Single);
            molecule.AddBond(molecule.Atoms[1], molecule.Atoms[4], BondOrder.Single);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule);
            CDK.LonePairElectronChecker.Saturate(molecule);

            molecule.Atoms[0].IsReactiveCenter = true;

            var setOfReactants = CDK.Builder.NewAtomContainerSet();

            setOfReactants.Add(molecule);

            var type = new ElectronImpactNBEReaction();

            var paramList = new List <IParameterReaction>();
            var param     = new SetReactionCenter
            {
                IsSetParameter = true
            };

            paramList.Add(param);
            type.ParameterList = paramList;

            /* initiate */
            var setOfReactions = type.Initiate(setOfReactants, null);

            Assert.AreEqual(1, setOfReactions.Count);

            // expected products

            //CreateFromSmiles("[F*+]C")
            var expected1 = builder.NewAtomContainer();

            expected1.Atoms.Add(builder.NewAtom("F"));
            expected1.Atoms[0].FormalCharge = 1;
            expected1.SingleElectrons.Add(builder.NewSingleElectron(expected1.Atoms[0]));
            expected1.Atoms.Add(builder.NewAtom("C"));
            expected1.AddBond(expected1.Atoms[0], expected1.Atoms[1], BondOrder.Single);
            expected1.Atoms.Add(builder.NewAtom("H"));
            expected1.Atoms.Add(builder.NewAtom("H"));
            expected1.Atoms.Add(builder.NewAtom("H"));
            expected1.AddBond(expected1.Atoms[1], expected1.Atoms[2], BondOrder.Single);
            expected1.AddBond(expected1.Atoms[1], expected1.Atoms[3], BondOrder.Single);
            expected1.AddBond(expected1.Atoms[1], expected1.Atoms[4], BondOrder.Single);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(expected1);
            CDK.LonePairElectronChecker.Saturate(expected1);

            var product1  = setOfReactions[0].Products[0];
            var queryAtom = QueryAtomContainerCreator.CreateSymbolAndChargeQueryContainer(expected1);

            Assert.IsTrue(new UniversalIsomorphismTester().IsIsomorph(product1, queryAtom));
        }