public void TestGenerate()
        {
            IAtomContainer m1 = Cyclopentylcyclopentane();
            IAtomContainer m2 = Decahydronaphthalene();

            SeedGenerator seeding      = new SeedGenerator(BasicAtomEncoder.AtomicNumber);
            Pseudorandom  pseudorandom = new Xorshift();

            IMoleculeHashGenerator basic   = new BasicMoleculeHashGenerator(new BasicAtomHashGenerator(seeding, pseudorandom, 8));
            IMoleculeHashGenerator perturb = new BasicMoleculeHashGenerator(new PerturbedAtomHashGenerator(seeding,
                                                                                                           new BasicAtomHashGenerator(seeding, pseudorandom, 8), pseudorandom, StereoEncoderFactory.Empty,
                                                                                                           new MinimumEquivalentCyclicSet(), AtomSuppression.Unsuppressed));

            // basic encoding should say these are the same
            Assert.AreEqual(basic.Generate(m1), basic.Generate(m2));

            // perturbed encoding should differentiate them
            Assert.AreNotEqual(perturb.Generate(m1), perturb.Generate(m2));
        }
Ejemplo n.º 2
0
        public void TestGenerate_Rotation()
        {
            var      m_atomGenerator = new Mock <IAtomHashGenerator>(); var atomGenerator = m_atomGenerator.Object;
            Xorshift xorshift = new Xorshift();
            var      m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            IMoleculeHashGenerator generator = new BasicMoleculeHashGenerator(atomGenerator, new Xorshift());

            m_atomGenerator.Setup(n => n.Generate(container)).Returns(new long[] { 5L, 5L, 5L, 5L });

            long hashCode = generator.Generate(container);

            m_atomGenerator.Verify(n => n.Generate(container), Times.Exactly(1));

            //VerifyNoMoreInteractions(atomGenerator, container);

            long expected = 2147483647L ^ 5L ^ xorshift.Next(5L) ^ xorshift.Next(xorshift.Next(5L))
                            ^ xorshift.Next(xorshift.Next(xorshift.Next(5L)));

            Assert.AreEqual(expected, hashCode);
        }
Ejemplo n.º 3
0
        public void TestGenerate()
        {
            var m_atomGenerator = new Mock <IAtomHashGenerator>(); var atomGenerator = m_atomGenerator.Object;
            var m_prng = new Mock <Pseudorandom>(); var prng = m_prng.Object;
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            IMoleculeHashGenerator generator = new BasicMoleculeHashGenerator(atomGenerator, prng);

            m_atomGenerator.Setup(n => n.Generate(container)).Returns(new long[] { 1, 1, 1, 1 });
            m_prng.Setup(n => n.Next(1L)).Returns(1L);

            long hashCode = generator.Generate(container);

            m_atomGenerator.Verify(n => n.Generate(container), Times.Exactly(1));
            m_prng.Verify(n => n.Next(1L), Times.Exactly(3));

            //VerifyNoMoreInteractions(atomGenerator, container, prng);

            long expected = 2147483647L ^ 1L ^ 1L ^ 1L ^ 1L;

            Assert.AreEqual(expected, hashCode);
        }