3
$\begingroup$

Update 04 Sept 2020: The problem described below occurs in Mathematica 12.0. It has been fixed in Mathematica 12.1, so that ServiceExecute returns the correct response.

Consider the molecule defined by the following SMILES string:

example = "C(/C=C/Cl)Cl"

(the slashes indicate cis/trans isomerism). Molecule[] has no problem interpretting this correctly:

Molecule[example]

returned Molecule

And a manual call to PubChem via the PUG-REST API works fine too:

 URLBuild["https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/cids/txt",
  {"smiles" -> example}]  (* "24726" *)

BUT the PubChem Service seems to fail on this input, giving an error about being unable to standardize the given structure:

ServiceExecute["PubChem", "CompoundCID", {"SMILES" -> example}]

error from ServiceExecute

It's definitely an error with handling the isomeric specification, because removing the slashes that define the isomer allows ServiceExecute[] to return successfully:

ServiceExecute["PubChem", "CompoundCID", {"SMILES" -> "C(C=CCl)Cl"}]

returns {24883}

(albeit, this is a different molecule, and hence the wrong answer)

$\endgroup$
4
  • $\begingroup$ For these types of SMILES strings you have to supply the SMILES string in POST instead of in the URL. The code doesn't take that into account. $\endgroup$
    – Jason B.
    Dec 13, 2019 at 22:41
  • $\begingroup$ I see. So to confirm: the PubChem service execute in Mathematica only works for the subset of PubChem calls that use GET? (and does not switch to POST behind the scenes when necessary?) $\endgroup$ Dec 13, 2019 at 23:00
  • 3
    $\begingroup$ It does switch to POST but not for SMILES. I guess the SMILES strings they used to test it were lacking in double-bond stereochemistry. I will file a bug report for it $\endgroup$
    – Jason B.
    Dec 13, 2019 at 23:02
  • $\begingroup$ This same problem also extends to SMILES strings containing a triple bond ("#"); A minimum breaking example is acetylene "C#C" ; this might also be useful to include in future tests. $\endgroup$ Dec 15, 2019 at 20:08

1 Answer 1

1
$\begingroup$

The fix for this bug has been pushed via paclet update to older versions of Mathematica:

In[6]:= $Version

Out[6]= "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)"

In[7]:= Normal@
 ServiceExecute["PubChem", "CompoundCID", {"SMILES" -> "C(/C=C/Cl)Cl"}]

Out[7]= <|"CompoundID" -> {24726}|>
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.