# pKa in Chemical Terms: equivalent to NaN or null?

User 870ab5b546

12-09-2007 17:35:15

Hi,

I have formulated this partial reactivity rule for SN2 substitutions:

 Code: match(ratom(1), "[H][C:1][H]", 1)         || (match(ratom(1), "[H][C:1]", 1) && pKa(ratom(2)) <= 14)

It works pretty well in many cases. However, when ratom(1) is Cl-, the substrate fails the reactivity rule. I think the reason is that Cl- returns "none" as the value for pKa(ratom(2)). Is there a way to test for this value?

On a similar topic, I assume that the Chemical Terms calculation uses the "static" model for pKa calculation? Can a parameter or a new method be introduced that would allow us to use the "dynamic" model?

-- Bob

ChemAxon e08c317633

14-09-2007 14:53:11

bobgr wrote:
I have formulated this partial reactivity rule for SN2 substitutions:

 Code: match(ratom(1), "[H][C:1][H]", 1)         || (match(ratom(1), "[H][C:1]", 1) && pKa(ratom(2)) <= 14)

It works pretty well in many cases. However, when ratom(1) is Cl-, the substrate fails the reactivity rule. I think the reason is that Cl- returns "none" as the value for pKa(ratom(2)). Is there a way to test for this value?
(I suppose you mean "when ratom(2) is Cl-, ...".)

I suggest you to use this (or a similar) Chemical Terms expression:

 Code: match(ratom(1), "[H][C:1][H]", 1)         || (match(ratom(1), "[H][C:1]", 1) && match(ratom(2), "[Cl-]"))          || (match(ratom(1), "[H][C:1]", 1) && pKa(ratom(2)) <= 14)

This expression is evaluated using lazy evaluation technique: if (match(ratom(1), "[H][C:1]", 1) && match(ratom(2), "[Cl-]")) subexpression returns true then the expression will return true and the 3rd part of it will not be evaluated.
 Quote: On a similar topic, I assume that the Chemical Terms calculation uses the "static" model for pKa calculation? Can a parameter or a new method be introduced that would allow us to use the "dynamic" model?
Yes, it can be done. See:

http://www.chemaxon.com/jchem/doc/user/Evaluator.html#config

http://www.chemaxon.com/jchem/doc/user/Evaluator.html#plugindef

http://www.chemaxon.com/jchem/doc/user/Evaluator.html#builtin

You have to add the lines below to the <Plugins> section of the built in evaluator.xml file, and copy the result file to the .chemaxon (UNIX / Linux) or chemaxon (Windows) subdirectory in your user's home directory.

 Code:

After these steps you can refer to this function as "dynamicpKa()" in a Chemical Terms expression.

Zsolt

User 870ab5b546

14-09-2007 15:19:38

Zsolt wrote:
You have to add the lines below to the <Plugins> section of the built in evaluator.xml file, and copy the result file to the .chemaxon (UNIX / Linux) or chemaxon (Windows) subdirectory in your user's home directory.

 Code:

After these steps you can refer to this function as "dynamicpKa()" in a Chemical Terms expression.
What do you mean by my user's home directory? Do you mean the same place where the licenses.dat file is kept? I see there is also a file called pKaPluginParameters.properties in that same directory.

Thanks for the tip on the Cl-. It will work, though I will have to list every example of a nucleophile that might not give a pKa value. Please put the NaN or null value on your list of suggestions for the next version of the Chemical Terms Language.

ChemAxon e08c317633

14-09-2007 15:38:13

 bobgr wrote: What do you mean by my user's home directory? Do you mean the same place where the licenses.dat file is kept? I see there is also a file called pKaPluginParameters.properties in that same directory.
Yes, I mean this directory.

Zsolt

User 870ab5b546

27-09-2007 19:38:00

Your tip worked for a while. Then we upgraded JChem, and now it's not working anymore. I checked that the evaluator.xml file in the Tomcat owner's .chemaxon directory still has the dynamicpKb method in it; it does. So why is JChem no longer getting information from this file?

Here is the code in evaluator.xml:

 Code:

ChemAxon e08c317633

28-09-2007 11:02:30

It should work.

