use of ambit2.core.data.StringArrayResult in project ambit-mirror by ideaconsult.
the class InChI method calculate.
public DescriptorValue calculate(IAtomContainer mol) {
try {
InChIGenerator gen = processor.process(mol);
INCHI_RET ret = gen.getReturnStatus();
if (ret.equals(INCHI_RET.OKAY) || ret.equals(INCHI_RET.WARNING)) {
StringArrayResult value = new StringArrayResult(new String[] { gen.getInchi(), null, gen.getInchiKey() });
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), value, getDescriptorNames());
} else {
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), null, getDescriptorNames(), new Exception(String.format("[%s] %s", gen.getReturnStatus(), gen.getMessage())));
}
} catch (Exception x) {
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), null, getDescriptorNames(), x);
}
}
use of ambit2.core.data.StringArrayResult in project ambit-mirror by ideaconsult.
the class PropertyCalculationProcessorTest method testInChI.
@Test
public void testInChI() throws Exception {
PropertyCalculationProcessor p = new PropertyCalculationProcessor();
Property prop = Property.getInstance("Count", "Descriptors");
prop.setLabel("Count");
prop.setClazz(Class.forName("ambit2.descriptors.InChI"));
p.setProperty(prop);
DescriptorValue value = p.process(MoleculeFactory.makeAlkane(10));
Assert.assertNotNull(value);
Assert.assertTrue(value.getValue() instanceof StringArrayResult);
StringArrayResult r = (StringArrayResult) value.getValue();
Assert.assertEquals("InChI=1S/C10H22/c1-3-5-7-9-10-8-6-4-2/h3-10H2,1-2H3", r.get(0));
// Assert.assertEquals("AuxInfo=1/0/N:1,10,2,9,3,8,4,7,5,6/E:(1,2)(3,4)(5,6)(7,8)(9,10)/rA:10CCCCCCCCCC/rB:s1;s2;s3;s4;s5;s6;s7;s8;s9;/rC:;;;;;;;;;;",
// r.get(1));
// we discarded AuxInfo
Assert.assertNull(r.get(1));
Assert.assertEquals("DIOQZVSQGTUSAI-UHFFFAOYSA-N", r.get(2));
}
use of ambit2.core.data.StringArrayResult in project ambit-mirror by ideaconsult.
the class AtomTypeVerifierDescriptor method calculate.
public DescriptorValue calculate(IAtomContainer mol) {
String pref = Preferences.getProperty(Preferences.STOP_AT_UNKNOWNATOMTYPES);
Preferences.setProperty(Preferences.STOP_AT_UNKNOWNATOMTYPES, "true");
try {
typer.process(mol);
StringArrayResult value = new StringArrayResult(new String[] { OK });
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), value, getDescriptorNames());
} catch (Exception x) {
StringArrayResult value = new StringArrayResult(new String[] { x.getMessage() });
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), value, getDescriptorNames());
} finally {
Preferences.setProperty(Preferences.STOP_AT_UNKNOWNATOMTYPES, pref == null ? "false" : pref);
}
}
Aggregations