Search in sources :

Example 1 with FingerprintGenerator

use of ambit2.core.processors.structure.FingerprintGenerator in project ambit-mirror by ideaconsult.

the class CallableFingerprintsModelCreator method createProcessors.

protected ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> createProcessors() throws Exception {
    ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> p1 = new ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor>();
    p1.add(new ProcessorStructureRetrieval());
    p1.add(new MoleculeReader());
    p1.add(new FingerprintGenerator(new Fingerprinter()));
    p1.add(new DefaultAmbitProcessor<BitSet, BitSet>() {

        /**
         */
        private static final long serialVersionUID = -2978697147490545478L;

        public BitSet process(BitSet target) throws AmbitException {
            builder.getTrainingData().add(target);
            return target;
        }
    });
    p1.setAbortOnError(true);
    return p1;
}
Also used : IBatchStatistics(net.idea.modbcum.i.batch.IBatchStatistics) BitSet(java.util.BitSet) IProcessor(net.idea.modbcum.i.processors.IProcessor) FingerprintGenerator(ambit2.core.processors.structure.FingerprintGenerator) IStructureRecord(ambit2.base.interfaces.IStructureRecord) MoleculeReader(ambit2.core.processors.structure.MoleculeReader) Fingerprinter(org.openscience.cdk.fingerprint.Fingerprinter) ProcessorsChain(net.idea.modbcum.i.processors.ProcessorsChain) ProcessorStructureRetrieval(ambit2.db.processors.ProcessorStructureRetrieval) AmbitException(net.idea.modbcum.i.exceptions.AmbitException)

Example 2 with FingerprintGenerator

use of ambit2.core.processors.structure.FingerprintGenerator in project ambit-mirror by ideaconsult.

the class FingerPrintGeneratorTest method test.

@Test
public void test() throws Exception {
    BigInteger[] expected = /*{
				new BigInteger("1126174803623952"), 
				new BigInteger("1152961362175993860"), 
				new BigInteger("2305843011903291728"),
				new BigInteger("25769820160"), 
				new BigInteger("1099511627776"),
				new BigInteger("33554496"), 
				new BigInteger("8864814662912"),
				new BigInteger("4803285265416200"), 
				new BigInteger("9223372050830336000"),
				new BigInteger("2454675102173515776"),
				new BigInteger("1152921504611041536"),
				new BigInteger("155684661740175875"), 
				new BigInteger("6917529131798265856"), 
				new BigInteger("310748377023266816"),
				new BigInteger("67110400"), 
				new BigInteger("2305843009213710336")};
				*/
    { new BigInteger("576462128137896992"), new BigInteger("10376293541473171584"), new BigInteger("2305843009214747777"), new BigInteger("72127962782121984"), new BigInteger("52776558133248"), new BigInteger("0"), new BigInteger("338649581355264"), new BigInteger("4366794756"), new BigInteger("17730770043904"), new BigInteger("2314887591865356288"), new BigInteger("2305844109263241488"), new BigInteger("2400709834665132544"), new BigInteger("13835058125075449856"), new BigInteger("10741891072"), new BigInteger("9007208196998144"), new BigInteger("18014398511644672") };
    MoleculeReader molreader = new MoleculeReader();
    FingerprintGenerator gen = new FingerprintGenerator(new Fingerprinter());
    InputStream in = FingerPrintGeneratorTest.class.getClassLoader().getResourceAsStream("ambit2/core/data/fp/fptest.mol");
    RawIteratingSDFReader reader = new RawIteratingSDFReader(new InputStreamReader(in));
    while (reader.hasNext()) {
        IStructureRecord record = reader.nextRecord();
        BitSet bs1 = gen.process(molreader.process(record));
        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)
		*/
}
Also used : RawIteratingSDFReader(ambit2.core.io.RawIteratingSDFReader) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) BitSet(java.util.BitSet) FingerprintGenerator(ambit2.core.processors.structure.FingerprintGenerator) IStructureRecord(ambit2.base.interfaces.IStructureRecord) 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) Random(java.util.Random) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 3 with FingerprintGenerator

use of ambit2.core.processors.structure.FingerprintGenerator in project ambit-mirror by ideaconsult.

the class QueryInfo2Query method createQuerySubstructure.

