Search in sources :

Example 1 with SMARTSPropertiesReader

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;
    }
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) MoleculeReader(ambit2.core.processors.structure.MoleculeReader) SMARTSPropertiesReader(ambit2.smarts.processors.SMARTSPropertiesReader) SuppleAtomContainer(ambit2.core.groups.SuppleAtomContainer) UniversalIsomorphismTester(org.openscience.cdk.isomorphism.UniversalIsomorphismTester) AtomConfigurator(ambit2.core.processors.structure.AtomConfigurator) AmbitException(net.idea.modbcum.i.exceptions.AmbitException)

Example 2 with SMARTSPropertiesReader

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;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SMARTSPropertiesReader(ambit2.smarts.processors.SMARTSPropertiesReader) AtomConfigurator(ambit2.core.processors.structure.AtomConfigurator) AmbitException(net.idea.modbcum.i.exceptions.AmbitException)

Aggregations

AtomConfigurator (ambit2.core.processors.structure.AtomConfigurator)2 SMARTSPropertiesReader (ambit2.smarts.processors.SMARTSPropertiesReader)2 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)2 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)2 SuppleAtomContainer (ambit2.core.groups.SuppleAtomContainer)1 MoleculeReader (ambit2.core.processors.structure.MoleculeReader)1 UniversalIsomorphismTester (org.openscience.cdk.isomorphism.UniversalIsomorphismTester)1