aboutsummaryrefslogtreecommitdiff
path: root/examples/dump-probeset-metadata.scm
blob: 6da1eb0cfcc8eb2be3233583c4ac71cbfe70c318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /usr/bin/env guile
!#

(use-modules (srfi srfi-1)
             (srfi srfi-26)
             (ice-9 match)
             (ice-9 regex)
             (dump strings)
             (dump sql)
             (dump triples)
             (dump special-forms))



(define %connection-settings
  (call-with-input-file (list-ref (command-line) 1)
    read))


(define-dump dump-probeset-metadata
  (tables (ProbeSetXRef
           (left-join ProbeSet "ON ProbeSetXRef.ProbeSetId = ProbeSet.Id")
           (left-join ProbeSetFreeze "ON ProbeSetXRef.ProbeSetFreezeId = ProbeSetFreeze.Id"))
          "WHERE ProbeSetFreeze.public > 0 AND ProbeSetFreeze.confidentiality < 1")
  (schema-triples
   (gn:probesetData rdfs:range gn:probeset)
   (gn-term:hasProbeset rdfs:range rdfs:Literal))
  (triples
      (string->identifier
       "probesetData"
       (field ("CONCAT(ProbeSetFreeze.Name,':',IFNULL(ProbeSet.Name, ProbeSet.Id))"
               ProbeSetName)))
    (set rdf:type 'gn:probesetData)
    (set gn-term:hasProbeset
         (ontology
          'probeset:
          (regexp-substitute/global
           #f "[^A-Za-z0-9:]"
           (field ("IFNULL(ProbeSet.Name, ProbeSet.Id)"
                   name))
           'pre "_" 'post)))
    (set gn-term:probesetOfDataset
         (ontology
          'probeset:
          (regexp-substitute/global #f "[^A-Za-z0-9:]"
                                    (field ProbeSetFreeze Name)
                                    'pre "_" 'post)))
    (set gn-term:mean
         (annotate-field
          (field ("IFNULL(ProbeSetXRef.mean, '')" mean))
          '^^xsd:double))
    (set gn-term:se
         (annotate-field
          (field ("IFNULL(ProbeSetXRef.se, '')" se))
          '^^xsd:double))
    (set gn-term:locus (field ProbeSetXRef Locus))
    (set gn:LRS
         (annotate-field
          (field ("IFNULL(ProbeSetXRef.LRS, '')" LRS))
          '^^xsd:double))
    (set gn-term:pValue
         (annotate-field
          (field ("IFNULL(ProbeSetXRef.pValue, '')" pValue))
          '^^xsd:double))
    (set gn-term:additive
         (annotate-field
          (field ("IFNULL(ProbeSetXRef.additive, '')" additive))
          '^^xsd:double))
    (set gn-term:h2
         (annotate-field
          (field ("IFNULL(ProbeSetXRef.h2, '')" h2))
          '^^xsd:float))))



(dump-with-documentation
 (name "Probeset Metadata")
 (connection %connection-settings)
 (table-metadata? #f)
 (prefixes
  '(("gn:" "<http://genenetwork.org/id/>")
    ("gn-term:" "<http://genenetwork.org/id/>")
    ("rdf:" "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>")
    ("rdfs:" "<http://www.w3.org/2000/01/rdf-schema#>")
    ("xsd:" "<http://www.w3.org/2001/XMLSchema#>")))
 (inputs
  (list dump-probeset-metadata))
 (outputs
  '(#:documentation "./docs/dump-probeset-metadata.md"
    #:rdf "./verified-data/dump-probeset-metadata.ttl")))