Technical Support Forum Index
Technical Support Forum
Access ChemAxon scientists and developers here. For registration and login issues contact website support.

Support Ticket System is replacing forum

This forum was converted into a searchable archive. You cannot add posts here any more. For support please use our new Ticket System.

Create your first ticket
LibraryMCS NullPointerException
To watch this topic for replies  Register (enables digests) or give email address:
This topic is locked: you cannot edit posts or make replies.
Display posts from previous:   
    View previous topic :: View next topic    
Author Message
Steven

Joined: 02 Nov 2001
Posts: 52

View user's profile

Back to top
Link to postPosted: Tue Mar 25, 2014 4:48 pmPost subject: LibraryMCS NullPointerException Reply with quote

Hello.  I'm getting a NullPointerException while using the LibraryMCS Java API.  This is what I get for a stack trace:

java.lang.NullPointerException

at chemaxon.clustering.LibraryMCS$ClusterEnumerator.next(LibraryMCS.java:744)

 

I'm using version 6.2.0.  Please let me know if you have a fix/work-around.  Thanks.

-&

László
ChemAxon personnel
Joined: 14 Jan 2011
Posts: 78

View user's profile

Back to top
Link to postPosted: Fri Mar 28, 2014 11:28 amPost subject: Reply with quote

Dear Steven,

We cannot reproduce this issue.
Could you send us a short example code which does not work for you? Is NPE thrown by every molecule set or only by a specific?

Best regards,
Laszlo

Steven

Joined: 02 Nov 2001
Posts: 52

View user's profile

Back to top
Link to postPosted: Fri Mar 28, 2014 6:28 pmPost subject: Reply with quote

I'm doing several thousand pairwise comparisons.  The vast majority of the comparisons work fine.  There may be a better way of doing what I'm trying to do.  Please see my method below.  The NPE is thrown at the ce.next() method call.  Unfortunately, catching the NPE doesn't work.

    public static Molecule calcMcs(Molecule m1, Molecule m2) {

        log.debug("Entered calcMcs()");

        LibraryMCS mcs = new LibraryMCS();

//        mcs.setAtomTypeMatch(false);

        mcs.setAtomTypeMatch(true);

        LibraryMCS.ClusterEnumerator ce = null;

        mcs.addMolecule(m1);

        mcs.addMolecule(m2);

        Boolean srch = null;

        Molecule rcore = null;

        Integer cnt = 0;

        try {

            srch = mcs.search();

        } catch (InterruptedException ex) {

            ex.printStackTrace();

        }

        if (!srch) {

            try {

                log.error("could not find MCSS: " + MolExporter.exportToFormat(m1, "smiles:u") + "  " + MolExporter.exportToFormat(m2, "smiles:u"));

            } catch (IOException ex) {

                ex.printStackTrace();

            }

            return null;

        } else {

            ce = mcs.getClusterEnumerator(false);

            Molecule core = null;

            while (ce != null && ce.hasNext()) {

                try {

                    core = ce.next();

                } catch (NullPointerException npe) {

                    log.error("Caught NullPointerException", npe);

                    return null;

                }

                cnt++;

                if (rcore != null) {

                    if (rcore.getMass() < core.getMass()) {

                        rcore = core;

                    }

                } else {

                    rcore = core;

                }

            }

        }

        log.debug("leaving calcMcs: " + cnt);

        return rcore;

    }

László
ChemAxon personnel
Joined: 14 Jan 2011
Posts: 78

View user's profile

Back to top
Link to postPosted: Wed Apr 16, 2014 1:42 pmPost subject: Reply with quote

Dear Steven,

Sorry for the very late answer.
We have investigated the issue and hopefully we will fix it in the next release.

There are a simpler way to find the MCS of two molecules. Please try the following code:

MaxCommonSubstructure mcs = MaxCommonSubstructure.newInstance();
mcs.setMolecules(Molecule m1, Molecule m2);
McsSearchResult result = mcs.nextResult();
        
result.getAsMolecule();

API documentation: https://www.chemaxon.com/jchem/doc/dev/java/api/com/chemaxon/search/mcs/MaxCommonSubstructure.html

Best regards,
Laszlo

This topic is locked: you cannot edit posts or make replies.
Page 1 of 1


To watch this topic for replies   Register (enables digests) or give email address  
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum