isValid and check unexpected results; sometimes throw error

User 3afdb4ab90

08-11-2012 19:35:21

It is importatn for us to have a robust cartridge method to validate SMILES.  We need a method that follows strict rules (even if they are unique to ChemAxon and not others' ideas of SMILES) and one that NEVER throws an exception.  I cannot find such a method in the JChem cartridge.  Here are some examples of expected, unexpected and unacceptable behaviour.


These two examples work as expected:


select jc_evaluate_x('CCOC', 'chemTerms:check("smiles..aromaticity..valence")') from dual; returns "passed"


select jc_evaluate_x('CCOC(C)(F)(Cl)(Br)', 'chemTerms:check("smiles..aromaticity..valence")') from dual; returns "failed"


These were expected to return "failed", but both returned "passed".


select jc_evaluate_x('CCO[CH4]', 'chemTerms:check("smiles..aromaticity..valence")') from dual;


select jc_evaluate_x('junk', 'chemTerms:check("smiles..aromaticity..valence")') from dual;


This one throws an exception:


select jc_evaluate_x('xjunk', 'chemTerms:check("smiles..aromaticity..valence")') from dual;


I also cannot find a description of the available configurations for isValid after following the link " Please, see
the isValid
Evaluator functions for creating configurations" on this page http://www.chemaxon.com/jchem/doc/dev/cartridge/cartapi.html#jc_evaluate_x_check_0_eg


Thanks,


TJ O'Donnell




ChemAxon aa7c50abf8

09-11-2012 20:15:36

TJ,


"smiles" doesn't appear in the checker action list: http://www.chemaxon.com/marvin/help/structurechecker/structurechecker_cline.html#checkers .


Accordingly,


select jc_evaluate_x('CCOC', 'chemTerms:check("smiles..aromaticity..valence")') from dual;

(which returns "passed" for you) throws the following error in the development trunk:


The provided checker configuration contains errors. The indexes of invalid checkers: 1-InvalidChecker

In contrast,


select jc_evaluate_x('CCOC', 'chemTerms:check("aromaticity..valence")') from dual;

(the "smiles" action removed) returns "passed".


Which JChem version are you testing with?


 


Regarding the documentation related question, the isValid function accepts the same argument as the check function. But instead of returning "verbose" results, it returns 1, if valid, 0 if invalid.


Peter

User 3afdb4ab90

09-11-2012 21:38:30

Thanks for the link to the structurechecker options.  I do not see "smiles" as an available option, but I am adding that to my options for isValid().  I was not confused or concerned about the difference between isValid and check.  Rather, I was unhappy with the fact that neither of them are working predictably.  For example, this returns 1 - a valid smiles, whilie it clearly is not.


select  jc_evaluate_x('junk', 'chemTerms:isValid("smiles..aromaticity..valence")') from dual;


and this throws an exception, which is unexepected and not useful:


select  jc_evaluate_x('xjunk', 'chemTerms:isValid("smiles..aromaticity..valence")') from dual;


Here is the output from select jchem_core_pkg.getenvironment() from dual


Oracle environment:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE    11.2.0.3.0    Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

JChem owner: JCHEM

JChem Server environment:
Java VM vendor: Oracle Corporation
Java version: 1.7.0_04
Java VM version: 23.0-b21
JChem version: 5.10.0
JChem Index version: 5100000
JDBC driver version: 11.1.0.7.0-Production

ChemAxon aa7c50abf8

09-11-2012 22:17:42

Hmm, I am starting to suspect where you're trying to get... (Well, you kind of clearly stated it at the beginning of your first post. :-) )


Let me skip, for now, testing with 5.10, even though I am pretty sure that if "smiles" is not listed as an action, you're likely to get an error -- and, conversely, not getting an error would qualify as a bug to me...


Would something like this help:


select jcf.molconvert ('junk', 'smiles', 'smiles', 'haltOnError:n') from dual;

?


This is also not exactly what you may be looking for, because this function will return NULL both for an invalid smiles and when, say, your system is trying to swap in from a defective disk sector causing some internal error even if a perfectly valid smiles is being tested.


If that is still not robust enough for your purposes (or even regardless whether robust enough or not), I will be glad to move this topic to the more approriate forum of Structure manipulation: Canonicalization / standardization .


BTW, whatever structure representation it is in, "junk" is recognized as (1S,5R,13R,14S,17R)-10-(acetyloxy)-4-methyl-12-oxa-4-azapentacyclo[9.6.1.0¹,¹³.0⁵,¹⁷.0⁷,¹⁸]octadeca-7,9,11(18),15-tetraen-14-yl acetate .


Peter

User 3afdb4ab90

11-11-2012 22:49:15

select jc_molconvert ('junk', 'smiles', 'smiles', 'haltOnError:n') from dual;


seems to do what I need.  It returns null, and returns non-null for valid smiles input.  It also reutrns null for the string 'bob the builder' as expected.


The lack of robustness (of isValid) that I reported was because of this:


select  jc_evaluate_x('xjunk', 'chemTerms:isValid("")') from dual;

which returned this:


ORA-29532: Java call terminated by uncaught Java exception: chemaxon.jchem.cartridge.oresident.nonidxscan.NonIdxScanException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: java.lang.Exception: Problem importing query structure: xjunk: chemaxon.formats.MolFormatException: Cannot create record reader for the "chime" format
ORA-06512: at "JCHEM.JCHEM_CLOB_PKG", line 34
ORA-06512: at "JCHEM.EXEC_FUNCV", line 44
ORA-06512: at "JCHEM.EVALUATEX_FUNC", line 7
29532. 00000 -  "Java call terminated by uncaught Java exception: %s"
*Cause:    A Java exception or error was signaled and could not be
           resolved by the Java code.
*Action:   Modify Java code, if this behavior is not intended.


I was also confused by your suggestion to try smiles..aromaticity..valence, as in this:


select  jc_evaluate_x('c1ccccc1', 'chemTerms:isValid("smiles..aromaticity..valence")') from dual;


when I did not see "smiles" listed as a possible option to isValid.  When I run that sql, I get this:


ORA-29532: Java call terminated by uncaught Java exception: chemaxon.jchem.cartridge.oresident.nonidxscan.NonIdxScanException: RemoteException occurred in server thread; nested exception is:
    java.rmi.RemoteException: chemaxon.nfunk.jep.ParseException: Error while evaluating expression:
isValid("smiles..aromaticity..valence")
    The provided checker configuration contains errors. The indexes of invalid checkers: 1-InvalidChecker .
ORA-06512: at "JCHEM.JCHEM_CLOB_PKG", line 34
ORA-06512: at "JCHEM.EXEC_FUNCV", line 44
ORA-06512: at "JCHEM.EVALUATEX_FUNC", line 7
29532. 00000 -  "Java call terminated by uncaught Java exception: %s"
*Cause:    A Java exception or error was signaled and could not be
           resolved by the Java code.
*Action:   Modify Java code, if this behavior is not intended.


 


Yet it works fine using this:


select  jc_evaluate_x('c1ccccc1', 'chemTerms:isValid("aromaticity..valence")') from dual;

ChemAxon 61b4fee994

12-11-2012 07:37:06

Hi,


You can use a PL/SQL block or function that handles the exception, like this:


create or replace function ISVALIDSMILES(MOLSTRING varchar2) return number is
str varchar2(4000);
begin
  begin
  STR:=SCRATCH.JCF.MOLCONVERT(MOLSTRING, 'smiles','smiles', null);
  return jcf.evaluate_x(MOLSTRING, 'chemTerms:isValid("aromaticity..valence")');
  exception
    when OTHERS then return 0;
  end;
END;
/


I know it is a bit more complicated, but you have to create it only once and at least it works.


Please note that you have to grant roles directly to the user if you haven't done that yet:


call privman_pkg.grants_on_jcobjs(<cartridge_owner>,<user>);


 


Tamas