Did you know ... Search Documentation:
Pack pubmed -- prolog/pubmed.pl
PublicShow source

A simple library for communicating with pubmed publications. Currently allows

  • (a) searching on conjunctions and disjunctions,
  • (b) fetching the details of a pubmed id(s)
  • (c) the publications citing a paper, and
  • (d) simple reporting of multiple fetched information.

It requires the curl executable to be in the path. Only tested on Linux. It is being developed on SWI-Prolog 6.1.8 but should also work on Yap Prolog.

author
- Nicos Angelopoulos
version
- 0.0.4, 2013/11/2
See also
- http://stoics.org.uk/~nicos/sware/pubmed
- http://www.ncbi.nlm.nih.gov/books/NBK25500/
- examples.pl file in the packs directory
- sources at http://stoics.org.uk/~nicos/sware/pubmed/pubmed-0.0.4.tgz @tbd this public version lags significantly behind my private sources. people interested in recent developments should feel free to email me.
 pubmed_version(+Version, +Date)
Get version information and date of publication.
 pubmed_search(+STerm, -Ids)
Short form of pubmed_search( +STerm, -Ids, [] ).
 pubmed_search(+STerm, -Ids, Options)
Search in pubmed for terms in the search term STerm. In this, conjunction is marked by , (comma) and disjunction by ; (semi-column). '-' pair terms are considered as Key-Value and interpreted as Value[Key] in the query. List are thought to be flat conjoint search terms with no pair values in them which are interpreted by pubmed also as OR operations. (See example below.) Known keys are : journal, pdat. au, All Fields The predicate constructs a query that is posted via the http API provided by NCBI (http://www.ncbi.nlm.nih.gov/books/NBK25500/). Options can be a single term or list of terms from :
  • retmax(RetMax) the maximum number of records that will be returned def: 100
  • verbose(Verbose) if Verbose == true then the predicate verbose
    about its progress by, for instance, requesting query is printed on current output stream.
  • tmp_file(Tmp) file to use, or when Tmp is variable the file that was used to receive the results from pubmed.
  • tmp_keep(Keep) keep the file with the xml result iff Keep==true
  • qtranslation(QTrans) return in QTrans the actual query ran on the the pubmed server. For instance, taking an example from the url we show how to find all breast cancer articles that were published in Science in 2008.
?-
    St = (journal=science,[breast,cancer],pdat=2008),
    pubmed_search( St, Ids, [verbose(true),qtranslation(QTrans)] ),
    length( Ids, Len ), write( number_of:Len ), nl.

http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax=100&term=science\[journal\]+AND+breast+cancer+AND+2008\[pdat\]
process_create(path(curl),[-o,/tmp/pl_13858_1,http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pubmed&retmax=100&term=science\[journal\]+AND+breast+cancer+AND+2008\[pdat\]],[])
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3008    0  3008    0     0   3585      0 --:--:-- --:--:-- --:--:--  4641
tmp_file(/tmp/pl_13858_1)
number_of:6
St = (journal=science, [breast, cancer], pdat=2008),
Ids = ['19008416', '18927361', '18787170', '18487186', '18239126', '18239125'],
QTrans = ['("Science"[Journal] OR "Science (80- )"[Journal] OR "J Zhejiang Univ Sci"[Journal]) AND ("breast neoplasms"[MeSH Terms] OR ("breast"[All Fields] AND "neoplasms"[All Fields]) OR "breast neoplasms"[All Fields] OR ("breast"[All Fields] AND "cancer"[All Fields]) OR "breast cancer"[All Fields]) AND 2008[pdat]'],
Len = 6.


?-
    date(Date), pubmed_search( prolog, Ids ), length( Ids, Len ), write( number_of:Len ), nl.

number_of:100
Date = date(2012, 7, 10),
Ids = ['22586414', '22462194', '22215819', '21980276', '21499053', '21353661', '20123506', '20123505', '19408879'|...],
Len = 100.

?-
    date(Date), pubmed_search( prolog, Ids, retmax(200) ),
    length( Ids, Len ), write( number_of:Len ), nl.

number_of:120
Date = date(2012, 7, 10),
Ids = ['22586414', '22462194', '22215819', '21980276', '21499053', '21353661', '20123506', '20123505', '19408879'|...],
Len = 120.
 pubmed_summary_display(+Ids)
Short for pubmed_summary_display( Ids, _Summary, [] ).
 pubmed_summary_display(+Ids, -Summary)
Short for pubmed_summary_display( Ids, Summary, [] ).
 pubmed_summary_display(+Ids, -Summary, +Opts)
A wrapper around pubmed_summary_info/3. It call this predicate with same arguments before displaying the Summary information. Opts can be a single term option or a list of such terms. In addition to pubmed_summary_info/3 options this wrapper also recognises the term :
  • display(Disp) A list of article information keys that will displayed one on a line for each Id in Ids.
?-
     date(Date), pubmed_search((programming,'Prolog'), Ids), Ids = [A,B,C|_], pubmed_summary_display( [A,B,C] ).

----
0:22215819
[Evaluating bacterial gene-finding HMM structures as probabilistic logic programs.]
[Mørk S,Holmes I]
----
1:21980276
[War of ontology worlds: mathematics, computer code, or Esperanto?]
[Rzhetsky A,Evans JA]
----
2:15360781
[Medical expert systems developed in j.MD, a Java based expert system shell: application in clinical laboratories.]
[Van Hoof V,Wormek A,Schleutermann S,Schumacher T,Lothaire O,Trendelenburg C]
----
Date = date(2012, 7, 10),
Ids = ['22215819', '21980276', '15360781', '11809317', '9783213', '9293715', '9390313', '8996790', '15048396'|...],
A = '22215819',
B = '21980276',
C = '15360781'.
?-
     pubmed_cited_by( 20195494, These ), pubmed_summary_display( These, _, [display(['Title','Author','PubDate'])] ).
 pubmed_cited_by(+Id, -Ids)
Redirects to pubmed_cited_by( Id, Ids, [] ).
 pubmed_cited_by(+Id, -Ids, +Options)
Ids is the list of pubmed ids that cite Id. Options is a term option or list of terms from the following;
  • verbose(Verb) be verbose
?-
     date(D), pubmed_cited_by( 12075665, By ).

D = date(2012, 7, 9),
By = ['19497389'].
 pubmed_cites(+Id, -Ids)
Redirects to pubmed_cites( Id, Ids, [] ).
 pubmed_cites(+Id, -Ids)
 pubmed_cites(+Id, -Ids, +Options)
Ids is the list of pubmed Ids that are cited by Id. Options is a term option or list of terms from the following;
  • verbose(Verb) be verbose
?-
     date(D), pubmed_cites( 20195494, Ids ), length( Ids, Len ), write( D:Len ), nl, fail.

date(2012,8,15):35
 pubmed_summary_info(+Id, -Results, +Opts)
Results are the summary information for pubmed id Id. The predicate communicates with pubmed via the http interface with curl. Results are deposited in xml files which are subsequently parsed to produce the termed Results. Id can also be a list of Ids in which case the result is a list of Id-Results pairs.

Options is a single term, or list of the following terms:

  • names(Names) list of names to be found in the xml file.
  • retmax(Retmax) the maximum number of records that will be returned def: 100
  • tmp_file(Tmp) temporary file to be used for saving xml files. If Tmp is a variable, or option is missing, a temporary file is created with tmp_file_stream/3.
  • tmp_keep(Keep) if true, keep the temporary xml file, otherwise, and by default, delete it.
  • verbose(Verb) When true be verbose.
?-
  date(Date),  Opts = names(['Author','PmcRefCount','Title']),
  pubmed_summary_info( 12075665, Results, Opts ),
  write( date:Date ), nl, member( R, Results ), write( R ), nl, fail.

date:date(2012,7,9)
Author-[Kemp GJ,Angelopoulos N,Gray PM]
Title-[Architecture of a mediator for a bioinformatics database federation.]
Source-[IEEE Trans Inf Technol Biomed]
Pages-[116-22]
PubDate-[2002 Jun]
Volume-[6]
Issue-[2]
ISSN-[1089-7771]
PmcRefCount-[1]
PubType-[Journal Article]
FullJournalName-[IEEE transactions on information technology in biomedicine : a publication of the IEEE Engineering in Medicine and Biology Society]
false.