superstructure search error

User da00f5c453

09-04-2010 20:28:10

Hi all, 


I am trying to create a database of query structures to be queried with regular structures to see what chemical structures contain the query structures in the database. All queries are encoded as SMARTS and imported into a query table in IJC, however for some particular query/target examples the search fails with an exception:


java.lang.NullPointerException
at chemaxon.sss.search.StructureSearch.initQueryProperties(StructureSearch.java:3183)
at chemaxon.sss.search.StructureSearch.initSearch(StructureSearch.java:1455)
at chemaxon.sss.search.StructureSearch.findFirst0(StructureSearch.java:6109)
at chemaxon.sss.search.StructureSearch.isMatching0(StructureSearch.java:6693)
at chemaxon.sss.search.StructureSearch.isMatching(StructureSearch.java:6685)
at chemaxon.sss.search.MolSearch.isMatching(MolSearch.java:703)
Caused: chemaxon.sss.search.SearchException: An error occured during search:java.lang.NullPointerException
Query:c1cnnc1
Target:
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5"
elementType="C C N N C"
mrvQueryProps="a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])]"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="A" />
<bond atomRefs2="a2 a3" order="A" />
<bond atomRefs2="a3 a4" order="A" />
<bond atomRefs2="a4 a5" order="A" />
<bond atomRefs2="a1 a5" order="A" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>


Caused by:
java.lang.NullPointerException
at chemaxon.sss.search.MolSearch.getWrapperSearchException(MolSearch.java:729)
at chemaxon.sss.search.MolSearch.isMatching(MolSearch.java:719)
at chemaxon.jchem.db.JChemSearch.isMatching(JChemSearch.java:4117)
at chemaxon.jchem.db.JChemSearch.access$1300(JChemSearch.java:120)
at chemaxon.jchem.db.JChemSearch$ABASThread.run(JChemSearch.java:471)
Caused: org.springframework.dao.InvalidDataAccessResourceUsageException: Exception occurred when executing JChem search; nested exception is chemaxon.sss.search.SearchException: An error occured during search:java.lang.NullPointerException
Query:c1cnnc1
Target:
<?xml version="1.0" ?>
<cml>
<MDocument>
<MChemicalStruct>
<molecule molID="m1">
<atomArray
atomID="a1 a2 a3 a4 a5"
elementType="C C N N C"
mrvQueryProps="a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])] a1;str:[x2!$(*=[!R])]"
/>
<bondArray>
<bond atomRefs2="a1 a2" order="A" />
<bond atomRefs2="a2 a3" order="A" />
<bond atomRefs2="a3 a4" order="A" />
<bond atomRefs2="a4 a5" order="A" />
<bond atomRefs2="a1 a5" order="A" />
</bondArray>
</molecule>
</MChemicalStruct>
</MDocument>
</cml>


Caused by:
java.lang.NullPointerException
at com.im.ijcs.impl.query.JChemExecutor.executeJChemSearch(JChemExecutor.java:268)
at com.im.ijcs.impl.query.JChemExecutor.execute(JChemExecutor.java:156)
at com.im.ijcs.impl.query.JChemExecutor.run(JChemExecutor.java:359)
at com.im.ijcs.impl.query.Executor.visitStructureQuery(Executor.java:152)
at com.im.ijcs.impl.query.Executor.visitSqlQuery(Executor.java:185)
at com.im.ijcs.impl.query.Executor.execute(Executor.java:143)
at com.im.df.server.local.LocalQueryExecutor.access$001(LocalQueryExecutor.java:14)
at com.im.df.server.local.LocalQueryExecutor$1.doInTransactionWithoutResult(LocalQueryExecutor.java:48)
at org.springframework.transaction.support.TransactionCallbackWithoutResult.doInTransaction(TransactionCallbackWithoutResult.java:33)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
at com.im.df.server.local.LocalQueryExecutor.execute(LocalQueryExecutor.java:46)
at com.im.ijcs.impl.query.DefaultQueryService.findIDs(DefaultQueryService.java:44)
at com.im.df.impl.db.DBSchemaDataProviderImpl.queryForIdsImpl(DBSchemaDataProviderImpl.java:439)
at com.im.df.impl.db.DBEntityDataProviderImpl.queryForIds(DBEntityDataProviderImpl.java:156)
at com.im.df.impl.db.ResultSetImpl.applyQueryInternal(ResultSetImpl.java:195)
at com.im.df.impl.db.ResultSetImpl.applyWorkingQuery(ResultSetImpl.java:148)
at com.im.ijc.core.query.exec.ExecutableQueryPanel$2.phase1InRequestProcessor(ExecutableQueryPanel.java:232)
at com.im.commons.progress.BackgroundRunner.processTheTask(BackgroundRunner.java:126)
at com.im.commons.progress.BackgroundRunner$1.run(BackgroundRunner.java:90)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:577)
[catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:1030)

