about summary refs log tree commit diff
path: root/gn
diff options
context:
space:
mode:
Diffstat (limited to 'gn')
-rw-r--r--gn/data/dataset.scm17
1 files changed, 15 insertions, 2 deletions
diff --git a/gn/data/dataset.scm b/gn/data/dataset.scm
index b552b21..afe75ba 100644
--- a/gn/data/dataset.scm
+++ b/gn/data/dataset.scm
@@ -18,6 +18,7 @@
             get-bxd-publish-list
             get-bxd-publish-values-list
             get-bxd-publish-name-value-dict
+            get-bxd-publish-dataid-name-value-dict
             ))
 
 (define (get-dataset db probesetfreeze-id)
@@ -29,6 +30,14 @@
 (define (dataset-name db probesetfreeze-id)
   (assoc-ref (get-dataset db probesetfreeze-id) "Name"))
 
+(define (get-dataid-from-publishxrefid id)
+  "Get the internal dataid from publishxref - which is the same as used in the GN2 web interface"
+  (call-with-db
+   (lambda (db)
+     (let [(query (string-append "SELECT Id,PhenotypeId,DataId FROM PublishXRef WHERE Id=" id " AND InbredSetId=1 LIMIT 1"))]
+       (dbi-query db query)
+       (pk (int-to-string (assoc-ref (get-row db) "DataId")))))))
+
 (define (get-bxd-publish-list)
   (call-with-db
    (lambda (db)
@@ -36,7 +45,7 @@
        (dbi-query db query)
        (get-rows db '())))))
 
-(define* (get-bxd-publish-values-list dataid #:key used-for-mapping?)
+(define* (get-bxd-publish-values-list dataid #:optional 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)
@@ -52,7 +61,7 @@
            (get-rows db '())
            )))))
 
-(define* (get-bxd-publish-name-value-dict dataid #:key used-for-mapping?)
+(define* (get-bxd-publish-dataid-name-value-dict dataid #:optional 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)
@@ -70,3 +79,7 @@
                                                `(,(assoc-ref r "Name") . ,(assoc-ref r "value"))
                                                ) '())))
            )))))
+
+(define* (get-bxd-publish-name-value-dict id #:optional used-for-mapping?)
+  "Same as above function, but starting from data id"
+  (get-bxd-publish-dataid-name-value-dict (get-dataid-from-publishxrefid id) used-for-mapping?))