diff options
Diffstat (limited to 'gn')
| -rw-r--r-- | gn/data/dataset.scm | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/gn/data/dataset.scm b/gn/data/dataset.scm index 6b2292a..c21a663 100644 --- a/gn/data/dataset.scm +++ b/gn/data/dataset.scm @@ -15,6 +15,7 @@ dataset-name get-bxd-publish-list get-bxd-publish-values-list + get-bxd-publish-name-value-dict )) (define (get-dataset db probesetfreeze-id) @@ -34,6 +35,7 @@ (get-rows db '()))))) (define* (get-bxd-publish-values-list dataid #:key used-for-mapping?) + "Returns dict of name values , e.g. [{\"Name\":\"C57BL/6J\",\"value\":9.136},{\"Name\":\"DBA/2J\",\"value\":4.401},{\"Name\":\"BXD9\",\"value\":4.36}, ... used-for-mapping? skips the founders and maybe other unmappable inds. Note, currently unused." (call-with-db (lambda (db) (let [(query (string-append "SELECT Strain.Name, PublishData.value FROM Strain, PublishData WHERE PublishData.Id=" dataid " and Strain.Id=StrainID;"))] @@ -48,5 +50,21 @@ (get-rows db '()) ))))) - -;; (define ids (db-get-rows-apply db (lambda (r) `(,(assoc-ref r \"StrainId\") . ,(assoc-ref r \"Name\"))) '())) +(define* (get-bxd-publish-name-value-dict dataid #:key used-for-mapping?) + "Returns dict of name values, e.g. (((\"C57BL/6J\" . 9.136) (\"DBA/2J\" . 4.401) (\"BXD9\" . 4.36) ... used-for-mapping? skips the founders and maybe other unmappable inds." + (call-with-db + (lambda (db) + (let [(query (string-append "SELECT Strain.Name, PublishData.value FROM Strain, PublishData WHERE PublishData.Id=" dataid " and Strain.Id=StrainID;"))] + (dbi-query db query) + (if used-for-mapping? + (remove null? (pk (get-rows-apply db + (lambda (r) + (if (string-contains (assoc-ref r "Name") "BXD") + `(,(assoc-ref r "Name") . ,(assoc-ref r "value")) + '() ) ;; return empty on no match + ) '()))) + (remove null? (pk (get-rows-apply db + (lambda (r) + `(,(assoc-ref r "Name") . ,(assoc-ref r "value")) + ) '()))) + ))))) |