I can reproduce the error with a simple Java program:


Molecule query = MolImporter.importMol("c1cnnc1", "smiles");


Molecule target = MolImporter.importMol("[c;x2!$(*=[!R])]:1:[c;x2!$(*=[!R])]:[n;x2!$(*=[!R])]:[n;x2!$(*=[!R])]:[c;x2!$(*=[!R])]:1", "smarts:d");


StandardizedMolSearch ms = new StandardizedMolSearch();


ms.setSearchType(SearchConstants.SUPERSTRUCTURE);


ms.setTarget(target);


ms.setQuery(query);


System.out.println(ms.isMatching());



wich raises the same exception. Am I doing something wrong? Are the SMARTS used in my application not supported?


IJC 5.3.1 and JChem 5.3.1 with Java 1.6 on Mac OSX 10.6


 


Oleg.

ChemAxon a3d59b832c

12-04-2010 20:51:26

Hi Oleg,


The SMARTS is OK, the problem is in our code.


 


It seems that the "x" (ring bond) query property in a SMARTS logical expression is causing the problem.


Until we fix it, a workaround is to give it as an "rb" query property in mrv:


<?xml version="1.0" ?>
<cml>
<MDocument>
  <MChemicalStruct>
    <molecule molID="m1">
      <atomArray
          atomID="a1 a2 a3 a4 a5"
          elementType="C C N N C"
          mrvQueryProps="a1;rb2;str:[!$(*=[!R])] a1;rb2;str:[!$(*=[!R])] a1;rb2;str:[!$(*=[!R])] a1;rb2;str:[!$(*=[!R])] a1;rb2;str:[!$(*=[!R])]"
          x2="2.3057002501002226 1.8298140787628048 0.2898140787628045 -0.18607209257461532 1.0598140787628036"
          y2="1.1748129563317335 -0.2898140787628034 -0.2898140787628045 1.174812956331732 2.0800022448621416"
          />
      <bondArray>
        <bond atomRefs2="a1 a2" order="A" />
        <bond atomRefs2="a2 a3" order="A" />
        <bond atomRefs2="a3 a4" order="A" />
        <bond atomRefs2="a4 a5" order="A" />
        <bond atomRefs2="a1 a5" order="A" />
      </bondArray>
    </molecule>
  </MChemicalStruct>
</MDocument>
</cml>




 


Best regards,


Szabolcs

User da00f5c453

30-06-2010 04:51:49

Hi Szabolcs,



I think this also could be in the same line as the error I found earlier


code:


