diff options
Diffstat (limited to 'gn/data/dataset.scm')
| -rw-r--r-- | gn/data/dataset.scm | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gn/data/dataset.scm b/gn/data/dataset.scm index c21a663..f099171 100644 --- a/gn/data/dataset.scm +++ b/gn/data/dataset.scm @@ -7,15 +7,18 @@ #:use-module (srfi srfi-1) #:use-module (dbi dbi) #:use-module (gn db mysql) + #:use-module (gn data genotype) #:use-module (gn data group) #:use-module (gn util convert) #:use-module (web gn-uri) + #:use-module (rnrs base) ; for assert #:export ( dataset-name get-bxd-publish-list get-bxd-publish-values-list get-bxd-publish-name-value-dict + write-pheno-file )) (define (get-dataset db probesetfreeze-id) @@ -68,3 +71,28 @@ `(,(assoc-ref r "Name") . ,(assoc-ref r "value")) ) '()))) ))))) + + +(define (write-pheno-file fn traits) + (define bxd-inds (geno-inds-bxd (pk "BXD.json"))) + (assert (= 235 (length bxd-inds))) + (display bxd-inds) + (call-with-output-file fn + (lambda (port) + (for-each + (lambda (ind) + (begin + (let* [(value (assoc-ref traits ind)) + (outvalue (if value + value + "NA"))] + (if value + (begin + (format #t "~s ~s" ind outvalue) + (newline))) + (display outvalue port) + (newline port)))) + bxd-inds) + (close port) + )) +) |
