Search in sources :

Example 1 with QueryPrescreenBitSet

use of ambit2.db.search.structure.QueryPrescreenBitSet 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 2 with QueryPrescreenBitSet

use of ambit2.db.search.structure.QueryPrescreenBitSet in project ambit-mirror by ideaconsult.

the class QueryInfo2Query method process.

public IQueryObject process(QueryInfo target) throws AmbitException {
    QueryCombinedStructure combined = new QueryCombinedStructure();
    // scope
    if (QueryInfo.SCOPE_DATABASE.equals(target.getScope()))
        combined.setScope(null);
    else if (QueryInfo.SCOPE_DATASET.equals(target.getScope())) {
        if (target.getDataset() != null) {
            QueryDataset d = new QueryDataset();
            d.setCondition(StringCondition.getInstance(StringCondition.C_EQ));
            d.setValue(target.getDataset());
            combined.setScope(d);
        } else {
            logger.warning("Dataset not defined!");
            combined.setScope(null);
        }
    } else if (QueryInfo.SCOPE_QUERY.equals(target.getScope())) {
        if (target.getStoredQuery() != null) {
            QueryStoredResults d = new QueryStoredResults();
            d.setCondition(EQCondition.getInstance());
            d.setFieldname(target.getStoredQuery());
            combined.setScope(d);
        } else {
            logger.warning("Stored query not defined!");
            combined.setScope(null);
        }
    }
    // and / or
    combined.setCombine_as_and(QueryInfo.COMBINE_ALL.equals(target.getCombine()));
    // identifiers
    QueryField f = createQueryField(Property.getInstance(target.getFieldname1(), ""), target.getIdentifier1(), target.getCondition1());
    if (f != null)
        combined.add(f);
    f = createQueryField(Property.getInstance(target.getFieldname2(), ""), target.getIdentifier2(), target.getCondition2());
    if (f != null)
        combined.add(f);
    f = createQueryField(Property.getInstance(target.getFieldname3(), ""), target.getIdentifier3(), target.getCondition3());
    if (f != null)
        combined.add(f);
    // formula, smiles, inchi
    QueryStructure s = createQueryStructure(ExactStructureSearchMode.formula, target.getFormula());
    if (s != null)
        combined.add(f);
    s = createQueryStructure(ExactStructureSearchMode.smiles, target.getSmiles());
    if (s != null)
        combined.add(f);
    s = createQueryStructure(ExactStructureSearchMode.inchi, target.getInchi());
    if (s != null)
        combined.add(f);
    // similarity
    try {
        QuerySimilarityBitset similarity = createQuerySimilarity(target);
        if (similarity != null)
            combined.add(similarity);
    } catch (AmbitException x) {
        logger.log(java.util.logging.Level.WARNING, x.getMessage(), x);
    }
    // substructure
    try {
        QueryPrescreenBitSet substructure = createQuerySubstructure(target);
        if (substructure != null)
            combined.add(substructure);
    } catch (AmbitException x) {
        logger.log(java.util.logging.Level.WARNING, x.getMessage(), x);
    }
    // substructure
    try {
        QueryStructure exact = createExactStructure(target);
        if (exact != null)
            combined.add(exact);
    } catch (AmbitException x) {
        logger.log(java.util.logging.Level.WARNING, x.getMessage(), x);
    }
    combined.setId(-1);
    return combined;
}
Also used : QuerySimilarityBitset(ambit2.db.search.structure.QuerySimilarityBitset) QueryField(ambit2.db.search.structure.QueryField) QueryStoredResults(ambit2.db.search.structure.QueryStoredResults) QueryStructure(ambit2.db.search.structure.QueryStructure) QueryDataset(ambit2.db.search.structure.QueryDataset) QueryCombinedStructure(ambit2.db.search.structure.QueryCombinedStructure) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) DbAmbitException(net.idea.modbcum.i.exceptions.DbAmbitException) QueryPrescreenBitSet(ambit2.db.search.structure.QueryPrescreenBitSet)

Aggregations

QueryPrescreenBitSet (ambit2.db.search.structure.QueryPrescreenBitSet)2 FingerprintGenerator (ambit2.core.processors.structure.FingerprintGenerator)1 QueryCombinedStructure (ambit2.db.search.structure.QueryCombinedStructure)1 QueryDataset (ambit2.db.search.structure.QueryDataset)1 QueryField (ambit2.db.search.structure.QueryField)1 QuerySimilarityBitset (ambit2.db.search.structure.QuerySimilarityBitset)1 QueryStoredResults (ambit2.db.search.structure.QueryStoredResults)1 QueryStructure (ambit2.db.search.structure.QueryStructure)1 BitSet (java.util.BitSet)1 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)1 DbAmbitException (net.idea.modbcum.i.exceptions.DbAmbitException)1 Fingerprinter (org.openscience.cdk.fingerprint.Fingerprinter)1