Exemplo n.º 1
0
        public void TestGetSize()
        {
            IFingerprinter fingerprinter = new Fingerprinter(512);

            Assert.IsNotNull(fingerprinter);
            Assert.AreEqual(512, fingerprinter.Length);
        }
Exemplo n.º 2
0
        public void TestGetSearchDepth()
        {
            Fingerprinter fingerprinter = new Fingerprinter(512, 3);

            Assert.IsNotNull(fingerprinter);
            Assert.AreEqual(3, fingerprinter.SearchDepth);
        }
Exemplo n.º 3
0
        public void TestgetBitFingerprint_IAtomContainer()
        {
            Fingerprinter fingerprinter = new Fingerprinter();

            var             mol = TestMoleculeFactory.MakeIndole();
            IBitFingerprint bs  = fingerprinter.GetBitFingerprint(mol);

            Assert.IsNotNull(bs);
            Assert.AreEqual(fingerprinter.Length, bs.Length);
        }
Exemplo n.º 4
0
        public void TestVersion()
        {
            Fingerprinter fpr = new Fingerprinter(1024, 7);

            fpr.SetPathLimit(2000);
            fpr.SetHashPseudoAtoms(true);
            string expected = "CDK-Fingerprinter/" + CDK.Version + " searchDepth=7 pathLimit=2000 hashPseudoAtoms=" + true.ToString();

            Assert.AreEqual(expected, fpr.GetVersionDescription());
        }
Exemplo n.º 5
0
 public void Main()
 {
     {
         #region
         var molecule      = new AtomContainer();
         var fingerprinter = new Fingerprinter();
         var fingerprint   = fingerprinter.GetBitFingerprint(molecule);
         Console.WriteLine(fingerprint.Length); // returns 1024 by default
         #endregion
     }
 }
Exemplo n.º 6
0
        public void TestIsSubSet_BitSet_BitSet()
        {
            Fingerprinter fingerprinter = new Fingerprinter();

            IAtomContainer mol   = TestMoleculeFactory.MakeIndole();
            BitArray       bs    = fingerprinter.GetBitFingerprint(mol).AsBitSet();
            IAtomContainer frag1 = TestMoleculeFactory.MakePyrrole();
            BitArray       bs1   = fingerprinter.GetBitFingerprint(frag1).AsBitSet();

            Assert.IsTrue(FingerprinterTool.IsSubset(bs, bs1));
        }
Exemplo n.º 7
0
        public void TestBug2819557()
        {
            IAtomContainer butane      = MakeButane();
            IAtomContainer propylAmine = MakePropylAmine();

            Fingerprinter fp = new Fingerprinter();
            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");
        }
Exemplo n.º 8
0
        public void TestFingerprinterBitSetSize()
        {
            Fingerprinter fingerprinter = new Fingerprinter(1024, 7);

            Assert.IsNotNull(fingerprinter);
            var      mol = TestMoleculeFactory.MakeIndole();
            BitArray bs  = fingerprinter.GetBitFingerprint(mol).AsBitSet();

            Assert.AreEqual(994, BitArrays.GetLength(bs)); // highest set bit
            Assert.AreEqual(1024, bs.Count);               // actual bit set size
        }
Exemplo n.º 9
0
        public void TestAtomPermutation2()
        {
            IAtomContainer  pamine = TestMoleculeFactory.MakeCyclopentane();
            Fingerprinter   fp     = new Fingerprinter();
            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));
            }
        }
Exemplo n.º 10
0
        public void TestAtomPermutation()
        {
            var pamine = MakePropylAmine();
            var fp     = new Fingerprinter();
            var bs1    = fp.GetBitFingerprint(pamine);

            var acp = new AtomContainerAtomPermutor(pamine);

            while (acp.MoveNext())
            {
                var container = acp.Current;
                var bs2       = fp.GetBitFingerprint(container);
                Assert.IsTrue(bs1.Equals(bs2));
            }
        }
