use of ambit2.smarts.processors.SMARTSPropertiesReader in project ambit-mirror by ideaconsult.
the class QueryExactStructure method calculateMetric.
@Override
public double calculateMetric(IStructureRecord object) {
try {
if (getValue() != null) {
if (reader == null)
reader = new MoleculeReader();
IAtomContainer mol = reader.process(object);
// empty or markush
if ((mol == null) || (mol.getAtomCount() == 0) || (mol instanceof SuppleAtomContainer))
return 0;
if ("true".equals(Preferences.getProperty(Preferences.FASTSMARTS))) {
Object smartsdata = object.getRecordProperty(smartsProperty);
if (smartsdata != null) {
mol.setProperty(smartsProperty, smartsdata);
if (bondPropertiesReader == null)
bondPropertiesReader = new SMARTSPropertiesReader();
mol = bondPropertiesReader.process(mol);
} else {
mol.removeProperty(smartsProperty);
if (configurator == null)
configurator = new AtomConfigurator();
mol = configurator.process(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
}
} else {
mol.removeProperty(smartsProperty);
if (configurator == null)
configurator = new AtomConfigurator();
mol = configurator.process(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
}
try {
if (((IAtomContainer) mol).getBondCount() > 1)
mol = AtomContainerManipulator.removeHydrogensPreserveMultiplyBonded(mol);
} catch (Exception x) {
}
if (uit == null)
uit = new UniversalIsomorphismTester();
int ok = (getValue().getAtomCount() != mol.getAtomCount()) ? 0 : (getValue().getBondCount() != mol.getBondCount()) ? 0 : uit.isIsomorph(getValue(), mol) ? 1 : 0;
return ok;
} else
return 0;
} catch (Exception x) {
logger.log(Level.WARNING, x.getMessage(), x);
return -1;
}
}
use of ambit2.smarts.processors.SMARTSPropertiesReader in project ambit-mirror by ideaconsult.
the class BitSetGenerator method getAtomContainer.
@Override
protected IAtomContainer getAtomContainer(IStructureRecord target) throws AmbitException {
// TODO Auto-generated method stub
IAtomContainer mol = super.getAtomContainer(target);
if (mol == null)
return null;
try {
if ("true".equals(Preferences.getProperty(Preferences.FASTSMARTS))) {
Object smartsdata = target.getRecordProperty(smartsProperty);
if (smartsdata != null) {
mol.setProperty(smartsProperty, smartsdata);
if (bondPropertiesReader == null)
bondPropertiesReader = new SMARTSPropertiesReader();
mol = bondPropertiesReader.process(mol);
} else {
if ((smartsProperty != null) && (mol != null))
mol.removeProperty(smartsProperty);
if (configurator == null)
configurator = new AtomConfigurator();
mol = configurator.process(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
}
} else {
mol.removeProperty(smartsProperty);
if (configurator == null)
configurator = new AtomConfigurator();
mol = configurator.process(mol);
CDKHueckelAromaticityDetector.detectAromaticity(mol);
}
} catch (Exception x) {
logger.log(Level.WARNING, x.getMessage(), x);
}
return mol;
}
Aggregations