diff options
author | Pjotr Prins | 2024-05-05 14:06:55 +0200 |
---|---|---|
committer | Pjotr Prins | 2024-05-05 14:06:55 +0200 |
commit | 91ed2e9f0f1c5bd96b4378db0cdfe88fdbb4d01a (patch) | |
tree | bc441753af1122b88c53c7d4bb99749750b4aa47 /scripts | |
parent | a1511cae7937ea60abdaf56e759f1066c2e83b13 (diff) | |
download | gn-guile-91ed2e9f0f1c5bd96b4378db0cdfe88fdbb4d01a.tar.gz |
Trait IDs fetch in batch
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/precompute/list-traits-to-compute.scm | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm index 3cba292..68f0711 100755 --- a/scripts/precompute/list-traits-to-compute.scm +++ b/scripts/precompute/list-traits-to-compute.scm @@ -59,47 +59,41 @@ Now list the next 1000 trait IDs: (dbi-query db (string-append "select Id,Chr,Mb,Name,Symbol,description from ProbeSet where Id=" (int-to-string probeset-id) " limit 1")) (get-row db)) (define (run-list-traits-to-compute db prev-id count) - (let [(hit (get-precompute-hit db prev-id))] - (if hit - (let* [(data-id (assoc-ref hit "DataId")) - (data-id-str (int-to-string data-id)) - (probesetfreeze-id (assoc-ref hit "ProbeSetFreezeId")) - (probeset-id (assoc-ref hit "ProbeSetId")) - (trait (get-trait db probeset-id)) - (trait-name (assoc-ref trait "Name")) - (name (dataset-name db probesetfreeze-id)) - ] - (display hit) - (newline) - ;; ---- Get strains and phenotypes for this dataset - (dbi-query db (string-append "SELECT StrainId,value from ProbeSetData WHERE Id=" data-id-str)) - (define id_traits (get-rows-apply db - (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "value"))) - '())) - ;; ---- Now we need to make sure that all strains belong to BXD - (define non-bxd (fold - (lambda (strain lst) - (let* [(id (car strain)) - (name (assoc id bxd-strains))] - (if name - lst - (append lst `(,name))))) - - '() - id_traits)) - (define traits (map - (lambda (t) - (match t - ((id . value) (cons (assoc-ref bxd-strains id) value) - ))) - id_traits)) - (if (eq? non-bxd '()) - (set-precompute-hit-status! db data-id-str "GEMMA-START") - ;; disable precompute if non-bxd, for now, so it won't try again - (set-precompute-hit-status! db data-id-str "NON-BXD")) - (if (> count 0) - (run-list-traits-to-compute db data-id (- count 1)) ;; next round - ) - )))) + (let [(hits (get-precompute-hits db prev-id count))] + (for-each (lambda (hit) + (let* [(data-id (assoc-ref hit "DataId")) + (data-id-str (int-to-string data-id)) + ;; (probesetfreeze-id (assoc-ref hit "ProbeSetFreezeId")) + ;; (probeset-id (assoc-ref hit "ProbeSetId")) + ;; (trait (get-trait db probeset-id)) + ;; (trait-name (assoc-ref trait "Name")) + ;; (name (dataset-name db probesetfreeze-id)) + ] + (display hit) + (newline) + ;; ---- Get strains and phenotypes for this dataset + (dbi-query db (string-append "SELECT StrainId,value from ProbeSetData WHERE Id=" data-id-str)) + (define id_traits (get-rows-apply db + (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "value"))) + '())) + ;; ---- Now we need to make sure that all strains belong to BXD + (define non-bxd (fold + (lambda (strain lst) + (let* [(id (car strain)) + (name (assoc id bxd-strains))] + (if name + lst + (append lst `(,name))))) + + '() + id_traits)) + (define traits (map + (lambda (t) + (match t + ((id . value) (cons (assoc-ref bxd-strains id) value) + ))) + id_traits)) + #t)) + hits))) (run-list-traits-to-compute db 0 5) ;; start precompute -))) + ))) |