Message Boards Message Boards

0
|
9006 Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Backslash problem in PubMed search from Mathematica 10.0.2

Posted 10 years ago

Hello,

I used following code to estimate PubMed hit of certain combination of words.

pubMedHit[str_] := Module[{},
  str3 = StringReplace[str, " " -> "+"];
  str2 = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%22" <> str3 <> "%22";
  imp = Import[str2, "XML"];
  count = Cases[imp, XMLElement["Count", _, _], 3];
  count[[All, -1]][[1, 1]] // ToExpression
  ]

This worked fine until I upgrade Mathematica to 10.0.2. Now the code suddenly stop working. It seems backslash is automatically inserted after certain character in str2 (between "&" and "term") in newer version. Is there any way to avoid this?

Takashi Miura.

POSTED BY: Miura Takashi
5 Replies

I hit on the same problem nine years later, and now I got the following working code now. (version 13.2).

pubMedHit[str_] := Module[{str2},
  str2 = 
   "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=\
pubmed&term=Lung+Branching+" <> str;
  str3 = URLEncode[str2];
  imp = Import[str2, "text"];
  imp2 = 
   StringCases[imp, Shortest["<Count>" ~~ X__ ~~ "</Count>"] :> X];
  imp3 = First[imp2];
  ToExpression[imp3]
  ]
POSTED BY: Miura Takashi

Hello,

The code worked. Thank you very much!

I received an e-mail from Wolfram tech support that it is due to Mathematica 10 being unable to import an XML files on a Mac operating System.

POSTED BY: Miura Takashi

Hello,

Thank you for the reply. I think I upgrade 10.0.2 from 10.0.0. directly. Unfortunately I do not have a machine which runs version 10.0.0., so attached is 9.0 version.

This is older version:

Search

$Version

"9.0 for Mac OS X x86 (64-bit) (December 12, 2012)"

pubMedHit[str_] := Module[{},
  str3 = StringReplace[str, " " -> "+"];
  str2 = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&\
term=%22" <> str3 <> "%22";
  imp = Import[str2, "XML"];
  count = Cases[imp, XMLElement["Count", _, _], 3];
  count[[All, -1]][[1, 1]] // ToExpression
  ]


pubMedHit["Sternum"]

10735

This is newer version:

$Version

"10.0 for Mac OS X x86 (64-bit) (December 4, 2014)"

pubMedHit[str_] := Module[{},
  str3 = StringReplace[str, " " -> "+"];
  str2 = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&\
term=%22" <> str3 <> "%22";
  imp = Import[str2, "XML"];
  count = Cases[imp, XMLElement["Count", _, _], 3];
  count[[All, -1]][[1, 1]] // ToExpression
  ]


pubMedHit["Sternum"]

$Failed
POSTED BY: Miura Takashi

Hi,

try this:

$Version

ClearAll[pubMedHit]
pubMedHit[str_String]:=Module[{str2,str3,imp},
str3=StringReplace[str," "->"+"];
str2="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&term=%22"<>str3<>"%22";
imp=Import[str2];
imp=StringCases[imp,Shortest["<Count>"~~X__~~"</Count>"]:>X];
imp=Last[imp];
ToExpression[imp]
]


pubMedHit["Sternum"]
POSTED BY: Sander Huisman

My quick test with 10.0.1 and 10.0.2 gave the same warning messages.

Please send a working notebook (<= 10.0.1), with all needed inputs and outputs to show how the code should work, and a 10.0.2 notebook with identical inputs showing the warning/error messages. Include

$Version

and its output in both notebook files.

If you can ZIP the notebook files together, use http://www.wolfram.com/support/contact/email/?topic=Technical ;
otherwise send regular email to support@wolfram.com and attach the notebooks.

Please mention this Community discussion (http://community.wolfram.com/groups/-/m/t/418083) in the body/comments of the email.

POSTED BY: Bruce Miller
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract