aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2024-05-12 09:20:27 +0200
committerPjotr Prins2024-05-12 09:20:27 +0200
commit88b3327e37c1c99e7cca48b718ff5d2992e2cd1e (patch)
tree14ef1c0c93a7d83433e61d76bd5f1f27fb07b341
parent8e8263c374f84fb9cbd6c3a0da7b7f17e6e06c72 (diff)
downloadgn-guile-main.tar.gz
list-traits handle CLI options --start-id and --nextHEADmain
-rwxr-xr-xscripts/precompute/list-traits-to-compute.scm36
1 files changed, 30 insertions, 6 deletions
diff --git a/scripts/precompute/list-traits-to-compute.scm b/scripts/precompute/list-traits-to-compute.scm
index e954b14..0bcef3e 100755
--- a/scripts/precompute/list-traits-to-compute.scm
+++ b/scripts/precompute/list-traits-to-compute.scm
@@ -1,4 +1,5 @@
-#!
+#!/usr/bin/env guile \
+-e main -s
Step p1 lists traits that need to be computed.
@@ -33,7 +34,7 @@ you should see
Now list the next 1000 trait IDs:
- . .guix-shell -- guile -L . -s ./scripts/precompute/list-traits-to-compute.scm --next 1000
+ . .guix-shell -- guile -L . -s ./scripts/precompute/list-traits-to-compute.scm --first 0 --next 1000
The current logic is to list all datasets that contain a
BXD. (bxd-strain-id-names #:used-for-mapping? #t) fetches all ids and
@@ -66,13 +67,15 @@ When that is the case we might as well write the phenotype file because we have
(gn util convert)
(gn runner gemma)
; (rnrs base)
+ (ice-9 getopt-long)
(ice-9 match)
(srfi srfi-1)
)
-(call-with-db
- (lambda (db)
+(define (write-phenotypes first-id count)
+ (call-with-db
+ (lambda (db)
(begin
(let [(bxd-strains (memo-bxd-strain-id-names #:used-for-mapping? #t))]
(define (run-list-traits-to-compute db prev-id count)
@@ -110,6 +113,27 @@ When that is the case we might as well write the phenotype file because we have
)) nrecs)
; (display nrecs)
)))
- (run-list-traits-to-compute db 0 1000) ;; start precompute
+ (run-list-traits-to-compute db first-id count) ;; start precompute
;; (write bxd-strains)
- ))))
+ )))))
+
+
+(define (main args)
+ ;; (write args)
+ (let* ((option-spec '( (version (single-char #\v) (value #f))
+ (start-id (single-char #\s) (value #t))
+ (next (single-char #\n) (value #t))
+ (help (single-char #\h) (value #f))))
+ (options (getopt-long args option-spec))
+ (start-id (string->number (option-ref options 'start-id "0")))
+ (next (string->number (option-ref options 'next "5")))
+ (help-wanted (option-ref options 'help #f)))
+ (if help-wanted
+ (format #t "list-traits-to-compute writes JSON traits files from the GN DB
+Usage: list-traits-to-compute [options...]
+ -s, --start-id num Start from ID (default 0)
+ -n, --next count In batches of count size (default 5)
+ -h, --help Display this help
+")
+ (write-phenotypes start-id next)
+)))