NullPointerException during isMatching()

User 870ab5b546

16-06-2009 13:47:28

The code:


            debugPrint("matchExactLewis: after pseudoatom replacement, response is:\n"
+ respMol.toFormat("mrv"));
debugPrint("and reference molecule is:"
+ authMol.toFormat("mrv"));
MolSearch search = new MolSearch();
MolSearchOptions searchOpts = new MolSearchOptions();
searchOpts.setSearchType(SearchConstants.FULL);
searchOpts.setStereoSearchType(SearchConstants.STEREO_IGNORE);
searchOpts.setExactBondMatching(true);
searchOpts.setSubgraphSearch(false);
searchOpts.setChargeMatching(SearchConstants.CHARGE_MATCHING_EXACT);
searchOpts.setIsotopeMatching(SearchConstants.ISOTOPE_MATCHING_EXACT);
searchOpts.setRadicalMatching(SearchConstants.RADICAL_MATCHING_EXACT);
searchOpts.setValenceMatching(true);
searchOpts.setVagueBondLevel(SearchConstants.VAGUE_BOND_OFF);
search.setSearchOptions(searchOpts);
search.addComparator(new ExplicitHMatcher());
search.setTarget(respMol);
search.setQuery(authMol);
boolean match = search.isMatching();
debugPrint("MolFunctions.matchExactLewis: returning " + match);
return match;

The log:

matchExactLewis: after pseudoatom replacement, response is:
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<propertyList>
<property dictRef="is Lewis Structure?" title="is Lewis Structure?">
<scalar>true</scalar>
</property>
</propertyList>
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16"
elementType="C C C C C C C H H H H H H H H H"
mrvAlias="N2 C C C C O4 O4 0 0 0 0 0 0 0 0 0"
mrvPseudo="N2 0 0 0 0 O4 O4 0 0 0 0 0 0 0 0 0"
x2="2.428077207366661 3.3525545838119046 4.454530681879907 5.6667051686336505 6.909718068882721 6.951569830588792 8.36654102693452 1.1210560358333814 2.6638230923812114 2.2781300301126874 3.8484434385030357 4.068840215874516 5.639156220527998 5.281012106365126 6.603384981804609 9.523615021213827"
y2="3.016995362644138 3.852568900621581 3.0720958551185746 4.201620901292229 3.2924900362269223 1.639527187256485 4.33002169080435 3.5955362541784908 1.8048234721535286 5.1658496625688395 5.331145947465883 2.0803207419994454 1.4191356024112707 5.1658496625688395 5.331145947465883 3.5679847098097057"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a2 a3" order="1" />
<bond atomRefs2="a3 a4" order="1" />
<bond atomRefs2="a4 a5" order="1" />
<bond atomRefs2="a5 a6" order="2" />
<bond atomRefs2="a5 a7" order="1" />
<bond atomRefs2="a1 a8" order="1" />
<bond atomRefs2="a1 a9" order="1" />
<bond atomRefs2="a2 a10" order="1" />
<bond atomRefs2="a2 a11" order="1" />
<bond atomRefs2="a3 a12" order="1" />
<bond atomRefs2="a3 a13" order="1" />
<bond atomRefs2="a4 a14" order="1" />
<bond atomRefs2="a4 a15" order="1" />
<bond atomRefs2="a7 a16" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

and reference molecule is:<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<propertyList>
<property dictRef="is Lewis Structure?" title="is Lewis Structure?">
<scalar>true</scalar>
</property>
</propertyList>
<atomArray
atomID="a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16"
elementType="C H H C C C C C C H H H H H H H"
mrvPseudo="N2 0 0 0 0 0 0 O4 O4 0 0 0 0 0 0 0"
x2="2.488366825927443 1.6268301970520662 1.3856010865131216 3.901277732913774 5.004043472328095 6.313571702168622 7.485256362481412 7.485256362481412 8.898172997198545 10.069857657511335 3.2120512936788748 4.452657738755533 4.452657738755533 5.693267047697593 5.756369457964654 7.1883021589508855"
y2="3.979111866808582 5.116332770874033 3.0486534531693357 5.023620856215978 4.116955436336321 5.288640096649109 4.289262762111396 2.497273447327577 5.553352903484228 6.494788513209234 6.425863864579962 6.598171190355038 2.7729634502484566 2.841885235012326 6.815999656694466 6.7587223486550165"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="1" />
<bond atomRefs2="a1 a3" order="1" />
<bond atomRefs2="a1 a4" order="1" />
<bond atomRefs2="a4 a5" order="1" />
<bond atomRefs2="a5 a6" order="1" />
<bond atomRefs2="a6 a7" order="1" />
<bond atomRefs2="a7 a8" order="2" />
<bond atomRefs2="a7 a9" order="1" />
<bond atomRefs2="a9 a10" order="1" />
<bond atomRefs2="a4 a11" order="1" />
<bond atomRefs2="a4 a12" order="1" />
<bond atomRefs2="a5 a13" order="1" />
<bond atomRefs2="a5 a14" order="1" />
<bond atomRefs2="a6 a15" order="1" />
<bond atomRefs2="a6 a16" order="1" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>

chemaxon.sss.search.SearchException: An error occured during search:java.lang.NullPointerException
Query:[H]
  • C(=
  • )C([H])([H])C([H])([H])C([H])([H])
  • ([H])[H] |$;O4_p;;O4_p;;;;;;;;;;N2_p;;$|
    Target:[H]*C(=*)C([H])([H])C([H])([H])C([H])([H])*([H])[H] |$;O4_p;C;O4_p;C;;;C;;;C;;;N2_p;;$|

    Caused by:
    java.lang.NullPointerException
    at chemaxon.sss.search.MolSearch.getWrapperSearchException(MolSearch.java:634)
    at chemaxon.sss.search.MolSearch.isMatching(MolSearch.java:624)
    at com.prenhall.epoch.chem.MolFunctions.matchExactLewis(MolFunctions.java:442)

When I use the SMILES structure for the query, there's no problem.  When I use the MRV structure, there is.  I can use either the SMILES or MRV structures for the target.  Same problem exists in both JChem 5.1.5 and 5.2.1.





A few more bits of information from playing around with the structures in my JChem comparator page:




  1. I also get the NullPointerException when the O atoms, but not the N atoms, in both structures are replaced with pseudoatoms.  However, if the N atom in the query is replaced with a pseudoatom and the N atom in the target is not, I don't get an exception; instead, the compounds (correctly) don't match.

  2. If I remove just one explicit H from the C atom adjacent to the N2 pseudoatom in the query, the search works, but if I remove it from the same atom in the target or from a different C atom in the query, it doesn't.  

  3. If I switch to duplicate search type, the search works, but it doesn't work for the substructure search type.

  4. I haven't encountered the problem with any other structures.  For example, morpholin-3-one works fine, even though it also has two O atoms and one N atom.


ChemAxon 42004978e8

17-06-2009 14:12:50

Hi Bob,


We have found the source of this bug. There is an erronous handling of pseudo atoms when having expicit hydrogens.


We will fix this bug by next release scheduled in 2-3 weeks.


Thanks for reporting this bug!


Bye,


Robert

ChemAxon 42004978e8

11-07-2009 09:43:35

Hi Bob,


Version 5.2.3 is released with the fix of this bug.


Bye,


Robert