public void TestBug2819557()
        {
            IAtomContainer butane      = MakeButane();
            IAtomContainer propylAmine = MakePropylAmine();

            ShortestPathFingerprinter fp = new ShortestPathFingerprinter();
            BitArray b1 = fp.GetBitFingerprint(butane).AsBitSet();
            BitArray b2 = fp.GetBitFingerprint(propylAmine).AsBitSet();

            Assert.IsFalse(FingerprinterTool.IsSubset(b2, b1), "butane should not be a substructure of propylamine");
        }
        public void TestRegression()
        {
            IAtomContainer mol1 = TestMoleculeFactory.MakeIndole();
            IAtomContainer mol2 = TestMoleculeFactory.MakePyrrole();

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2);
            ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter();
            IBitFingerprint           bs1           = fingerprinter.GetBitFingerprint(mol1);

            Assert.AreEqual(22, bs1.Cardinality, "Seems the fingerprint code has changed. This will cause a number of other tests to fail too!");
            IBitFingerprint bs2 = fingerprinter.GetBitFingerprint(mol2);

            Assert.AreEqual(11, bs2.Cardinality, "Seems the fingerprint code has changed. This will cause a number of other tests to fail too!");
        }
        public void TestAtomPermutation()
        {
            IAtomContainer            pamine = MakePropylAmine();
            ShortestPathFingerprinter fp     = new ShortestPathFingerprinter();
            IBitFingerprint           bs1    = fp.GetBitFingerprint(pamine);

            AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);

            while (acp.MoveNext())
            {
                IAtomContainer  container = acp.Current;
                IBitFingerprint bs2       = fp.GetBitFingerprint(container);
                Assert.IsTrue(bs1.Equals(bs2));
            }
        }
        public void TestAtomPermutation2()
        {
            IAtomContainer pamine = TestMoleculeFactory.MakeCyclopentane();

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(pamine);
            ShortestPathFingerprinter fp  = new ShortestPathFingerprinter();
            IBitFingerprint           bs1 = fp.GetBitFingerprint(pamine);

            AtomContainerAtomPermutor acp = new AtomContainerAtomPermutor(pamine);

            while (acp.MoveNext())
            {
                IAtomContainer  container = acp.Current;
                IBitFingerprint bs2       = fp.GetBitFingerprint(container);
                Assert.IsTrue(bs1.Equals(bs2));
            }
        }
        public void TestFingerprinter_int_int()
        {
            ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(1024);

            Assert.IsNotNull(fingerprinter);

            IAtomContainer mol = TestMoleculeFactory.MakeIndole();

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            BitArray       bs    = fingerprinter.GetBitFingerprint(mol).AsBitSet();
            IAtomContainer frag1 = TestMoleculeFactory.MakePyrrole();

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(frag1);
            BitArray bs1 = fingerprinter.GetBitFingerprint(frag1).AsBitSet();

            Assert.IsTrue(FingerprinterTool.IsSubset(bs, bs1));
        }
        public void TestGenerateFingerprintIsNotASubSet1()
        {
            string smilesT      = "O[C@H]1[C@H](O)[C@@H](O)[C@H](O)[C@H](O)[C@@H]1O";
            string smilesQ      = "OC[C@@H](O)[C@@H](O)[C@H](O)[C@@H](O)C(O)=O";
            var    smilesParser = new SmilesParser(builder, false);
            var    moleculeQ    = smilesParser.ParseSmiles(smilesQ);
            var    moleculeT    = smilesParser.ParseSmiles(smilesT);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(moleculeQ);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(moleculeT);

            ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
            BitArray fingerprintQ;
            BitArray fingerprintT;

            fingerprintQ = fingerprint.GetBitFingerprint(moleculeQ).AsBitSet();
            fingerprintT = fingerprint.GetBitFingerprint(moleculeT).AsBitSet();
            Assert.IsFalse(FingerprinterTool.IsSubset(fingerprintT, fingerprintQ));
        }
        public void TestGenerateFingerprintIsSubset()
        {
            string smilesT      = "NC(=O)C1=C2C=CC(Br)=CC2=C(Cl)C=C1";
            string smilesQ      = "CC1=C2C=CC(Br)=CC2=C(Cl)C=C1";
            var    smilesParser = CDK.SmilesParser;
            var    moleculeQ    = smilesParser.ParseSmiles(smilesQ);
            var    moleculeT    = smilesParser.ParseSmiles(smilesT);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(moleculeQ);
            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(moleculeT);

            ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
            BitArray fingerprintQ;
            BitArray fingerprintT;

            fingerprintQ = fingerprint.GetBitFingerprint(moleculeQ).AsBitSet();
            fingerprintT = fingerprint.GetBitFingerprint(moleculeT).AsBitSet();

            Assert.IsTrue(FingerprinterTool.IsSubset(fingerprintT, fingerprintQ));
        }
Beispiel #8
0
 public void Main()
 {
     {
         #region
         var molecule = new AtomContainer();
         AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule);
         var fingerprinter = new ShortestPathFingerprinter();
         var fingerprint   = fingerprinter.GetBitFingerprint(molecule);
         Console.WriteLine(fingerprint.Length); // returns 1024 by default
         #endregion
     }
 }
        public void TestgetBitFingerprint_IAtomContainer()
        {
            ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter();

            IAtomContainer mol = TestMoleculeFactory.MakeIndole();

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            IBitFingerprint bs = fingerprinter.GetBitFingerprint(mol);

            Assert.IsNotNull(bs);
            Assert.AreEqual(fingerprinter.Length, bs.Length);
        }
        public void TestFingerprinterBitSetSize()
        {
            ShortestPathFingerprinter fingerprinter = new ShortestPathFingerprinter(1024);

            Assert.IsNotNull(fingerprinter);
            IAtomContainer mol = TestMoleculeFactory.MakeIndole();

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol);
            BitArray bs = fingerprinter.GetBitFingerprint(mol).AsBitSet();

            Assert.AreEqual(1024, bs.Length); // highest set bit
            Assert.AreEqual(1024, bs.Count);  // actual bit set size
        }
        public void TestGenerateFingerprintNaphthalene()
        {
            var smiles       = "C1=CC2=CC=CC=C2C=C1";
            var smilesParser = CDK.SmilesParser;
            var molecule     = smilesParser.ParseSmiles(smiles);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule);
            Aromaticity.CDKLegacy.Apply(molecule);
            ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
            BitArray fingerprint1;

            fingerprint1 = fingerprint.GetBitFingerprint(molecule).AsBitSet();
            Assert.AreEqual(8, BitArrays.Cardinality(fingerprint1));
        }
        public void TestGenerateFingerprintMultiphtalene()
        {
            var smiles       = "C1=CC2=CC=C3C4=CC5=CC6=CC=CC=C6C=C5C=C4C=CC3=C2C=C1";
            var smilesParser = CDK.SmilesParser;
            var molecule     = smilesParser.ParseSmiles(smiles);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule);

            AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(molecule);
            ShortestPathFingerprinter fingerprint = new ShortestPathFingerprinter(1024);
            BitArray fingerprint1;

            fingerprint1 = fingerprint.GetBitFingerprint(molecule).AsBitSet();
            Assert.AreEqual(15, BitArrays.Cardinality(fingerprint1));
        }