A simple library for communicating with pubmed publications. Currently allows
id(s)
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.
pubmed_search( +STerm, -Ids, [] )
.Search in pubmed for terms in the search termSTerm
. 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: 100verbose(Verbose)
if Verbose == true
then the predicate verbose
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, _Summary, [] ).
pubmed_summary_display( Ids, Summary, [] ).
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, [] )
.verbose(Verb)
be verbose?- date(D), pubmed_cited_by( 12075665, By ). D = date(2012, 7, 9), By = ['19497389'].
pubmed_cites( Id, Ids, [] )
.verbose(Verb)
be verbose?- date(D), pubmed_cites( 20195494, Ids ), length( Ids, Len ), write( D:Len ), nl, fail. date(2012,8,15):35
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: 100tmp_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.