Search in sources :

Example 1 with PubchemFingerprinter

use of org.openscience.cdk.fingerprint.PubchemFingerprinter in project ambit-mirror by ideaconsult.

the class TestUtilities method comparePubChemFP.

public static void comparePubChemFP(String smiFile) throws Exception {
    File file = new File(smiFile);
    RandomAccessFile f = new RandomAccessFile(file, "r");
    long length = f.length();
    PubChemFingerprinter ambitFP = new PubChemFingerprinter();
    PubchemFingerprinter cdkFP = new PubchemFingerprinter(SilentChemObjectBuilder.getInstance());
    long ambitTime = 0;
    long cdkTime = 0;
    long curTime = 0;
    int nStr = 0;
    int nDiff = 0;
    while (f.getFilePointer() < length) {
        String line = f.readLine();
        line = line.trim();
        if (line.isEmpty())
            continue;
        IAtomContainer mol = SmartsHelper.getMoleculeFromSmiles(line);
        nStr++;
        curTime = System.nanoTime();
        BitSet bs0 = ambitFP.getFingerprint(mol);
        ambitTime += (System.nanoTime() - curTime);
        if (nStr % 100 == 0)
            System.out.println("nStr = " + nStr + "  nDiff = " + nDiff + "  ambitTime = " + ambitTime / 1.0e9 + "  cdkTime = " + cdkTime / 1.0e9 + "  cdk/ambit = " + 1.0 * cdkTime / ambitTime);
    }
    f.close();
}
Also used : PubChemFingerprinter(ambit2.descriptors.fingerprints.PubChemFingerprinter) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) RandomAccessFile(java.io.RandomAccessFile) PubchemFingerprinter(org.openscience.cdk.fingerprint.PubchemFingerprinter) BitSet(java.util.BitSet) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 2 with PubchemFingerprinter

use of org.openscience.cdk.fingerprint.PubchemFingerprinter in project ambit-mirror by ideaconsult.

the class FingerPrintGeneratorTest method testPolyAromatics.

@Test
public void testPolyAromatics() throws Exception {
    MoleculeReader molreader = new MoleculeReader();
    FingerprintGenerator gen = new FingerprintGenerator(new Fingerprinter());
    InputStream in = FingerPrintGeneratorTest.class.getClassLoader().getResourceAsStream("ambit2/core/data/fp/polyaromatics.sdf");
    RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(in));
    while (reader.hasNext()) {
        IStructureRecord record = reader.nextRecord();
        IAtomContainer mol = molreader.process(record);
        AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
        CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance()).addImplicitHydrogens(mol);
        CDKHueckelAromaticityDetector.detectAromaticity(mol);
        gen.setHydrogens(false);
        mol = AtomContainerManipulator.removeHydrogensPreserveMultiplyBonded(mol);
        BitSet bs1 = gen.process(mol);
        System.out.println(bs1);
        ExtendedFingerprinter efp = new ExtendedFingerprinter();
        System.out.println(efp.getClass().getName());
        System.out.println(efp.getBitFingerprint(mol).asBitSet());
        PubchemFingerprinter pfp = new PubchemFingerprinter(SilentChemObjectBuilder.getInstance());
        System.out.println(pfp.getClass().getName());
        System.out.println(pfp.getBitFingerprint(mol).asBitSet());
        EStateFingerprinter esfp = new EStateFingerprinter();
        System.out.println(esfp.getClass().getName());
        System.out.println(esfp.getBitFingerprint(mol).asBitSet());
        MACCSFingerprinter mfp = new MACCSFingerprinter();
        System.out.println(mfp.getClass().getName());
        System.out.println(mfp.getBitFingerprint(mol).asBitSet());
        SubstructureFingerprinter sfp = new SubstructureFingerprinter();
        System.out.println(sfp.getClass().getName());
        System.out.println(sfp.getBitFingerprint(mol).asBitSet());
        HybridizationFingerprinter hfp = new HybridizationFingerprinter();
        System.out.println(hfp.getClass().getName());
        System.out.println(hfp.getBitFingerprint(mol).asBitSet());
    /*
			BigInteger[] h16 = new BigInteger[16];
			MoleculeTools.bitset2bigint16(bs1,64,h16);
			new Random(10000);
			BitSet bs2 = gen.process(molreader.process(record));
			Assert.assertEquals(bs1,bs2);
			MoleculeTools.bitset2bigint16(bs2,64,h16);
			for (int i=0; i <16;i++) {
				Assert.assertEquals(expected[i], h16[i]);
			}
			*/
    }
    /*
		IStructureRecord record = new StructureRecord();
		record.setContent();
		MoleculeReader reader = new MoleculeReader();
		reader.process(target)
		*/
    reader.close();
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) RawIteratingSDFReader(ambit2.core.io.RawIteratingSDFReader) InputStreamReader(java.io.InputStreamReader) PubchemFingerprinter(org.openscience.cdk.fingerprint.PubchemFingerprinter) InputStream(java.io.InputStream) BitSet(java.util.BitSet) SubstructureFingerprinter(org.openscience.cdk.fingerprint.SubstructureFingerprinter) FingerprintGenerator(ambit2.core.processors.structure.FingerprintGenerator) EStateFingerprinter(org.openscience.cdk.fingerprint.EStateFingerprinter) IStructureRecord(ambit2.base.interfaces.IStructureRecord) HybridizationFingerprinter(org.openscience.cdk.fingerprint.HybridizationFingerprinter) ExtendedFingerprinter(org.openscience.cdk.fingerprint.ExtendedFingerprinter) MoleculeReader(ambit2.core.processors.structure.MoleculeReader) MACCSFingerprinter(org.openscience.cdk.fingerprint.MACCSFingerprinter) ExtendedFingerprinter(org.openscience.cdk.fingerprint.ExtendedFingerprinter) SubstructureFingerprinter(org.openscience.cdk.fingerprint.SubstructureFingerprinter) PubchemFingerprinter(org.openscience.cdk.fingerprint.PubchemFingerprinter) Fingerprinter(org.openscience.cdk.fingerprint.Fingerprinter) HybridizationFingerprinter(org.openscience.cdk.fingerprint.HybridizationFingerprinter) EStateFingerprinter(org.openscience.cdk.fingerprint.EStateFingerprinter) MACCSFingerprinter(org.openscience.cdk.fingerprint.MACCSFingerprinter) Test(org.junit.Test)