protected QueryPrescreenBitSet createQuerySubstructure(QueryInfo target) throws AmbitException {
    if (QueryInfo.METHOD_SUBSTRUCTURE.equals(target.getMethod())) {
        if (target.getMolecule() == null)
            return null;
        FingerprintGenerator g = new FingerprintGenerator(new Fingerprinter());
        BitSet bitset = g.process(target.getMolecule());
        QueryPrescreenBitSet qs = new QueryPrescreenBitSet();
        qs.setValue(bitset);
        return qs;
    } else
        return null;
}
Also used : Fingerprinter(org.openscience.cdk.fingerprint.Fingerprinter) BitSet(java.util.BitSet) QueryPrescreenBitSet(ambit2.db.search.structure.QueryPrescreenBitSet) FingerprintGenerator(ambit2.core.processors.structure.FingerprintGenerator) QueryPrescreenBitSet(ambit2.db.search.structure.QueryPrescreenBitSet)

Example 4 with FingerprintGenerator

use of ambit2.core.processors.structure.FingerprintGenerator in project ambit-mirror by ideaconsult.

the class QueryInfo2Query method createQuerySimilarity.

protected QuerySimilarityBitset createQuerySimilarity(QueryInfo target) throws AmbitException {
    if (QueryInfo.METHOD_SIMILARITY.equals(target.getMethod())) {
        if (target.getMolecule() == null)
            return null;
        FingerprintGenerator g = new FingerprintGenerator(new Fingerprinter());
        BitSet bitset = g.process(target.getMolecule());
        QuerySimilarityBitset qs = new QuerySimilarityBitset();
        qs.setValue(bitset);
        qs.setThreshold(target.getThreshold());
        return qs;
    } else
        return null;
}
Also used : QuerySimilarityBitset(ambit2.db.search.structure.QuerySimilarityBitset) Fingerprinter(org.openscience.cdk.fingerprint.Fingerprinter) BitSet(java.util.BitSet) QueryPrescreenBitSet(ambit2.db.search.structure.QueryPrescreenBitSet) FingerprintGenerator(ambit2.core.processors.structure.FingerprintGenerator)

Example 5 with FingerprintGenerator

use of ambit2.core.processors.structure.FingerprintGenerator in project ambit-mirror by ideaconsult.

the class FingerprintStructure_crud_test method createQuery.

@Override
protected IQueryUpdate<IStructureRecord, BitSet> createQuery() throws Exception {
    CreateFingerprintStructure q = new CreateFingerprintStructure();
    IStructureRecord record = new StructureRecord(7, 100211, null, null);
    IDatabaseConnection c = getConnection();
    ProcessorStructureRetrieval p = new ProcessorStructureRetrieval();
    p.setConnection(c.getConnection());
    MoleculeReader molReader = new MoleculeReader();
    FingerprintGenerator g = new FingerprintGenerator(new Fingerprinter());
    q.setObject(g.process(molReader.process(p.process(record))));
    q.setGroup(record);
    c.close();
    return q;
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) MoleculeReader(ambit2.core.processors.structure.MoleculeReader) Fingerprinter(org.openscience.cdk.fingerprint.Fingerprinter) IStructureRecord(ambit2.base.interfaces.IStructureRecord) StructureRecord(ambit2.base.data.StructureRecord) CreateFingerprintStructure(ambit2.db.update.fp.CreateFingerprintStructure) ProcessorStructureRetrieval(ambit2.db.processors.ProcessorStructureRetrieval) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) FingerprintGenerator(ambit2.core.processors.structure.FingerprintGenerator)

Aggregations

FingerprintGenerator (ambit2.core.processors.structure.FingerprintGenerator)10 Fingerprinter (org.openscience.cdk.fingerprint.Fingerprinter)10 IStructureRecord (ambit2.base.interfaces.IStructureRecord)6 MoleculeReader (ambit2.core.processors.structure.MoleculeReader)6 BitSet (java.util.BitSet)6 ProcessorStructureRetrieval (ambit2.db.processors.ProcessorStructureRetrieval)4 StructureRecord (ambit2.base.data.StructureRecord)3 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)3 Test (org.junit.Test)3 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)3 RawIteratingSDFReader (ambit2.core.io.RawIteratingSDFReader)2 QueryCombinedStructure (ambit2.db.search.structure.QueryCombinedStructure)2 QueryPrescreenBitSet (ambit2.db.search.structure.QueryPrescreenBitSet)2 QuerySimilarityBitset (ambit2.db.search.structure.QuerySimilarityBitset)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)2 EStateFingerprinter (org.openscience.cdk.fingerprint.EStateFingerprinter)2 ExtendedFingerprinter (org.openscience.cdk.fingerprint.ExtendedFingerprinter)2 HybridizationFingerprinter (org.openscience.cdk.fingerprint.HybridizationFingerprinter)2