Browse Source

Prepare transforming to snp-record

master
Pjotr Prins 11 months ago
parent
commit
2e1004f964
3 changed files with 38 additions and 11 deletions
  1. +16
    -6
      README.org
  2. +16
    -0
      summary-stats/ebi.rkt
  3. +6
    -5
      test/ebi-test.rkt

+ 16
- 6
README.org View File

@@ -441,16 +441,26 @@ that returns the full result and handles the paging. So we can do
(ebi-sumstat-chr-pos-json "13" 32315086 32400266)
#+END_SRC

The result is the full set. This looks good, but why return a JSON
structure (even if it is an ~jsexp~)? Also we probably don't need all
data, so a transform and filter makes sense that get executed when
data flows in.
The result is the full set. This looks good, but why return a
JSON structure (even if it is an ~jsexp~)? Also we probably don't
need all data, so a transform and filter makes sense that get
executed when data flows in.

In the first step we create a generic struct related to a SNP
record.

#+BEGIN_SRC scheme
(struct snp-record
(snp-name snp-variant chr pos p-value gene snp-uri trait trait-uri))
#+END_SRC

This is the information that gets passed back to GeneNetwork.

Next steps:

+ Add unit test infra that can read data from file
x Add unit test infra that can read data from file
+ Use jsexp to filter out p-value is -99
+ return snp, variant, chr, pos, p-value, trait
+ return snp-record: snp, variant, chr, pos, p-value, trait
+ add description for trait
- we can use a link like https://www.ebi.ac.uk/ols/api/ontologies/efo/terms?iri=http://www.ebi.ac.uk/efo/EFO_0000305
+ cache result


+ 16
- 0
summary-stats/ebi.rkt View File

@@ -121,3 +121,19 @@
(let ([json-res (ebi-sumstat-string (string-append "chromosomes/" chr "/associations?size=10000&bp_lower=" (number->string startpos) "&bp_upper=" (number->string endpos) "&p_upper=1e-8&p_lower=-0.0"))])
json-res
))

; Use implementation independent struct
(struct snp-record
(snp-name snp-variant chr pos p-value gene snp-uri trait trait-uri))

#|

Converts a JSON sumstats result buffer-list and filters
out missing p-values (-99). Returns a simplified set.

|#

(provide ebi-sumstat->snp-records)

(define (ebi-sumstat->snp-records buf)
(compose string->jsexpr string-join) buf)

+ 6
- 5
test/ebi-test.rkt View File

@@ -20,7 +20,7 @@
(dropf lst non-empty-string?)
)

(define (read->buf fn)
(define (read->list fn)
(with-input-from-file fn
(lambda ()
(for/list ([line (in-lines)])
@@ -29,13 +29,14 @@

; Path -> (Listof String)
(define metadata
(read->buf "data/ebi-api-metadata.json"))
(read->list "data/ebi-api-metadata.json"))

(test-case
"EBI Summary Statistics Tests"
; (define in (open-input-file "test/data/metadata.json"))
; (define in (open-input-file "test/data/metadata.json"))
(check-equal? (first metadata) "HTTP/1.1 200 OK")
(define meta (string->jsexpr (string-join (skip-header metadata))))
(define meta (string->jsexpr(string-join(skip-header metadata))))
(check-equal? (genome-build meta) "GRCh38.p12")
(display (read->buf "data/ebi-sumstats-brca2.json"))
(display (ebi-sumstat->snp-records (read->list "data/ebi-sumstats-brca2.json")))
#t
)

Loading…
Cancel
Save