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 TestAnonFingerprints() { var expected = new BitArray[] { ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), ParseBitSet("{148, 206, 392, 542, 637, 742, 752, 830}"), }; var filename = "NCDK.Data.MDL.fingerprints_from_modelbuilder3d.sdf"; var ins = this.GetType().Assembly.GetManifestResourceStream(filename); var data = TemplateExtractor.MakeFingerprintsFromSdf(true, true, new Dictionary <string, int>(), new StreamReader(ins), 10); var obj = new QueryChemObject(); var dummy = obj.Builder; for (int i = 0; i < data.Count; i++) { IBitFingerprint bs = data[i]; Assert.IsTrue(Compares.AreEqual(expected[i], bs.AsBitSet())); } }
public override void TestBug706786() { IAtomContainer superStructure = Bug706786_1(); IAtomContainer subStructure = Bug706786_2(); AddImplicitHydrogens(superStructure); AddImplicitHydrogens(subStructure); // SMARTS is now correct and D will include H atoms, CDK had this wrong // for years (had it has non-H count). Whilst you can set the optional // SMARTS flavor CDK_LEGACY this is not correct AtomContainerManipulator.SuppressHydrogens(superStructure); AtomContainerManipulator.SuppressHydrogens(subStructure); IFingerprinter fpr = GetBitFingerprinter(); IBitFingerprint superBits = fpr.GetBitFingerprint(superStructure); IBitFingerprint subBits = fpr.GetBitFingerprint(subStructure); Assert.IsTrue(BitArrays.Equals( AsBitSet(0, 11, 13, 17, 40, 48, 136, 273, 274, 278, 286, 294, 299, 301, 304, 306), superBits.AsBitSet())); Assert.IsTrue(BitArrays.Equals( AsBitSet(1, 17, 273, 274, 278, 294, 306), subBits.AsBitSet())); }
public void TestFingerprint() { var parser = CDK.SmilesParser; IFingerprinter printer = new EStateFingerprinter(); IBitFingerprint bs1 = printer.GetBitFingerprint(parser.ParseSmiles("C=C-C#N")); IBitFingerprint bs2 = printer.GetBitFingerprint(parser.ParseSmiles("C=CCC(O)CC#N")); Assert.AreEqual(79, printer.Length); Assert.IsTrue(bs1[7]); Assert.IsTrue(bs1[10]); Assert.IsTrue(FingerprinterTool.IsSubset(bs2.AsBitSet(), bs1.AsBitSet())); }
public override void TestBug706786() { IAtomContainer superStructure = Bug706786_1(); IAtomContainer subStructure = Bug706786_2(); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(superStructure); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(subStructure); AddImplicitHydrogens(superStructure); AddImplicitHydrogens(subStructure); IFingerprinter fpr = new MACCSFingerprinter(); IBitFingerprint superBits = fpr.GetBitFingerprint(superStructure); IBitFingerprint subBits = fpr.GetBitFingerprint(subStructure); Assert.IsTrue(BitArrays.Equals( AsBitSet(53, 56, 65, 71, 73, 88, 97, 104, 111, 112, 126, 130, 136, 138, 139, 140, 142, 143, 144, 145, 148, 149, 151, 153, 156, 158, 159, 161, 162, 163, 164), superBits.AsBitSet())); Assert.IsTrue(BitArrays.Equals( AsBitSet(56, 97, 104, 108, 112, 117, 131, 136, 143, 144, 146, 151, 152, 156, 161, 162, 163, 164), subBits.AsBitSet())); }
public override void TestBug706786() { IAtomContainer superStructure = Bug706786_1(); IAtomContainer subStructure = Bug706786_2(); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(superStructure); AtomContainerManipulator.PercieveAtomTypesAndConfigureAtoms(subStructure); AddImplicitHydrogens(superStructure); AddImplicitHydrogens(subStructure); // SMARTS is now correct and D will include H atoms, CDK had this wrong // for years (had it has non-H count). Whilst you can set the optional // SMARTS flavor CDK_LEGACY this is not correct AtomContainerManipulator.SuppressHydrogens(superStructure); AtomContainerManipulator.SuppressHydrogens(subStructure); IFingerprinter fpr = new EStateFingerprinter(); IBitFingerprint superBits = fpr.GetBitFingerprint(superStructure); IBitFingerprint subBits = fpr.GetBitFingerprint(subStructure); Assert.IsTrue(BitArrays.Equals(AsBitSet(6, 11, 12, 15, 16, 18, 33, 34, 35), superBits.AsBitSet())); Assert.IsTrue(BitArrays.Equals(AsBitSet(8, 11, 16, 35), subBits.AsBitSet())); }
/// <summary> /// BuildTest /// </summary> public static void BuildTest() { CircularFingerprinter cfp = null; CircularFingerprinterClass FpClass = CircularFingerprinterClass.ECFP6; // FP diameter int FpLen = 2048; // folded binary fp length IAtomContainer mol, mol2; //string molfile = FileUtil.ReadFile(@"C:\Download\CorpId-12345.mol"); //java.io.StringReader sr = new java.io.StringReader(molfile); //if (Lex.Contains(molfile, "v2000")) // cor = new MDLV2000Reader(sr); //else // cor = new MDLV3000Reader(sr); //cor.setReaderMode(IChemObjectReader.Mode.RELAXED); //ac = (IAtomContainer)cor.read(new AtomContainer()); //cor.close(); FpClass = CircularFingerprinterClass.ECFP4; // debug cfp = new CircularFingerprinter(FpClass, FpLen); StreamReader reader = new StreamReader(@"C:\Download\CorpId-12345.mol"); //FileReader FileReader = new FileReader(@"C:\Download\V3000 Mols.sdf"); EnumerableSDFReader rdr = new EnumerableSDFReader(reader.BaseStream, ChemObjectBuilder.Instance); rdr.ReaderMode = ChemObjectReaderMode.Relaxed; IEnumerator <IAtomContainer> cursor = rdr.GetEnumerator(); while (cursor.MoveNext()) { mol = cursor.Current; mol = CdkMol.GetLargestMoleculeFragment(mol); ICountFingerprint cfp1 = cfp.GetCountFingerprint(mol); // get hash values and counts for each cfp.Calculate(mol); int fpCount = cfp.FPCount; for (int fpi = 0; fpi < fpCount; fpi++) // gets { CircularFingerprint cfp2 = cfp.GetFP(fpi); // gets hash, iteration and lists of atoms (dups appear multiple times) } IBitFingerprint bfp = cfp.GetBitFingerprint(mol); BitArray bs = bfp.AsBitSet(); int bsCard = bfp.Cardinality; long bsSize = bfp.Length; continue; } reader.Close(); return; //java.io.StringReader sr = new java.io.StringReader(molfile); //AtomContainer mol = new AtomContainer(); //mol.addAtom(new Atom("C")); //mol.addAtom(new Atom("H")); //mol.addAtom(new Atom("H")); //mol.addAtom(new Atom("H")); //mol.addAtom(new Atom("H")); //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(1))); //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(2))); //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(3))); //mol.addBond(new Bond(mol.getAtom(0), mol.getAtom(4))); //FileReader FileReader = new FileReader(@"C:\Download\CorpId-12345.mol"); //MolReader mr = new MolReader(FileReader, DefaultChemObjectBuilder.getInstance()); //java.io.StringReader sr = new java.io.StringReader(molfile); //IMol m = (IMol)mr.next(); //FileReader.close(); }