Exemplo n.º 11
0
 public void Main()
 {
     {
         #region IsSubset
         var mol           = TestMoleculeFactory.MakeIndole();
         var fingerprinter = new Fingerprinter();
         var bs            = fingerprinter.GetBitFingerprint(mol);
         var frag1         = TestMoleculeFactory.MakePyrrole();
         var bs1           = fingerprinter.GetBitFingerprint(frag1);
         if (FingerprinterTool.IsSubset(bs.AsBitSet(), bs1.AsBitSet()))
         {
             Console.Out.WriteLine("Pyrrole is subset of Indole.");
         }
         #endregion
     }
 }
Exemplo n.º 12
0
        public void TestRegression()
        {
            IAtomContainer  mol1          = TestMoleculeFactory.MakeIndole();
            IAtomContainer  mol2          = TestMoleculeFactory.MakePyrrole();
            Fingerprinter   fingerprinter = new Fingerprinter(1024, 8);
            IBitFingerprint bs1           = fingerprinter.GetBitFingerprint(mol1);

            Assert.AreEqual(
                33, 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(
                13, bs2.Cardinality,
                "Seems the fingerprint code has changed. This will cause a number of other tests to fail too!");
        }
Exemplo n.º 13
0
        public void Testbug2917084()
        {
            string filename1 = "NCDK.Data.MDL.boronBuckyBall.mol";

            Trace.TraceInformation("Testing: " + filename1);
            var ins1     = ResourceLoader.GetAsStream(filename1);
            var reader   = new MDLV2000Reader(ins1, ChemObjectReaderMode.Strict);
            var chemFile = reader.Read(builder.NewChemFile());

            Assert.IsNotNull(chemFile);
            var mol = ChemFileManipulator.GetAllAtomContainers(chemFile).First();

            Fingerprinter fingerprinter = new Fingerprinter(1024, 8);

            Assert.IsNotNull(fingerprinter.GetBitFingerprint(mol));
        }
Exemplo n.º 14
0
        public void TestBug1851202()
        {
            string filename1 = "NCDK.Data.MDL.0002.stg01.rxn";

            Trace.TraceInformation("Testing: " + filename1);
            var ins1 = ResourceLoader.GetAsStream(filename1);
            MDLRXNV2000Reader reader   = new MDLRXNV2000Reader(ins1, ChemObjectReaderMode.Strict);
            IReaction         reaction = (IReaction)reader.Read(builder.NewReaction());

            Assert.IsNotNull(reaction);

            IAtomContainer reactant = reaction.Reactants[0];
            IAtomContainer product  = reaction.Products[0];

            Fingerprinter fingerprinter = new Fingerprinter(64 * 26, 8);

            Assert.IsNotNull(fingerprinter.GetBitFingerprint(reactant));
            Assert.IsNotNull(fingerprinter.GetBitFingerprint(product));
        }
Exemplo n.º 15
0
        public void PseudoAtomFingerprintArom()
        {
            SmilesParser  smipar    = CDK.SmilesParser;
            string        query     = "*1cnccc1";
            string        indole    = "n1cnccc1";
            var           queryMol  = smipar.ParseSmiles(query);
            var           indoleMol = smipar.ParseSmiles(indole);
            Fingerprinter fpr       = new Fingerprinter();
            BitArray      fp1       = fpr.GetFingerprint(queryMol);
            BitArray      fp2       = fpr.GetFingerprint(indoleMol);

            Assert.IsTrue(FingerprinterTool.IsSubset(fp2, fp1));
            Assert.IsFalse(FingerprinterTool.IsSubset(fp1, fp2));
            fpr.SetHashPseudoAtoms(true);
            BitArray fp3 = fpr.GetFingerprint(queryMol);
            BitArray fp4 = fpr.GetFingerprint(indoleMol);

            Assert.IsFalse(FingerprinterTool.IsSubset(fp4, fp3));
            Assert.IsFalse(FingerprinterTool.IsSubset(fp3, fp4));
        }
Exemplo n.º 16
0
 /// <summary>
 /// Constructs a fingerprint generator that creates fingerprints of
 /// the given size, using a generation algorithm with the given search
 /// depth.
 /// </summary>
 /// <param name="size">The desired size of the fingerprint</param>
 /// <param name="searchDepth">The desired depth of search</param>
 public ExtendedFingerprinter(int size, int searchDepth)
 {
     this.fingerprinter = new Fingerprinter(size - ReservedBits, searchDepth);
 }