CDK Render handling of missing cells

Hi

It seems when creating CDK cells already missing rows (and maybe also failed conversions) are removed. 

In my implementation, if I have a missing cell come in I have a missing cell go out and missing cells for the expected generated values. 

The CDK Value render is falling over when the IAtomContainer is null resulting in the output table not being rendered correctly. 

I believe the CDKValueRender#setAtomContainer method should be:

 

/**
 * Sets a new object to be rendered.
 *
 * @param con
 *            the new molecule to be rendered (null is ok)
 */
protected void setAtomContainer(final IAtomContainer con)
{
    m_mol = con;
    if (m_mol != null)
    {
        try
        {
            LayoutHelper.adjustStereo(m_mol);
        } catch (IllegalArgumentException exception)
        {
            m_mol = con;
        }
 
        switch (numbering)
        {
        case SEQUENTIAL:
            int i = 1;
            for (IAtom atom : con.atoms())
            {
                String label = Integer.toString(i++);
                atom.setProperty(StandardGenerator.ANNOTATION_LABEL, label);
            }
            break;
        case CANONICAL:
            for (IAtom atom : con.atoms())
            {
                String label = atom.getID();
                atom.setProperty(StandardGenerator.ANNOTATION_LABEL, label);
            }
            break;
        case NONE:
            break;
        }
    }
 
}

With the switch inside the if (m_mol != null) block. Otherwise the con.atoms() throws a null pointer exception. 

Making the change as posted above gives a correctly rendered output table. 

 

 

Cheers

Sam

Hi Sam,

that would indeed be the correct and expected behavior. Thanks for providing the patch. I've amended the CDKValueRender#setAtomContainer method and updated the SVN trunk.

Cheers,

Stephan

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.