Ejemplo n.º 1
0
        public void TestShiftReactionVerticalTwohorizontalmolecules()
        {
            var atom1 = builder.NewAtom("C");

            atom1.Point2D = Vector2.Zero;
            var atom2 = builder.NewAtom("C");

            atom2.Point2D = new Vector2(1, 0);
            var react1   = builder.NewAtomContainer();
            var reaction = builder.NewReaction();

            reaction.Reactants.Add(react1);
            react1.Atoms.Add(atom1);
            react1.Atoms.Add(atom2);
            react1.AddBond(react1.Atoms[0], react1.Atoms[1], BondOrder.Single);
            var reaction2 = (IReaction)reaction.Clone();
            var react2    = reaction2.Reactants[0];

            // shift the second reaction up
            GeometryUtil.ShiftReactionVertical(reaction2, GeometryUtil.GetMinMax(react2), GeometryUtil.GetMinMax(react1),
                                               1.0);
            // assert all coordinates of the second reaction moved up
            AtomContainerDiff.Diff(react1, react2);
            for (int i = 0; i < 2; i++)
            {
                atom1 = react1.Atoms[0];
                atom2 = react2.Atoms[0];
                // so, x coordinates should be the same
                Assert.AreEqual(atom1.Point2D.Value.X, atom2.Point2D.Value.X, 0.0);
                // but, y coordinates should not
                Assert.IsTrue(atom1.Point2D.Value.Y < atom2.Point2D.Value.Y);
            }
        }
Ejemplo n.º 2
0
        public void TestShiftContainerHorizontalTwoverticalmolecules()
        {
            var atom1 = builder.NewAtom("C");

            atom1.Point2D = Vector2.Zero;
            var atom2 = builder.NewAtom("C");

            atom2.Point2D = new Vector2(0, 1);
            var react1 = builder.NewAtomContainer();

            react1.Atoms.Add(atom1);
            react1.Atoms.Add(atom2);
            var react2 = (IAtomContainer)react1.Clone();

            // shift the second molecule right
            GeometryUtil.ShiftContainer(react2, GeometryUtil.GetMinMax(react2), GeometryUtil.GetMinMax(react1), 1.0);
            // assert all coordinates of the second molecule moved right
            AtomContainerDiff.Diff(react1, react2);
            for (int i = 0; i < 2; i++)
            {
                atom1 = react1.Atoms[0];
                atom2 = react2.Atoms[0];
                // so, y coordinates should be the same
                Assert.AreEqual(atom1.Point2D.Value.Y, atom2.Point2D.Value.Y, 0.0);
                // but, x coordinates should not
                Assert.IsTrue(atom1.Point2D.Value.X < atom2.Point2D.Value.X);
            }
        }
Ejemplo n.º 3
0
        public void EnsureConsistentRepresentation()
        {
            IAtomContainer a    = CreateFromSmiles("C1=CC2=CC3=CC4=C(C=CC=C4)C=C3C=C2C=C1");
            IAtomContainer b    = CreateFromSmiles("c1cc2cc3cc4c(cccc4)cc3cc2cc1");
            Aromaticity    arom = new Aromaticity(ElectronDonation.DaylightModel, Cycles.AllSimpleFinder);

            arom.Apply(a);
            arom.Apply(b);
            Assert.IsTrue(AtomContainerDiff.Diff(a, b).Count() == 0);
        }
Ejemplo n.º 4
0
        public void TestCalculate_NoModifications()
        {
            var mol   = SomeoneBringMeSomeWater();
            var clone = (IAtomContainer)mol.Clone();

            CreateDescriptor().Calculate(mol);
            var diff = AtomContainerDiff.Diff(clone, mol);

            Assert.AreEqual(0, diff.Length, $"The descriptor must not change the passed molecule in any respect, but found this diff: {diff}");
        }
Ejemplo n.º 5
0
        public void TestMoleculeInvariance()
        {
            var mol   = TestMoleculeFactory.MakePyrrole();
            var clone = (IAtomContainer)mol.Clone();

            // should pass since we have not explicitly detected aromaticity
            foreach (var atom in mol.Atoms)
            {
                Assert.IsFalse(atom.IsAromatic);
            }

            var diff1 = AtomContainerDiff.Diff(mol, clone);

            Assert.AreEqual("", diff1);

            var fprinter = new ExtendedFingerprinter();
            var fp       = fprinter.GetBitFingerprint(mol).AsBitSet();

            Assert.IsNotNull(fp);

            var diff2 = AtomContainerDiff.Diff(mol, clone);

            Assert.IsTrue(diff2.Length == 0, "There was a difference\n" + diff2);
        }