blob: 8d319743dc0b456e0a7dc647a5ff2a1378e01e7b (
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
91
92
93
|
#! /usr/bin/env guile
!#
(use-modules (srfi srfi-1)
(srfi srfi-26)
(ice-9 getopt-long)
(ice-9 match)
(ice-9 regex)
(transform strings)
(transform sql)
(transform triples)
(transform special-forms))
;; One email ID in the Investigators table has spaces in it. This
;; function fixes that.
(define (fix-email-id email)
(string-delete #\space email))
(define (investigator-attributes->id first-name last-name email)
;; There is just one record corresponding to "Evan Williams" which
;; does not have an email ID. To accommodate that record, we
;; construct the investigator ID from not just the email ID, but
;; also the first and the last names. It would be preferable to just
;; find Evan Williams' email ID and insert it into the database.
(string->identifier "investigator"
(string-join
(list first-name last-name (fix-email-id email))
"_")
#:separator "_"))
(define-transformer investigators
;; There are a few duplicate entries. We group by email to
;; deduplicate.
(tables (Investigators)
"GROUP BY Email")
(triples (investigator-attributes->id (field Investigators FirstName)
(field Investigators LastName)
"")
(set rdf:type 'foaf:Person)
(set foaf:name (string-append (field Investigators FirstName) " "
(field Investigators LastName)))
(set foaf:givenName
(field Investigators FirstName))
(set foaf:familyName
(field Investigators LastName))
(set foaf:homepage (field Investigators Url))
(set v:adr (field Investigators Address))
(set v:locality (field Investigators City))
(set v:region (field Investigators State))
(set v:postal-code (field Investigators ZipCode))
(set v:country-name (field Investigators Country))))
(let* ((option-spec
'((settings (single-char #\s) (value #t))
(output (single-char #\o) (value #t))
(documentation (single-char #\d) (value #t))))
(options (getopt-long (command-line) option-spec))
(settings (option-ref options 'settings #f))
(output (option-ref options 'output #f))
(documentation (option-ref options 'documentation #f))
(%connection-settings
(call-with-input-file settings
read)))
(with-documentation
(name "Info files / Investigators Metadata")
(connection %connection-settings)
(table-metadata? #f)
(prefixes
'(
("dcat:" "<http://www.w3.org/ns/dcat#>")
("dct:" "<http://purl.org/dc/terms/>")
("foaf:" "<http://xmlns.com/foaf/0.1/#term_>")
("geoSeries:" "<http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=>")
("gn:" "<http://rdf.genenetwork.org/v1/id/>")
("gnc:" "<http://rdf.genenetwork.org/v1/category/>")
("gnt:" "<http://rdf.genenetwork.org/v1/term/>")
("owl:" "<http://www.w3.org/2002/07/owl#>")
("rdf:" "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>")
("rdfs:" "<http://www.w3.org/2000/01/rdf-schema#>")
("skos:" "<http://www.w3.org/2004/02/skos/core#>")
("taxon:" "<http://purl.uniprot.org/taxonomy/>")
("v:" "<http://www.w3.org/2006/vcard/ns#>")
("xkos:" "<http://rdf-vocabulary.ddialliance.org/xkos#>")
("xsd:" "<http://www.w3.org/2001/XMLSchema#>")
))
(inputs
(list investigators))
(outputs
`(#:documentation ,documentation
#:rdf ,output))))
|