Please run these two commands and post their output:

 Code: evaluate -e "pKa()" "CC(O)=O"

 Code: evaluate -e "dynamicpKa()" "CC(O)=O"

Regards,

Zsolt

User 870ab5b546

28-09-2007 14:05:56

 Code: [root@epoch root]# evaluate -e "pKa()" "CC(O)=O" ;;4.54; [root@epoch root]# evaluate -e "dynamicpKa()" "CC(O)=O" Exception in thread "main" chemaxon.nfunk.jep.ParseException: Error while evaluating expression: dynamicpKa()     null     Error while evaluating expression: dynamicpKa()     null         at chemaxon.jep.Evaluator.main(Evaluator.java:897) Caused by: ERRORS: Error 1: null Error 2:     null ------------------------------ TRACES: chemaxon.nfunk.jep.ParseException: Error while evaluating expression: dynamicpKa()     null         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:477)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 1: java.lang.NullPointerException         at chemaxon.jep.function.Plugin.getDoubleResult(Plugin.java:374)         at chemaxon.jep.function.Plugin.run(Plugin.java:339)         at chemaxon.nfunk.jep.EvaluatorVisitor.visit(EvaluatorVisitor.java:291)         at chemaxon.nfunk.jep.ASTFunNode.jjtAccept(ASTFunNode.java:60)         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:156)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 2: ERRORS: Error 1: null ------------------------------ TRACES: chemaxon.nfunk.jep.ParseException:     null         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:160)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 1: java.lang.NullPointerException         at chemaxon.jep.function.Plugin.getDoubleResult(Plugin.java:374)         at chemaxon.jep.function.Plugin.run(Plugin.java:339)         at chemaxon.nfunk.jep.EvaluatorVisitor.visit(EvaluatorVisitor.java:291)         at chemaxon.nfunk.jep.ASTFunNode.jjtAccept(ASTFunNode.java:60)         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:156)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) [root@epoch root]#

BTW, I already tried stopping and restarting Tomcat. No joy.

ChemAxon e08c317633

01-10-2007 08:29:25

Please modify the following line of the \${HOME}/.chemaxon/evaluator.xml file (HOME refers to the home directory of the user, who is running Tomcat):

 Code:

to this:

 Code:

After the modification

 Code: evaluate -e "pKa()" "CC(O)=O"

should throw an exception, and

 Code: evaluate -e "pKa111()" "CC(O)=O"

should work.

 Code: evaluate -e "pKa111()" "CC(O)=O" ;;4.54;

If it works like this, then please send me your evaluator.xml file.

Zsolt

User 870ab5b546

01-10-2007 12:13:20

The behavior was as you described.

I am attaching evaluator.xml.

One note: I have .chemaxon/evaluator.xml also in my own home directory. After I changed the one in root, the Tomcat owner, when I exited root and became myself again, pKa111 was not recognized. But when I changed my own evaluator.xml file from pKa to pKa111, then pKa111 was recognized properly.

Anyway, it appears that Tomcat is no longer recognizing the evaluator.xml file in root.

ChemAxon e08c317633

02-10-2007 15:03:58

 bobgr wrote: The behavior was as you described. I am attaching evaluator.xml. ... Anyway, it appears that Tomcat is no longer recognizing the evaluator.xml file in root.

Does "pKa111()" work when you run it as root user or not (after it was changed from "pKa" to "pKa111")?
 Quote: One note: I have .chemaxon/evaluator.xml also in my own home directory. After I changed the one in root, the Tomcat owner, when I exited root and became myself again, pKa111 was not recognized. But when I changed my own evaluator.xml file from pKa to pKa111, then pKa111 was recognized properly.
Does

 Code: evaluate -e "dynamicpKa()" "CC(O)=O"

work for you (if you run it as normal user, not root) after the upgrade?

What OS do you use?

Zsolt

User 870ab5b546

02-10-2007 15:16:07

 Zsolt wrote: Bob, I don't understand your answer. Does "pKa111()" work when you run it as root user or not (after it was changed from "pKa" to "pKa111")?
