For a number of years I have been compiling a comprehensive bibliography of works that include mention of fishes of the family Scorpaenidae. Consequently, I am always on the lookout for datasets that can be mined for this purpose.
Recently, I learned that I could use this method to automatically search the PubMed database:
pubmed = ServiceConnect["PubMed"]
scorpaenidaeSearch = pubmed["PublicationSearch", "Query" -> "Scorpaenidae",
MaxItems -> 1000, "Elements" -> "FullData"]
I am able to get much of the pertinent data directly (although it only seems to return recent publications). From this I can obtain a lists of the UID's or the located publications by using the following commands.
scorpSearch = Values[Normal[scorpaenidaeSearch]]
scorpSearch[[All, 1]]
However, the "FullData" parameter does not return the publication abstract. For an individual UID I can obtain the corresponding Abstract using
pubmed["PublicationAbstract", "ID" -> "37344374"]
However, I can't figure out the syntax to generate the abstracts from a list of UID's, without violating the NCBI limit of requesting not more than one request every 3 seconds.
How can I place Pause[5] into the following mapping to generate abstracts for the list of UID's obtained using the UID's returned via the following command?
abstracts =
pubmed["PublicationAbstract", "ID" -> #] & /@ scorpSearch[[All, 1]]
I've tried to construct a Do loop for this purpose, but can not construct an appropriate syntax for the mapping. Without a pause, the mapping violates the rate limit on the service and the request is denied. The following does not work.
abstracts =
Do[Pause[5]; pubmed["PublicationAbstract", "ID" -> String[#]] &, 125] /@
scorpSearch[[All, 1]]
(125 records are returned for this particular search)
Nor does:
abstracts = (pubmed["PublicationAbstract", "ID" -> ToString[#]] &;
Pause[5]) /@ scorpSearch[[All, 1]]

s = OpenWrite["testfile"]; Write[s, abstracts]to create a file without any error messages (version 13.3.0 for Linux x86). Try puttingClose[streamin a separate cell after executingWrite[stream,abstracts]- if that does not work you might consider posting the issue as a new question. – kglr Jul 12 '23 at 16:56