class AminoAcidCountDescriptor extends AbstractMolecularDescriptor implements IMolecularDescriptor {

    @Override
    public DescriptorValue calculate(IAtomContainer ac) {
        ac = clone(ac); // don't modify input
        int resultLength = substructureSet.getAtomContainerCount();
        IntegerArrayResult results = new IntegerArrayResult(resultLength);

        UniversalIsomorphismTester universalIsomorphismTester = new UniversalIsomorphismTester();
        IAtomContainer substructure;
        for (int i = 0; i < resultLength; i++) {
            substructure = substructureSet.getAtomContainer(i);
            List<List<RMap>> maps;
            try {
                maps = universalIsomorphismTester.getSubgraphMaps(ac, substructure);
            } catch (CDKException e) {
                // TODO is it OK to cast Double.NaN to int?
                for (int j = 0; j < resultLength; j++)
                    results.add((int) Double.NaN);
                return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), results,
                        getDescriptorNames(), new CDKException("Error in substructure search: " + e.getMessage()));
            }
            if (maps != null) {
                results.add(maps.size());
            }
        }

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), results,
                getDescriptorNames());
    }

    public  AminoAcidCountDescriptor();

}