changeset 221:317fe3126c6c

add database-admin function to create composition identifiers from file Ignore-this: ff758dc4be1061baebae471feee53f00 darcs-hash:20090820181949-16a00-389500f68b818adca481631fc7ae26be59a8ad4a.gz committer: Jamie Forth <j.forth@gold.ac.uk>
author j.forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents de60993404c1
children ead979ad3b28
files base/database/datasets-functions.lisp base/database/package.lisp
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/base/database/datasets-functions.lisp	Thu Feb 24 11:23:18 2011 +0000
+++ b/base/database/datasets-functions.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -64,6 +64,16 @@
 				       dataset-identifier
 				       database)))
 
+(defun make-composition-identifiers-from-file (package pathname)
+  "This reads a file that contains one id per line, and returns a list
+of composition-identifiers (specialised on package). It is useful for
+reading files that have been exported from the database, for use with
+the above functions."
+  (with-open-file (stream pathname :direction :input)
+    (loop for id = (read stream nil)
+       while id
+       collect (make-composition-identifier package id))))
+
 (defun get-dataset (dataset-identifier &optional (database
 						  *amuse-database*))
   (let ((dataset-header (clsql:query (format nil "
--- a/base/database/package.lisp	Thu Feb 24 11:23:18 2011 +0000
+++ b/base/database/package.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -7,6 +7,8 @@
 
 	   #:make-new-dataset		; datasets-functions
 	   #:assign-composition-to-dataset
+	   #:assign-compositions-to-dataset
+	   #:make-composition-identifiers-from-file
 	   #:get-dataset
  	   #:make-amuse-dataset-identifier