use of ambit2.core.data.IStructureDiagramHighlights in project ambit-mirror by ideaconsult.
the class ModelImageReporter method getImage.
protected BufferedImage getImage(ModelPredictor predictor, String resultsURI) throws ResourceException {
if (dataset == null) {
// legend only
if (predictor instanceof IStructureDiagramHighlights)
try {
return ((IStructureDiagramHighlights) predictor).getLegend(d.width, d.height);
} catch (AmbitException x) {
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, x.getMessage(), x);
}
else
throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, OpenTox.params.dataset_uri.getDescription());
}
Reference firstmol = new Reference(dataset);
firstmol.addQueryParameter(OpenTox.params.feature_uris.toString(), resultsURI);
firstmol.addQueryParameter("max", "1");
ClientResourceWrapper client = new ClientResourceWrapper(firstmol);
Representation r = null;
IteratingSDFReader reader = null;
try {
r = client.get(ChemicalMediaType.CHEMICAL_MDLSDF);
reader = new IteratingSDFReader(r.getStream(), SilentChemObjectBuilder.getInstance());
while (reader.hasNext()) {
Object o = reader.next();
if (o instanceof IAtomContainer)
return predictor.getImage((IAtomContainer) o, param, d.width, d.height, false);
}
} catch (ResourceException x) {
throw x;
} catch (Exception x) {
throw new ResourceException(x);
} finally {
try {
reader.close();
} catch (Exception x) {
}
try {
r.release();
} catch (Exception x) {
}
try {
client.release();
} catch (Exception x) {
}
}
return null;
}
Aggregations