Example 3 with PubchemFingerprinter

use of org.openscience.cdk.fingerprint.PubchemFingerprinter in project ambit-mirror by ideaconsult.

the class TestUtilities method compareFP.

public static void compareFP(String smiles) throws Exception {
    IAtomContainer mol = SmartsHelper.getMoleculeFromSmiles(smiles);
    PubChemFingerprinter ambitFP = new PubChemFingerprinter();
    PubchemFingerprinter cdkFP = new PubchemFingerprinter(SilentChemObjectBuilder.getInstance());
    BitSet bs0 = ambitFP.getFingerprint(mol);
    BitSet bs1 = cdkFP.getBitFingerprint(mol).asBitSet();
    System.out.println(smiles);
    System.out.println("ambit: " + bs0);
    System.out.println("cdk:   " + bs1);
    bs1.xor(bs0);
    System.out.println("   diff:   " + bs1);
}
Also used : PubChemFingerprinter(ambit2.descriptors.fingerprints.PubChemFingerprinter) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) PubchemFingerprinter(org.openscience.cdk.fingerprint.PubchemFingerprinter) BitSet(java.util.BitSet)

Example 4 with PubchemFingerprinter

use of org.openscience.cdk.fingerprint.PubchemFingerprinter in project ambit-mirror by ideaconsult.

the class FingerprinterTest method testPubChem.

@Test
public void testPubChem() throws Exception {
    IAtomContainer mol = MoleculeFactory.make123Triazole();
    IFingerprinter fp = new PubchemFingerprinter(SilentChemObjectBuilder.getInstance());
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    CDKHydrogenAdder h = CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance());
    h.addImplicitHydrogens(mol);
    CDKHueckelAromaticityDetector.detectAromaticity(mol);
    BitSet bs1 = fp.getBitFingerprint(mol).asBitSet();
    BitSet bs2 = fp.getBitFingerprint(mol).asBitSet();
    // fails if aromaticity was not detected!
    Assert.assertEquals(bs1, bs2);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) PubchemFingerprinter(org.openscience.cdk.fingerprint.PubchemFingerprinter) BitSet(java.util.BitSet) CDKHydrogenAdder(org.openscience.cdk.tools.CDKHydrogenAdder) IFingerprinter(org.openscience.cdk.fingerprint.IFingerprinter) Test(org.junit.Test)

Aggregations

BitSet (java.util.BitSet)4 PubchemFingerprinter (org.openscience.cdk.fingerprint.PubchemFingerprinter)4 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)4 PubChemFingerprinter (ambit2.descriptors.fingerprints.PubChemFingerprinter)2 Test (org.junit.Test)2 IStructureRecord (ambit2.base.interfaces.IStructureRecord)1 RawIteratingSDFReader (ambit2.core.io.RawIteratingSDFReader)1 FingerprintGenerator (ambit2.core.processors.structure.FingerprintGenerator)1 MoleculeReader (ambit2.core.processors.structure.MoleculeReader)1 File (java.io.File)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 RandomAccessFile (java.io.RandomAccessFile)1 EStateFingerprinter (org.openscience.cdk.fingerprint.EStateFingerprinter)1 ExtendedFingerprinter (org.openscience.cdk.fingerprint.ExtendedFingerprinter)1 Fingerprinter (org.openscience.cdk.fingerprint.Fingerprinter)1 HybridizationFingerprinter (org.openscience.cdk.fingerprint.HybridizationFingerprinter)1 IFingerprinter (org.openscience.cdk.fingerprint.IFingerprinter)1 MACCSFingerprinter (org.openscience.cdk.fingerprint.MACCSFingerprinter)1 SubstructureFingerprinter (org.openscience.cdk.fingerprint.SubstructureFingerprinter)1