about summary refs log tree commit diff
path: root/examples/dataset-metadata-git.scm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/dataset-metadata-git.scm')
-rwxr-xr-xexamples/dataset-metadata-git.scm94
1 files changed, 0 insertions, 94 deletions
diff --git a/examples/dataset-metadata-git.scm b/examples/dataset-metadata-git.scm
deleted file mode 100755
index c9ea59b..0000000
--- a/examples/dataset-metadata-git.scm
+++ /dev/null
@@ -1,94 +0,0 @@
-#! /usr/bin/env guile
-
-!#
-(use-modules
- (ice-9 getopt-long)
- (srfi srfi-26)
- ((ice-9 regex) #:select (regexp-substitute/global))
- ((transform strings) #:select (string-blank? string-capitalize-first))
- ((transform sql) #:select (call-with-target-database sql-for-each)))
-
-(define (save-file file result)
-  (when result
-    (let ((dir-name (dirname file)))
-      (unless (file-exists? dir-name)
-        (mkdir dir-name))
-      (with-output-to-file file
-        (lambda ()
-          (format #t "~a" result))))))
-
-(define (infopages/sql->rtf result)
-  (let* ((get (cut assoc-ref result <>))
-         (get* (compose (lambda (str)
-                          (if (or (string-blank? str)
-                                  (string-ci=?
-                                   (string-trim-both str) "None"))
-                              #f
-                              str))
-                        get))
-         (identifier
-          (string-capitalize-first
-           (regexp-substitute/global
-            #f "[^A-Za-z0-9:]"
-            (get "InfoPageName")
-            'pre "_" 'post)))
-         (dir-name "/export/data/genenetwork/gn-docs/general/datasets/")
-         (file-name (cut string-append dir-name <>))
-         (summary (get* "Summary"))
-         (tissue (get* "AboutTissue"))
-         (specifics (get* "Specifics"))
-         (contributors (get* "Contributors"))
-         (cases (get* "AboutCases"))
-         (platform (get* "AboutPlatform"))
-         (processing (get* "AboutDataProcessing"))
-         (notes (get* "Notes"))
-         (citation (get* "Citation"))
-         (experiment-type (get* "Experiment_Type"))
-         (experiment-design (get* "ExperimentDesign"))
-         (acknowledgment (get* "Acknowledgment")))
-    (for-each (lambda (x)
-                (save-file
-                 (string-append (file-name identifier)
-                                "/"
-                                (car x))
-                 (cdr x)))
-              `(("summary.rtf" . ,summary)
-                ("tissue.rtf" . ,tissue)
-                ("citation.rtf" . ,citation)
-                ("specifics.rtf" . ,specifics)
-                ("cases.rtf" . ,cases)
-                ("platform.rtf" . ,platform)
-                ("processing.rtf" . ,processing)
-                ("notes.rtf" . ,notes)
-                ("experiment-design.rtf" . ,experiment-design)
-                ("experiment-type.rtf" . ,experiment-type)
-                ("contributors.rtf" . ,contributors)
-                ("acknowledgment.rtf" . ,acknowledgment)))))
-
-
-(let* ((option-spec
-        '((settings (single-char #\s) (value #t))))
-       (options (getopt-long (command-line) option-spec))
-       (settings (option-ref options 'settings #f))
-       (query "SELECT InfoPageName, Datasets.Summary, Datasets.AboutTissue, InfoFiles.Specifics,
-Datasets.AboutCases, Datasets.AboutPlatform, Datasets.AboutDataProcessing, InfoFiles.Experiment_Type,
-Datasets.Notes, Datasets.ExperimentDesign, Datasets.Acknowledgment, Datasets.Contributors, Datasets.Citation
-FROM InfoFiles LEFT JOIN Datasets USING (DatasetId)")
-       (%connection-settings
-        (call-with-input-file settings
-          read)))
-  (call-with-target-database
-   %connection-settings
-   (lambda (db)
-     (let ((dir "/export/data/genenetwork/gn-docs/"))
-       (chdir dir)
-       (system "git reset --hard origin")
-       (system "git pull")
-       ;; Clear directory so that we can re-do the dump again from the db.
-       (system "rm -rf general/datasets/*/")
-       (sql-for-each infopages/sql->rtf
-                     db
-                     query)
-       (system "git add general/datasets")
-       (system (format #f "git commit -m ~s" "Update dataset RTF Files."))
-       (system "git push origin master")))))