Hi,

Welcome to the CDK community.

Atom types can be determined with

AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);

If you do this before detecting aromaticity, the exception should go away.

Best wishes
Uli


On Thu, Oct 12, 2023 at 3:02 AM Velusamy Velu <vv...@peruselab.com> wrote:

> Hi
>
> I'm a new user of CDK. It's a great tool and I'm learning a lot. I'm
> currently trying to use the aromaticity detection tool, the Aromaticity. In
> a test I built a benzene molecule, an instance of the IAtomContainer. This
> was successful and I was able to create an image of it in the SVG format.
> Then I went on to try to detect aromaticity using the following code
> snippet.
>
> Aromaticity a = new Aromaticity(ElectronDonation.cdk(), Cycles.all());
> a.apply(molecule);
>
> The aromaticity.apply call throws the following error.
>
> java.lang.NullPointerException: atom has unset atom type
>     at java.util.Objects.requireNonNull(Objects.java:228)
>     at
> org.openscience.cdk.aromaticity.AtomTypeModel.contribution(AtomTypeModel.java:112)
>
> I trace the error back to this line of code in AtomTypeModel.java
> Objects.requireNonNull(atom.getAtomTypeName(), "atom has unset atom type");
>
> Am I supposed to programmatically set the AtomTypeName? If the answer is
> yes, then why so? Is there a simpler way to set the atom type name?
>
> I will greatly appreciate your help.
>
> Thanks
>
> Velusamy K. Velu
> (614) 323-9649
> <https://peruselab.com>  <https://www.linkedin.com/company/peruselab/>
> <https://twitter.com/PeruseLab>  <https://www.facebook.com/PeruseLab/>
> _______________________________________________
> Cdk-user mailing list
> Cdk-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cdk-user
>
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to