Molecule mol1 = MolImporter.importMol("[#6,#16&X2H0,X3H1,X4H2,X5H3,X6H4&!$(S=*),#35,#53;R0;!$(*~[!#1;!#6;!$([#16;X2H0,X3H1,X4H2,X5H3,X6H4])]);X1H0,X2H1,X3H2,X4H3,X5H4,X6H5]~*(~[#6,#16&X2H0,X3H1,X4H2,X5H3,X6H4&!$(S=*),#35,#53;R0;!$(*~[!#1;!#6;!$([#16;X2H0,X3H1,X4H2,X5H3,X6H4])]);X1H0,X2H1,X3H2,X4H3,X5H4,X6H5])~[#6,#16&X2H0,X3H1,X4H2,X5H3,X6H4&!$(S=*),#35,#53;R0;!$(*~[!#1;!#6;!$([#16;X2H0,X3H1,X4H2,X5H3,X6H4])]);X1H0,X2H1,X3H2,X4H3,X5H4,X6H5]", "smarts");
Molecule mol2 = MolImporter.importMol("C(C)(C)C", "smiles");
MolSearch ms = new MolSearch();
ms.setQuery(mol1);
ms.setTarget(mol2);
System.out.println(ms.isMatching());

throws the following exception:


Exception in thread "main" chemaxon.sss.search.SearchException: An error occured during search:java.lang.ArrayIndexOutOfBoundsException: -1
  Query:[R0;#6,#16X2H0,X3H1,X4H2,X5H3,X6H4!$(S=*),#35,#53;!$(*~[!#1;!#6;!$([#16;X2H0,X3H1,X4H2,X5H3,X6H4])]);X1H0,X2H1,X3H2,X4H3,X5H4,X6H5]~*(~[R0;#6,#16X2H0,X3H1,X4H2,X5H3,X6H4!$(S=*),#35,#53;!$(*~[!#1;!#6;!$([#16;X2H0,X3H1,X4H2,X5H3,X6H4])]);X1H0,X2H1,X3H2,X4H3,X5H4,X6H5])~[R0;#6,#16X2H0,X3H1,X4H2,X5H3,X6H4!$(S=*),#35,#53;!$(*~[!#1;!#6;!$([#16;X2H0,X3H1,X4H2,X5H3,X6H4])]);X1H0,X2H1,X3H2,X4H3,X5H4,X6H5]
  Target:CC(C)C

Caused by:
-1
    at chemaxon.sss.search.MolSearch.getWrapperSearchException(MolSearch.java:729)
    at chemaxon.sss.search.MolSearch.isMatching(MolSearch.java:719)
    at edu.unm.health.biocomp.molfp.Test1.main(Test1.java:24)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
    at chemaxon.util.BondClassifier.isRingAtom(Unknown Source)
    at chemaxon.sss.search.StructureSearch.compareAtomQueryProperties(StructureSearch.java:4265)
    at chemaxon.sss.search.StructureSearch.compareAtoms(StructureSearch.java:4459)
    at chemaxon.sss.search.StructureSearch.initMaps(StructureSearch.java:3481)
    at chemaxon.sss.search.StructureSearch.findFirst0(StructureSearch.java:6138)
    at chemaxon.sss.search.StructureSearch.isMatching0(StructureSearch.java:6693)
    at chemaxon.sss.search.StructureSearch.isMatching(StructureSearch.java:6685)
    at chemaxon.sss.search.MolSearch.isMatching(MolSearch.java:703)
    ... 1 more

I tested the SMARTS expresion and match at


http://www.daylight.com/daycgi_tutorials/depictmatch.cgi

and it parses the SMARTS and gives 1 unique match, I also tested it with OEChem toolkit and it passes with 1 unique match. This indicates that the SMARTS expression should be ok. I hope this also helps in debuging the previous error. Note that the SMARTS expression in this example doesn't contain "x" (ring bonds) atom primitive.


Oleg.

User da00f5c453

30-06-2010 21:42:01

Hi Szabolcs,


I think I tracked the error, if you replace in the SMARTS expression above the "R0" atomic primitive with "!R" than the MolSearch doesn't raise any exceptions and gives a match.


Oleg.

ChemAxon a3d59b832c

03-07-2010 14:34:45

Hi Oleg,


 


I am glad you found a workaround.


It seems that it is a different issue then.


We will check this case as well.


 


Best regards,


Szabolcs

ChemAxon 8407015329

20-10-2010 14:35:08

Hi all,


The problem has been fixed and is coming out with version 5.4


 


Regards,


Vencel Bors