Yes, it does, and pKa() fails. Then, when I change it back, pKa() works, and pKa111() fails, as expected. So it appears that only dynamicpKb() and dynamicpKa() do not work as expected.
Quote:
Does

 Code: evaluate -e "dynamicpKa()" "CC(O)=O"

work for you (if you run it as normal user, not root) after the upgrade?
No, it does not work, neither as normal user nor as root (both of whom have a .chemaxon/evaluator.xml file in their home directories, both containing the appropriate definition). Here's the trace:

 Code: Exception in thread "main" chemaxon.nfunk.jep.ParseException: Error while evaluating expression: dynamicpKa()     null     Error while evaluating expression: dynamicpKa()     null         at chemaxon.jep.Evaluator.main(Evaluator.java:897) Caused by: ERRORS: Error 1: null Error 2:     null ------------------------------ TRACES: chemaxon.nfunk.jep.ParseException: Error while evaluating expression: dynamicpKa()     null         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:477)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 1: java.lang.NullPointerException         at chemaxon.jep.function.Plugin.getDoubleResult(Plugin.java:374)         at chemaxon.jep.function.Plugin.run(Plugin.java:339)         at chemaxon.nfunk.jep.EvaluatorVisitor.visit(EvaluatorVisitor.java:291)         at chemaxon.nfunk.jep.ASTFunNode.jjtAccept(ASTFunNode.java:60)         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:156)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 2: ERRORS: Error 1: null ------------------------------ TRACES: chemaxon.nfunk.jep.ParseException:     null         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:160)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 1: java.lang.NullPointerException         at chemaxon.jep.function.Plugin.getDoubleResult(Plugin.java:374)         at chemaxon.jep.function.Plugin.run(Plugin.java:339)         at chemaxon.nfunk.jep.EvaluatorVisitor.visit(EvaluatorVisitor.java:291)         at chemaxon.nfunk.jep.ASTFunNode.jjtAccept(ASTFunNode.java:60)         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:156)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868)

And again, here's the definition of the function:

 Code:
 Quote: What OS do you use?
Linux.

Zsolt

ChemAxon e08c317633

09-10-2007 10:18:09

bobgr wrote:

 Code: Exception in thread "main" chemaxon.nfunk.jep.ParseException: Error while evaluating expression: dynamicpKa()     null     Error while evaluating expression: dynamicpKa()     null         at chemaxon.jep.Evaluator.main(Evaluator.java:897) Caused by: ERRORS: Error 1: null Error 2:     null ------------------------------ TRACES: chemaxon.nfunk.jep.ParseException: Error while evaluating expression: dynamicpKa()     null         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:477)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 1: java.lang.NullPointerException         at chemaxon.jep.function.Plugin.getDoubleResult(Plugin.java:374)         at chemaxon.jep.function.Plugin.run(Plugin.java:339)         at chemaxon.nfunk.jep.EvaluatorVisitor.visit(EvaluatorVisitor.java:291)         at chemaxon.nfunk.jep.ASTFunNode.jjtAccept(ASTFunNode.java:60)         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:156)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 2: ERRORS: Error 1: null ------------------------------ TRACES: chemaxon.nfunk.jep.ParseException:     null         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:160)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868) Error 1: java.lang.NullPointerException         at chemaxon.jep.function.Plugin.getDoubleResult(Plugin.java:374)         at chemaxon.jep.function.Plugin.run(Plugin.java:339)         at chemaxon.nfunk.jep.EvaluatorVisitor.visit(EvaluatorVisitor.java:291)         at chemaxon.nfunk.jep.ASTFunNode.jjtAccept(ASTFunNode.java:60)         at chemaxon.nfunk.jep.EvaluatorVisitor.getValue(EvaluatorVisitor.java:156)         at chemaxon.nfunk.jep.JEP.getValueAsObject(JEP.java:470)         at chemaxon.jep.ChemJEP.evaluate(ChemJEP.java:150)         at chemaxon.jep.Evaluator.main(Evaluator.java:868)

Hi Bob,

We have fixed this error. The fix will be available in JChem 3.2.12 version.

Zsolt

User 870ab5b546

09-10-2007 12:45:13

Köszönöm, and glad to hear I wasn't just doing something wrong.

