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;
}
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;
}
Aggregations