Unfortunately other parts of my code are using new features such as IAtomContainer.atoms() so whilst switching to the legacy IAtomContainer avoids the alignment problem it looks to be a no go as a solution.

Would switching to the legacy classes in the org.openscience.cdk.smsd package be an option or do I just need to wait for the problem to be fixed?


On 28/08/2019 08:15, John Mayfield wrote:
Okay code is likely adding atoms/bonds in the wrong order, will fix it.

On Tue, 27 Aug 2019 at 18:18, Tim Dudgeon <tdudgeon...@gmail.com <mailto:tdudgeon...@gmail.com>> wrote:

    Hi John,

    Yes, turning off AtomContainer2 avoids the error.


    On 27/08/2019 16:31, John Mayfield wrote:
    Hmm odd, in legacy so expected but tests seem okay. Can you try
    turning off AtomContainer2,
    https://github.com/cdk/cdk/wiki/AtomContainer2

    On Tue, 27 Aug 2019 at 14:19, Tim Dudgeon <tdudgeon...@gmail.com
    <mailto:tdudgeon...@gmail.com>> wrote:

        Hi folks,

        I'm getting a NPE from
        AtomAtomMapping.getCommonFragmentAsSMILES() in certain cases.
        An example is below - the two structures differ only for a Cl
        <-> Br change.

        This is using the org.openscience.smsd.AtomAtomMapping,
        org.openscience.smsd.Isomorphism and
        org.openscience.smsd.tools.ExtAtomContainerManipulator classes.
        Not sure if those guys are active on this list?


        IAtomContainer query =smilesParser.parseSmiles('BrC1CCC(Cc2ccccc2)C1')
        IAtomContainer target =smilesParser.parseSmiles('ClC1CCC(Cc2ccccc2)C1')

        StructureDiagramGenerator sdg =new StructureDiagramGenerator()
        sdg.generateCoordinates(query)

        ExtAtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(query)
        ExtAtomContainerManipulator.aromatizeMolecule(query)

        ExtAtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(target)
        ExtAtomContainerManipulator.aromatizeMolecule(target)

        Isomorphism comparison =new Isomorphism(query, target, 
Algorithm.DEFAULT,true,false,false)
        AtomAtomMapping mapping = comparison.getFirstAtomMapping()

        String mcsSmiles = mapping.getCommonFragmentAsSMILES()

        The error I get is:

        java.lang.NullPointerException
            at
        
org.openscience.cdk.silent.AtomContainer2.getAtomRefUnsafe(AtomContainer2.java:172)
            at
        
org.openscience.cdk.silent.AtomContainer2.getBond(AtomContainer2.java:612)
            at
        
org.openscience.smsd.AtomAtomMapping.getCommonFragment(AtomAtomMapping.java:332)
            at
        
org.openscience.smsd.AtomAtomMapping.getCommonFragmentAsSMILES(AtomAtomMapping.java:371)
            at
        
org.squonk.fragnet.depict.ChemUtilsSpec.alignMolecule2(ChemUtilsSpec.groovy:81)




        _______________________________________________
        Cdk-user mailing list
        Cdk-user@lists.sourceforge.net
        <mailto: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