User 870ab5b546

15-02-2008 16:26:47

Zsolt wrote:
bobgr wrote:
I have formulated this partial reactivity rule for SN2 substitutions:

 Code: match(ratom(1), "[H][C:1][H]", 1)         || (match(ratom(1), "[H][C:1]", 1) && pKa(ratom(2)) <= 14)

It works pretty well in many cases. However, when ratom(2) is Cl-, the substrate fails the reactivity rule. I think the reason is that Cl- returns "none" as the value for pKa(ratom(2)). Is there a way to test for this value?
I suggest you to use this (or a similar) Chemical Terms expression:

 Code: match(ratom(1), "[H][C:1][H]", 1)         || (match(ratom(1), "[H][C:1]", 1) && match(ratom(2), "[Cl-]"))          || (match(ratom(1), "[H][C:1]", 1) && pKa(ratom(2)) <= 14)

This expression is evaluated using lazy evaluation technique: if (match(ratom(1), "[H][C:1]", 1) && match(ratom(2), "[Cl-]")) subexpression returns true then the expression will return true and the 3rd part of it will not be evaluated.

Zsolt
I'm coming up against a similar problem again. For the following reaction:

 Code:                                                                                   0.0001                           37]]>                           true

CCCBr as the substrate gives CC[CH-]Br. Interestingly, this seemingly identical substrate:

 Code:

gives [CH2-]CCBr. (The only difference is that Br is attached to C3 in the first compound and C1 in the second.) The exclude rule should exclude either product, but because the pKa plugin does not return any values for the pKas of hydrocarbon C atoms, Reactor arrives at the end of its calculations having failed to find an acidic atom, so it just deprotonates the last atom it saw.

I cannot exclude C atoms for which the pKa plugin returns no value unless I can test for "no value". I also cannot prevent substrates with no acidic atoms from being submitted. I need Reactor to understand that if there is a pKa selectivity rule for an atom, that any atom that fails to return a pKa cannot participate in the reaction. Alternatively, I need the pKa plugin to return values for all atoms that are submitted, even if they are estimated rather than calculated values.

We are using JChem 3.2.12.

ChemAxon e08c317633

18-02-2008 10:20:27

 bobgr wrote: I cannot exclude C atoms for which the pKa plugin returns no value unless I can test for "no value". I also cannot prevent substrates with no acidic atoms from being submitted. I need Reactor to understand that if there is a pKa selectivity rule for an atom, that any atom that fails to return a pKa cannot participate in the reaction. Alternatively, I need the pKa plugin to return values for all atoms that are submitted, even if they are estimated rather than calculated values.
Bob, to make Reactor understand that "any atom that fails to return a pKa cannot participate in the reaction" use a reactivity rule. This reactivity rule will do the job:

 Code: (pKa(ratom(1), "acidic") >= 0) || (pKa(ratom(1), "acidic") < 0)

Regards,

Zsolt

User 870ab5b546

18-02-2008 13:58:35

Ahhh... Very clever workaround. May I suggest that you add this problem and its solution to the documentation? Neither the existence of the problem nor the solution is at all obvious.

Köszönöm.

ChemAxon d76e6e95eb

18-02-2008 14:48:36

If reactive sites are identified by the scheme and the reactivity rule, all isomeric products are be generated.

If a selectivity rule is given, it just prioritizes the reactive sites, some products are generated (the main products).

At least Reactor should work accordingly.

User 870ab5b546

28-02-2008 19:15:38

 Gyuri wrote: If reactive sites are identified by the scheme and the reactivity rule, all isomeric products are be generated. If a selectivity rule is given, it just prioritizes the reactive sites, some products are generated (the main products). At least Reactor should work accordingly.
The selectivity rule is,

 Code: -pKa(ratom(1), "acidic"); match(ratom(1), "[C:1]#[C]", 1); match(ratom(1), "[C:1]P(c)(c)c", 1); match(ratom(1), "[C:1][P]=O", 1)

According to this rule, the most acidic atom should be deprotonated. However, if Reactor is unable to find an acidic atom, it's just deprotonating the last atom it finds. That's not how it should behave; if it is unable to find an acidic atom, it should not return any products at all.

