cl-pubmed-2.1.3/ 0000755 0001750 0001750 00000000000 10040273144 013632 5 ustar kevin kevin 0000000 0000000 cl-pubmed-2.1.3/package.lisp 0000644 0001750 0001750 00000003017 10037540734 016127 0 ustar kevin kevin 0000000 0000000 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name: package.lisp
;;;; Purpose: Package file for cl-pubmed
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Jun 2001
;;;;
;;;; $Id: package.lisp 9010 2004-04-15 06:47:23Z kevin $
;;;;
;;;; This file, part of cl-pubmed, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;; cl-pubmed users are granted the rights to distribute and use this software
;;;; as governed by the terms of the GNU Lesser General Public License
;;;; (http://www.gnu.org/licenses/lgpl.html)
;;;; *************************************************************************
(in-package #:cl-user)
(defpackage #:pubmed
(:use #:common-lisp #:kmrcl)
(:export
;; Conditions
#:pubmed-condition
#:pubmed-query-error
#:pubmed-server-error
#:pubmed-condition-response
;; Query functions
#:pm-query
#:pm-fetch-ids
;; Print functions
#:print-article
#:print-article-set
; Classes
#:pm-article
#:pm-article-set
;; pm-article-set accessors
#:articles
#:articles-query
#:articles-total
#:articles-count
#:articles-start
;; article accessors
#:article-pmid
#:article-title
#:article-authors
#:article-affiliation
#:article-journal
#:article-date
#:article-volume
#:article-issue
#:article-pages
#:article-abstract
#:article-mesh-headings
;; proxy setting
#:*proxy-host*
))
cl-pubmed-2.1.3/pubmed-src.lisp 0000644 0001750 0001750 00000032170 10040273135 016567 0 ustar kevin kevin 0000000 0000000 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
;;;; *************************************************************************
;;;; FILE IDENTIFICATION
;;;;
;;;; Name: pubmed-src.lisp
;;;; Purpose: Library to access PubMed web application
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Jun 2001
;;;;
;;;; $Id: pubmed-src.lisp 9043 2004-04-17 18:24:17Z kevin $
;;;;
;;;; This file, part of cl-pubmed, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;; cl-pubmed users are granted the rights to distribute and use this software
;;;; as governed by the terms of the GNU Lesser General Public License
;;;; (http://www.gnu.org/licenses/lgpl.html)
;;;; *************************************************************************
(in-package #:pubmed)
(defparameter +pubmed-host+ "www.ncbi.nlm.nih.gov")
(defparameter +pubmed-query-url+ "/entrez/utils/pmqty.fcgi")
(defparameter +pubmed-fetch-url+ "/entrez/utils/pmfetch.fcgi")
(defparameter *proxy-host* nil)
(define-condition pubmed-condition ()
())
(define-condition pubmed-server-error (error pubmed-condition)
((response :initarg :response
:initform nil
:reader pubmed-condition-response))
(:report (lambda (c stream)
(format stream "A PubMed server error occurred.")
(awhen (pubmed-condition-response c)
(format stream " The server response was:~&~S" it)))))
(define-condition pubmed-query-error (error pubmed-condition)
((response :initarg :response
:initform nil
:reader pubmed-condition-response))
(:report (lambda (c stream)
(format stream "A PubMed server error occurred.")
(awhen (pubmed-condition-response c)
(format stream " The server response was:~&~S" it)))))
;;; Article-Set and Article Classes
(defclass pm-article-set ()
((query :type string :initarg :query :accessor articles-query)
(articles :type list :initarg :articles :accessor articles)
(total :type fixnum :initarg :total :accessor articles-total)
(count :type fixnum :initarg :count :accessor articles-count)
(start :type fixnum :initarg :start :accessor articles-start))
(:documentation "Pubmed Article Set Class")
(:default-initargs :total 0 :start 0 :count 0
:query nil :articles nil))
(defclass pm-article ()
(
(pmid :type integer :accessor article-pmid)
(title :type string :accessor article-title)
(authors :type list :accessor article-authors)
(affiliation :type string :accessor article-affiliation)
(journal :type string :accessor article-journal)
(date :type string :accessor article-date)
(volume :type string :accessor article-volume)
(issue :type string :accessor article-issue)
(pages :type string :accessor article-pages)
(abstract :type string :accessor article-abstract)
(mesh-headings :type list :accessor article-mesh-headings))
(:documentation "Pubmed Article Class"))
(defmethod print-object ((obj pm-article-set) (s stream))
(print-unreadable-object (obj s :type t :identity t)
(format s "~d total articles, ~d articles starting at #~d"
(articles-total obj)
(articles-count obj)
(articles-start obj)
)))
(defmethod print-object ((obj pm-article) (s stream))
(print-unreadable-object (obj s :type t :identity t)
(format s "pmid:~d, title:~S" (article-pmid obj)
(article-title obj))))
(defun article-equal-p (a b)
(check-type a pm-article)
(check-type b pm-article)
(eql (article-pmid a) (article-pmid b)))
(defun article-ref (art)
"Return a string of publication data for an article"
(let ((ref ""))
(awhen (article-date art)
(string-append ref (format nil "~a; " it)))
(awhen (article-volume art)
(string-append ref it))
(awhen (article-issue art)
(string-append ref (format nil "(~a)" it)))
(awhen (article-pages art)
(string-append ref (format nil ":~a" it)))
ref))
(defmethod print-article-set ((artset pm-article-set)
&key (os *standard-output*) (format :text)
(complete nil) (print-link nil))
"Display an article set to specified stream in specified format"
(dotimes (i (articles-count artset) artset)
(if (nth i (articles artset))
(print-article (nth i (articles artset)) :os os :format format
:complete complete :print-link print-link)
(princ "NULL Article" os))))
(defmethod print-article ((art pm-article) &key (os *standard-output*)
(format :text) (complete nil) (print-link nil))
"Display an article"
(ecase format
(:text
(format os "~a~%~a~%~a~a ~a~%~a~%"
(article-title art)
(list-to-delimited-string (article-authors art) ", ")
(aif (article-affiliation art)
(format nil "~a~%" it) "")
(article-journal art) (article-ref art)
(aif (article-abstract art)
(if complete
it
"Abstract available")
"No abstract available")
(when complete
(format os "~a~%" (article-mesh-headings art)))))
(:html
(let ((has-link (or (article-abstract art) (article-mesh-headings art))))
(when (and print-link has-link)
(format os "" (funcall print-link
(article-pmid art))))
(format os "