public override void TestBug934819() { IAtomContainer subStructure = Bug934819_1(); IAtomContainer superStructure = Bug934819_2(); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(superStructure); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(subStructure); AddImplicitHydrogens(superStructure); AddImplicitHydrogens(subStructure); IFingerprinter fpr = new PubchemFingerprinter(); IBitFingerprint superBits = fpr.GetBitFingerprint(superStructure); IBitFingerprint subBits = fpr.GetBitFingerprint(subStructure); Assert.IsTrue(BitArrays.Equals( AsBitSet(9, 10, 14, 18, 19, 33, 143, 146, 255, 256, 283, 284, 285, 293, 301, 332, 344, 349, 351, 353, 355, 368, 370, 371, 376, 383, 384, 395, 401, 412, 416, 421, 423, 434, 441, 446, 449, 454, 455, 464, 470, 471, 480, 489, 490, 500, 502, 507, 513, 514, 516, 520, 524, 531, 532, 545, 546, 549, 552, 556, 558, 564, 570, 586, 592, 599, 600, 607, 633, 658, 665), subBits.AsBitSet())); Assert.IsTrue(BitArrays.Equals( AsBitSet(9, 10, 11, 14, 18, 19, 33, 34, 143, 146, 150, 153, 255, 256, 257, 258, 283, 284, 285, 293, 301, 332, 344, 349, 351, 353, 355, 368, 370, 371, 374, 376, 383, 384, 395, 401, 412, 416, 417, 421, 423, 427, 434, 441, 446, 449, 454, 455, 460, 464, 470, 471, 479, 480, 489, 490, 500, 502, 507, 513, 514, 516, 520, 524, 531, 532, 545, 546, 549, 552, 556, 558, 564, 570, 578, 582, 584, 586, 592, 595, 600, 603, 607, 608, 633, 634, 640, 658, 660, 664, 665, 668, 677, 678, 683), superBits.AsBitSet())); }
public void TestFingerprint() { IFingerprinter printer = new PubchemFingerprinter(); var adder = CDK.HydrogenAdder; var mol1 = parser.ParseSmiles("c1ccccc1CCc1ccccc1"); var mol2 = parser.ParseSmiles("c1ccccc1CC"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2); adder.AddImplicitHydrogens(mol1); adder.AddImplicitHydrogens(mol2); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol1); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol2); Aromaticity.CDKLegacy.Apply(mol1); Aromaticity.CDKLegacy.Apply(mol2); BitArray bs1 = printer.GetBitFingerprint(mol1).AsBitSet(); BitArray bs2 = printer.GetBitFingerprint(mol2).AsBitSet(); Assert.AreEqual(881, printer.Length); Assert.IsFalse(FingerprinterTool.IsSubset(bs1, bs2), "c1ccccc1CC was detected as a subset of c1ccccc1CCc1ccccc1"); }
public void TestMultithReadedUsage() { var mol1 = parser.ParseSmiles("C=C(C1=CC=C(C=C1)O)NNC2=C(C(=NC(=C2Cl)Cl)C(=O)O)Cl"); IAtomContainer mol2 = parser .ParseSmiles("C1=CC=C(C=C1)C[N+]2=C(C=C(C=C2C=CC3=CC=CC=C3)C4=CC=CC=C4)C5=CC=CC=C5"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2); var adder = CDK.HydrogenAdder; adder.AddImplicitHydrogens(mol1); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol1); Aromaticity.CDKLegacy.Apply(mol1); adder.AddImplicitHydrogens(mol2); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol2); Aromaticity.CDKLegacy.Apply(mol2); IFingerprinter fp = new PubchemFingerprinter(); BitArray bs1 = fp.GetBitFingerprint(mol1).AsBitSet(); BitArray bs2 = fp.GetBitFingerprint(mol2).AsBitSet(); // now lets run some threads var objs = new List <FpRunner> { new FpRunner(mol1), new FpRunner(mol2) }; var ret = Parallel.ForEach(objs, o => o.Call()); Assert.IsTrue(ret.IsCompleted); BitArray fb1 = objs[0].Result; Assert.IsNotNull(fb1); BitArray fb2 = objs[1].Result; Assert.IsNotNull(fb2); Assert.IsTrue(BitArrays.Equals(bs1, fb1)); Assert.IsTrue(BitArrays.Equals(bs2, fb2)); }
public static void Main() { { #region var molecule = new AtomContainer(); IFingerprinter fingerprinter = new PubchemFingerprinter(Silent.ChemObjectBuilder.Instance); IBitFingerprint fingerprint = fingerprinter.GetBitFingerprint(molecule); Console.WriteLine(fingerprint.Length); // returns 881 #endregion } }
public void Testfp2() { IFingerprinter printer = new PubchemFingerprinter(); var mol1 = parser.ParseSmiles("CC(N)CCCN"); var mol2 = parser.ParseSmiles("CC(N)CCC"); var mol3 = parser.ParseSmiles("CCCC"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol1); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol2); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol3); Aromaticity.CDKLegacy.Apply(mol1); Aromaticity.CDKLegacy.Apply(mol2); Aromaticity.CDKLegacy.Apply(mol3); BitArray bs1 = printer.GetBitFingerprint(mol1).AsBitSet(); BitArray bs2 = printer.GetBitFingerprint(mol2).AsBitSet(); BitArray bs3 = printer.GetBitFingerprint(mol3).AsBitSet(); Assert.IsTrue(FingerprinterTool.IsSubset(bs1, bs2)); Assert.IsTrue(FingerprinterTool.IsSubset(bs2, bs3)); }
public void Call() { BitArray fp = null; IFingerprinter fpr = new PubchemFingerprinter(); try { fp = fpr.GetBitFingerprint(mol).AsBitSet(); } catch (CDKException e) { Console.Error.WriteLine(e.StackTrace); //To change body of catch statement use File | Settings | File Templates. } Result = fp; }
public void TestBenzene() { var mol = parser.ParseSmiles("c1ccccc1"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol); var adder = CDK.HydrogenAdder; adder.AddImplicitHydrogens(mol); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol); Aromaticity.CDKLegacy.Apply(mol); IFingerprinter printer = new PubchemFingerprinter(); BitArray fp = printer.GetBitFingerprint(mol).AsBitSet(); BitArray ref_ = PubchemFingerprinter .Decode("AAADcYBgAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAABAAAAGAAAAAAACACAEAAwAIAAAACAACBCAAACAAAgAAAIiAAAAIgIICKAERCAIAAggAAIiAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="); Assert.IsTrue(BitArrays.Equals(ref_, fp)); }
public void TestCID25181289() { var mol = parser.ParseSmiles("C=C(C1=CC=C(C=C1)O)NNC2=C(C(=NC(=C2Cl)Cl)C(=O)O)Cl"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol); var adder = CDK.HydrogenAdder; adder.AddImplicitHydrogens(mol); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol); Aromaticity.CDKLegacy.Apply(mol); IFingerprinter printer = new PubchemFingerprinter(); BitArray fp = printer.GetBitFingerprint(mol).AsBitSet(); BitArray ref_ = PubchemFingerprinter .Decode("AAADccBzMAAGAAAAAAAAAAAAAAAAAAAAAAA8QAAAAAAAAAABwAAAHgIYCAAADA6BniAwzpJqEgCoAyTyTASChCAnJiIYumGmTtgKJnLD1/PEdQhkwBHY3Qe82AAOIAAAAAAAAABAAAAAAAAAAAAAAAAAAA=="); Assert.IsTrue(BitArrays.Equals(ref_, fp)); }
public void TestCID5934166() { var mol = parser.ParseSmiles("C1=CC=C(C=C1)C[N+]2=C(C=C(C=C2C=CC3=CC=CC=C3)C4=CC=CC=C4)C5=CC=CC=C5"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol); var adder = CDK.HydrogenAdder; adder.AddImplicitHydrogens(mol); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol); Aromaticity.CDKLegacy.Apply(mol); IFingerprinter printer = new PubchemFingerprinter(); BitArray fp = printer.GetBitFingerprint(mol).AsBitSet(); BitArray ref_ = PubchemFingerprinter .Decode("AAADceB+AAAAAAAAAAAAAAAAAAAAAAAAAAA8YMGCAAAAAAAB1AAAHAAAAAAADAjBHgQwgJMMEACgAyRiRACCgCAhAiAI2CA4ZJgIIOLAkZGEIAhggADIyAcQgMAOgAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="); Assert.IsTrue(BitArrays.Equals(ref_, fp)); }
public void TestCID2518130() { var mol = parser.ParseSmiles("COC1C(C(C(C(O1)CO)OC2C(C(C(C(O2)CO)S)O)O)O)O"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol); var adder = CDK.HydrogenAdder; adder.AddImplicitHydrogens(mol); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol); Aromaticity.CDKLegacy.Apply(mol); IFingerprinter printer = new PubchemFingerprinter(); BitArray fp = printer.GetBitFingerprint(mol).AsBitSet(); BitArray ref_ = PubchemFingerprinter .Decode("AAADceBwPABAAAAAAAAAAAAAAAAAAAAAAAAkSAAAAAAAAAAAAAAAGgQACAAACBS0wAOCCAAABgQAAAAAAAAAAAAAAAAAAAAAAAAREAIAAAAiQAAFAAAHAAHAYAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="); Assert.IsTrue(BitArrays.Equals(ref_, fp)); }
public void TestGetFingerprintAsBytes() { var mol = parser.ParseSmiles("C=C(C1=CC=C(C=C1)O)NNC2=C(C(=NC(=C2Cl)Cl)C(=O)O)Cl"); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(mol); var adder = CDK.HydrogenAdder; adder.AddImplicitHydrogens(mol); AtomContainerManipulator.ConvertImplicitToExplicitHydrogens(mol); Aromaticity.CDKLegacy.Apply(mol); PubchemFingerprinter printer = new PubchemFingerprinter(); BitArray fp = printer.GetBitFingerprint(mol).AsBitSet(); byte[] actual = printer.GetFingerprintAsBytes(); byte[] expected = Arrays.CopyOf(ToByteArray(fp), actual.Length); Assert.IsTrue(Compares.AreEqual(expected, actual)); }