class AcidicGroupCountDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor {

    @Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {

        if (tools.isEmpty()) {
            throw new IllegalStateException("descriptor is not initalised, invoke 'initalise' first");
        }

        atomContainer = clone(atomContainer); // don't mod original
        for (IAtom atom : atomContainer.atoms()) {
            if (atom.getImplicitHydrogenCount() == null)
                atom.setImplicitHydrogenCount(0);
        }

        // do aromaticity detection
        if (this.checkAromaticity) {
            try {
                AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(atomContainer);
                Aromaticity.cdkLegacy().apply(atomContainer);
            } catch (CDKException exception) {
                return getDummyDescriptorValue(exception);
            }
        }

        int count = 0;
        for (SmartsPattern tool : tools)
            count += tool.matchAll(atomContainer).count();
        return new DescriptorValue(getSpecification(), getParameterNames(),
                                   getParameters(), new IntegerResult(count),
                                   getDescriptorNames());
    }

    public  AcidicGroupCountDescriptor();

}