Zsolt's workaround works well, but it's still a workaround. The real problem is that the pKa plugin is still not returning pKa values for hydrocarbons, even very acidic ones such as CC#C, let alone poor acids such as CC=C and CCC. It should return a value for every atom that bears an H, because every atom that bears an H is a potential acid. I'm not suggesting you calculate every single value; for extremely weak acids, you can just provide a number estimated from experimental values; the calculations probably aren't worth much anyway in these extreme cases.

You might be interested to see how complex the rules have to become to account for this deficiency. Consider the following rule, which is simply to deprotonate the most acidic site of a compound with LDA:

 Code:                                                                                   0.0001                           37 || (!(pKa(ratom(1), "acidic") >= 0 || pKa(ratom(1), "acidic") < 0) && !match(ratom(1), "[C:1]#[C]", 1) && !match(ratom(1), "[C:1]P(c)(c)c", 1) && !match(ratom(1), "[C:1][P]=O", 1))]]>                           true

Because the pKa plugin doesn't recognize terminal alkynes, phosphonium ions, or phosphonates as acids, my selectivity rule needs to be, "Deprotonate the most acidic atom; failing that, a terminal alkyne; failing that, a phosphonium ion; failing that, a phosphonate." (Note this rule may return invalid products if, e.g., there are two alkynes of different acidities, as in C#Cc1ccccc1CC#C.) Then the exclude rule needs to be, "Don't deprotonate an anion, an atom with pKa > 37, or an atom that doesn't return a pKa (unless it is a terminal alkyne or a phosphonium ion or a phosphonate)." So I need to repeat part of the selectivity rule in the exclude rule. Awkward!

ChemAxon d76e6e95eb

01-03-2008 08:35:51

Bob, the pKa plugin calculates some acidic hydrocarbons, like the ones connected to carbonyls, but not all. I agree, that acetylenes should be included, maybe more, but we need to clarify the reasons of this limitation in the scope of a discussion with the developers first and consider enhancements. We will get back to you soon after.

User 870ab5b546

01-03-2008 22:35:23

Thank you for looking into this problem.

ChemAxon d76e6e95eb

04-03-2008 12:29:07

The pKa tool will consider all CH features. The tests are running currently, and if the modified algorithm performs well we try to make it available for you asap, hopefully in 5.0.2.

User 870ab5b546

04-03-2008 12:46:07

Thank you for making this enhancement. It will solve many problems for us.

User 870ab5b546

05-04-2008 18:45:08

Hello, I used MarvinSketch 5.0.2.1 to calculate the pKa values of propyne. Happily, pKa values are given for both H-bearing C atoms. Less happily, the values are significantly larger than they ought to be. The pKa of C(1) should be about 25, not 35.2, and the pKa of C(3) should be about 37, not 44.6. I am less concerned about the latter value than I am about the former one. So we have progress, but there are still tasks ahead.

Also, I tried to calculate the pKa values of propynyl anion in dynamic mode, and I was told that no ionizable atoms were found. The plugin should return a pKb value of about 25.

ChemAxon 2136dd2f4b

14-04-2008 20:49:38

Hi,

 Quote: ...pKa values of propynyl anion in dynamic mode, and I was told that no ionizable atoms were found. The plugin should return a pKb value of about 25.
Ok. I fixed this bug in the pKa calculator. The new version of the pKa calculator will be released this week.

Jozsi

User 870ab5b546

22-04-2008 00:48:56

Thank you. And what about the too-large values for the pKa of C(sp)-H and propargylic H?

User 851ac690a0

05-05-2008 15:47:18

Hi,

 Quote: And what about the too-large values for the pKa of C(sp)-H and propargylic H?

Temporarly I postponed the pKa development. I will continiue later.

Jozsi

User 870ab5b546

05-05-2008 16:37:56

I'm sorry to hear that. Do you know how long the delay will endure? (Weeks, months...?)

User 851ac690a0

14-05-2008 06:55:58

Hi,

I think I will fix your pKa problem in this month.

Jozsi

User 870ab5b546

14-05-2008 13:51:23

That'll be great, köszönöm.