diff options
author | Pjotr Prins | 2023-11-17 11:09:17 +0100 |
---|---|---|
committer | Pjotr Prins | 2023-11-17 11:09:17 +0100 |
commit | c401f66de2dbcbc41dd9551490563543092de242 (patch) | |
tree | 8e9eab92738389a8e4e73280a52ec5f11ea6f45b /scripts | |
parent | 678d976260c6f566166e0459a425d5ef296b002f (diff) | |
download | gn-guile-c401f66de2dbcbc41dd9551490563543092de242.tar.gz |
First implementation of DB handler
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/precompute/precompute-hits.scm | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/scripts/precompute/precompute-hits.scm b/scripts/precompute/precompute-hits.scm index cc26a9a..5955fb1 100755 --- a/scripts/precompute/precompute-hits.scm +++ b/scripts/precompute/precompute-hits.scm @@ -6,6 +6,7 @@ (use-modules (dbi dbi) (gn db mysql) + (gn data strains) (rnrs base) (ice-9 match) ) @@ -14,22 +15,46 @@ ;; ;; mysql -uwebqtlout -pwebqtlout -A -h 127.0.0.1 -P 3306 db_webqtl -e "show tables;" ;; -(define db (dbi-open "mysql" "webqtlout:webqtlout:db_webqtl:tcp:127.0.0.1:3306")) -(db-check db) -(dbi-query db "SELECT * FROM ProbeSetXRef LIMIT 3") -(db-check db) -; (display (dbi-get_status db_webqtl)) -(let [(row (dbi-get_row db))] + +#! +(db-query "SELECT * FROM ProbeSetXRef LIMIT 3") +(db-check) +(let [(row (db-get-row))] (display row) ) +!# -(dbi-query db "SELECT StrainId,Strain.Name FROM Strain, StrainXRef WHERE StrainXRef.StrainId = Strain.Id AND StrainXRef.InbredSetId = 1 AND Used_for_mapping='Y' ORDER BY StrainId;") -(db-check db) - -(define ids (db-get-rows-apply db (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "Name"))) '())) +(call-with-db + (lambda (db) + (begin + (dbi-query db "SELECT * FROM ProbeSetXRef LIMIT 3") + (let [(row (get-row db))] + (display row) + ) + (newline) + (dbi-query db "SELECT * FROM ProbeSetXRef LIMIT 3") + (let [(row (get-row db))] + (display row) + ) + (newline) + (dbi-query db "SELECT StrainId,Strain.Name FROM Strain, StrainXRef WHERE StrainXRef.StrainId = Strain.Id AND StrainXRef.InbredSetId = 1 AND Used_for_mapping='Y' ORDER BY StrainId;") + (let [(row (get-row db))] + (display row) + ) + (let [(result (get-rows-apply db (lambda (r) `(,(assoc-ref r "StrainId") . ,(assoc-ref r "Name"))) '()))] + (display (car result))) -(newline) -(display (car ids)) -(newline) -(display (assoc 5 ids)) -(newline) + (newline) + (display (strain-names)) + ; (display (car ids)) + (newline) + ; (display (assoc 5 ids)) + (newline) + (newline) + (dbi-query db "SELECT * FROM ProbeSetXRef LIMIT 3") + (let [(row (get-row db))] + (display row) + ) + (db-check2 db) + (newline) +))) |