Search in sources :

Example 1 with ProcessorStructureRetrieval

use of ambit2.db.processors.ProcessorStructureRetrieval 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 ProcessorStructureRetrieval

use of ambit2.db.processors.ProcessorStructureRetrieval in project ambit-mirror by ideaconsult.

the class CSVReporter method configurePropertyProcessors.

@Override
protected void configurePropertyProcessors() {
    super.configurePropertyProcessors();
    getProcessors().add(new ProcessorStructureRetrieval(new ReadChemicalIds()) {

        @Override
        public IStructureRecord process(IStructureRecord target) throws AmbitException {
            ((ReadChemicalIds) getQuery()).setValue(target);
            return super.process(target);
        }
    });
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) ProcessorStructureRetrieval(ambit2.db.processors.ProcessorStructureRetrieval) ReadChemicalIds(ambit2.db.readers.ReadChemicalIds) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) DbAmbitException(net.idea.modbcum.i.exceptions.DbAmbitException)

Example 3 with ProcessorStructureRetrieval

use of ambit2.db.processors.ProcessorStructureRetrieval in project ambit-mirror by ideaconsult.

the class DbReaderTest method testProcess.

@Test
public void testProcess() throws Exception {
    setUpDatabaseFromResource("ambit2/db/processors/test/descriptors-datasets.xml");
    IDatabaseConnection c = getConnection();
    ITable names = c.createQueryTable("EXPECTED_NAMES", "SELECT * FROM properties");
    Assert.assertEquals(5, names.getRowCount());
    ITable values = c.createQueryTable("EXPECTED_VALUES", "SELECT * FROM property_values");
    Assert.assertEquals(2, values.getRowCount());
    ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor> p = new ProcessorsChain<IStructureRecord, IBatchStatistics, IProcessor>();
    p.add(new ProcessorStructureRetrieval());
    p.add(new IProcessor<IStructureRecord, IStructureRecord>() {

        public boolean isEnabled() {
            return true;
        }

        public IStructureRecord process(IStructureRecord target) throws AmbitException {
            // System.out.println(target.getContent());
            return target;
        }

        public void setEnabled(boolean value) {
        }

        public long getID() {
            return 0;
        }

        @Override
        public void open() throws Exception {
        }

        @Override
        public void close() throws Exception {
        }
    });
    p.add(new MoleculeReader());
    p.add(new AtomConfigurator());
    p.add(new FunctionalGroup("Test", "P", "Test"));
    p.add(new IProcessor<VerboseDescriptorResult, String>() {

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

        public String process(VerboseDescriptorResult target) throws AmbitException {
            Assert.assertEquals("1", target.getResult().toString());
            return target.toString();
        }

        public boolean isEnabled() {
            return true;
        }

        public void setEnabled(boolean value) {
        }

        public long getID() {
            return 0;
        }

        @Override
        public void open() throws Exception {
        }

        @Override
        public void close() throws Exception {
        }
    });
    batch.setProcessorChain(p);
    QueryStructureByID query = new QueryStructureByID(100215);
    batch.setConnection(c.getConnection());
    batch.open();
    IBatchStatistics stats = batch.process(query);
    Assert.assertEquals(1, stats.getRecords(IBatchStatistics.RECORDS_STATS.RECORDS_READ));
    Assert.assertEquals(1, stats.getRecords(IBatchStatistics.RECORDS_STATS.RECORDS_PROCESSED));
// C20H20BrP
}
Also used : IBatchStatistics(net.idea.modbcum.i.batch.IBatchStatistics) IProcessor(net.idea.modbcum.i.processors.IProcessor) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) QueryStructureByID(ambit2.db.search.structure.QueryStructureByID) IStructureRecord(ambit2.base.interfaces.IStructureRecord) FunctionalGroup(ambit2.descriptors.FunctionalGroup) MoleculeReader(ambit2.core.processors.structure.MoleculeReader) ProcessorsChain(net.idea.modbcum.i.processors.ProcessorsChain) ITable(org.dbunit.dataset.ITable) ProcessorStructureRetrieval(ambit2.db.processors.ProcessorStructureRetrieval) AtomConfigurator(ambit2.core.processors.structure.AtomConfigurator) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) VerboseDescriptorResult(ambit2.descriptors.VerboseDescriptorResult) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) DbUnitTest(ambit2.db.processors.test.DbUnitTest) Test(org.junit.Test)

Example 4 with ProcessorStructureRetrieval

use of ambit2.db.processors.ProcessorStructureRetrieval 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)

Example 5 with ProcessorStructureRetrieval

use of ambit2.db.processors.ProcessorStructureRetrieval in project ambit-mirror by ideaconsult.

the class FPAtomEnvironmentCrudTest method createQuery.

@Override
protected IQueryUpdate<IStructureRecord, IStructureRecord> createQuery() throws Exception {
    CreateAtomEnvironmentMatrix q = new CreateAtomEnvironmentMatrix();
    IStructureRecord record = new StructureRecord(7, 100211, null, null);
    IDatabaseConnection c = getConnection();
    ProcessorStructureRetrieval p = new ProcessorStructureRetrieval();
    p.setConnection(c.getConnection());
    AtomEnvironmentMatrixGenerator gen = new AtomEnvironmentMatrixGenerator(3);
    record = gen.process(p.process(record));
    q.setObject(record);
    q.setGroup(record);
    c.close();
    return q;
}
Also used : IStructureRecord(ambit2.base.interfaces.IStructureRecord) IStructureRecord(ambit2.base.interfaces.IStructureRecord) StructureRecord(ambit2.base.data.StructureRecord) AtomEnvironmentMatrixGenerator(ambit2.descriptors.processors.AtomEnvironmentMatrixGenerator) ProcessorStructureRetrieval(ambit2.db.processors.ProcessorStructureRetrieval) IDatabaseConnection(org.dbunit.database.IDatabaseConnection) CreateAtomEnvironmentMatrix(ambit2.db.update.fpae.CreateAtomEnvironmentMatrix)

Aggregations

IStructureRecord (ambit2.base.interfaces.IStructureRecord)16 ProcessorStructureRetrieval (ambit2.db.processors.ProcessorStructureRetrieval)16 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)9 IBatchStatistics (net.idea.modbcum.i.batch.IBatchStatistics)7 IProcessor (net.idea.modbcum.i.processors.IProcessor)7 ProcessorsChain (net.idea.modbcum.i.processors.ProcessorsChain)7 RetrieveStructure (ambit2.db.readers.RetrieveStructure)6 MoleculeReader (ambit2.core.processors.structure.MoleculeReader)5 IDatabaseConnection (org.dbunit.database.IDatabaseConnection)5 StructureRecord (ambit2.base.data.StructureRecord)4 FingerprintGenerator (ambit2.core.processors.structure.FingerprintGenerator)4 Fingerprinter (org.openscience.cdk.fingerprint.Fingerprinter)4 QuerySmilesByID (ambit2.db.search.QuerySmilesByID)3 DbAmbitException (net.idea.modbcum.i.exceptions.DbAmbitException)3 QueryStructureByID (ambit2.db.search.structure.QueryStructureByID)2 AtomEnvironmentMatrixGenerator (ambit2.descriptors.processors.AtomEnvironmentMatrixGenerator)2 LiteratureEntry (ambit2.base.data.LiteratureEntry)1 SourceDataset (ambit2.base.data.SourceDataset)1 ModelQueryResults (ambit2.core.data.model.ModelQueryResults)1 StructureNormalizer (ambit2.core.processors.StructureNormalizer)1