-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_matrix.rq
210 lines (204 loc) · 6.94 KB
/
make_matrix.rq
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#+ summary: Create the full matrix (this is deprecated; the new method is via the make_tables script)
#+ method: GET
#+ pagination: 10000
prefix fip: <https://w3id.org/fair/fip/terms/>
prefix dct: <http://purl.org/dc/terms/>
prefix dce: <http://purl.org/dc/elements/1.1/>
prefix npa: <http://purl.org/nanopub/admin/>
prefix npx: <http://purl.org/nanopub/x/>
prefix np: <http://www.nanopub.org/nschema#>
prefix dcat: <https://www.w3.org/ns/dcat#>
select distinct ?fip_index ?fip_title ?community ?c ?supercommunity ?sc ?question ?q ?sort ?nochoice ?decl ?rel ?resource ?res ?reslabel ?res_np ?resourcetype ?startdate ?enddate ?qualifier ?qualification_np ?date where {
?np np:hasAssertion ?assertion .
graph npa:graph { ?np dct:created ?date . }
graph ?assertion {
?decl a fip:FIP-Declaration .
values ?rel {
fip:declares-current-use-of fip:declares-planned-use-of fip:declares-planned-replacement-of
# unofficial:
fip:declares-replacement-from fip:declares-replacement-to
}
?decl ?rel ?resource_pre .
?decl fip:refers-to-question ?question .
# grlc gives an error for some reason if these two optional statements are at the end of the graph block:
optional { ?decl dcat:startDate ?startdate . }
optional { ?decl dcat:endDate ?enddate . }
?decl fip:declared-by ?community .
}
optional {
?community dct:isPartOf ?supercommunity .
}
graph npa:graph { ?index_np npa:hasValidSignatureForPublicKey ?pubkey . }
?index_np np:hasAssertion ?index_a .
?index_np np:hasPublicationInfo ?index_i .
graph ?index_a {
?fip_index npx:includesElement ?np .
}
graph ?index_i {
?fip_index dce:title ?fip_title_l .
}
filter not exists {
?fip_newer_index npx:includesElement ?newer_np ;
dce:title ?fip_title_l .
graph npa:graph { ?newer_np dct:created ?newer_date . }
filter (?newer_date > ?date)
}
filter not exists {
graph npa:graph {
?index_np_new npa:hasHeadGraph ?nh .
?index_np_new npa:hasValidSignatureForPublicKey ?pubkey .
}
graph ?nh {
?index_np_new np:hasPublicationInfo ?ni .
}
graph ?ni {
?index_np_new npx:supersedes ?index_np .
}
}
filter not exists {
graph npa:graph {
?index_np_r npa:hasHeadGraph ?rh .
?index_np_r npa:hasValidSignatureForPublicKey ?pubkey .
}
graph ?rh {
?index_np_r np:hasAssertion ?ra .
}
graph ?ra {
?somebody npx:retracts ?index_np .
}
}
optional {
graph npa:graph { ?res_np_pre npa:hasValidSignatureForPublicKey ?res_pubkey . }
?res_np_pre np:hasAssertion ?res_a .
?res_np_pre np:hasPublicationInfo ?res_i .
graph ?res_a {
?resource_pre rdfs:label ?resourcelabel_pre .
}
graph ?res_i {
?res_np_pre (npx:introduces|npx:describes) ?resource_pre .
}
optional {
graph npa:graph {
?res_np_new npa:hasHeadGraph ?rnh .
?res_np_new npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rnh {
?res_np_new np:hasAssertion ?rha .
?res_np_new np:hasPublicationInfo ?rni .
}
graph ?rha {
?resource_new rdfs:label ?resourcelabel_new .
}
graph ?rni {
?res_np_new npx:supersedes ?res_np_x .
?res_np_new (npx:introduces|npx:describes) ?resource_new .
}
# needs to be done properly:
?res_np_x npx:supersedes* ?res_np_pre .
filter not exists {
graph npa:graph {
?res_np_rn npa:hasHeadGraph ?rrhn .
?res_np_rn npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rrhn {
?res_np_rn np:hasAssertion ?rran .
}
graph ?rran {
?rnsomebody npx:retracts ?res_np_new .
}
}
filter not exists {
graph npa:graph {
?res_np_sn npa:hasHeadGraph ?rshn .
?res_np_sn npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rshn {
?res_np_sn np:hasPublicationInfo ?rsin .
}
graph ?rsin {
?res_np_ns npx:supersedes ?res_np_new .
}
}
}
bind(coalesce(?resource_new, ?resource_pre) as ?resource)
bind(coalesce(?res_np_new, ?res_np_pre) as ?res_np)
bind(coalesce(?resourcelabel_new, ?resourcelabel_pre) as ?resourcelabel)
filter not exists {
graph npa:graph {
?res_np_r npa:hasHeadGraph ?rrh .
?res_np_r npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rrh {
?res_np_r np:hasAssertion ?rra .
}
graph ?rra {
?rsomebody npx:retracts ?res_np .
}
}
filter not exists {
graph npa:graph {
?res_np_s npa:hasHeadGraph ?rsh .
?res_np_s npa:hasValidSignatureForPublicKey ?res_pubkey .
}
graph ?rsh {
?res_np_s np:hasPublicationInfo ?rsi .
}
graph ?rsi {
?res_np_s npx:supersedes ?res_np .
}
}
optional {
values ?resourcetype { fip:Available-FAIR-Enabling-Resource fip:FAIR-Enabling-Resource-to-be-Developed }
?resource a ?resourcetype
}
optional {
values ?qpubkey {
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCtpcftn7kbe6toJbOTDQaCcCssEFSWqt6J4rZ02w+TfY7/eIOgJZYOlpL6G3AzO2RNmVYWRPSlMiykaFuaRuBitvk1GKfGdprfZbvXwmeOxpqCTRBQX9EnFyQyd+Ra/ajfw/UsG8skeu1xnUEpnQbpgbQYc/fvhJNN0UwEc77mOwIDAQAB"^^xsd:string
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDO4xkU+/dGujq1raR66QtRqquMxiJ9hm2uzc2uBj7bCBBRnWhTw7M8f77BqAFHShgxqxYTr2do7/tVmoKeM51ISyttxWrh9ebZRoz5o6Muxt7HyA4sLHAmnixeZ5VJfZzsKAmVN23Y2ZiCqMoXjtcp5jO2lOC0AXaGPftnaA8b9QIDAQAB"^^xsd:string
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCFntPrMZqvg2kVhCNArNnEn37ddXGwZ/0r4C8CS4lDry7C7YkYgng9yb0UMZQUHiTVkR/5A4m/xjE+Vy+AnwcWUeB75SfGZjE5ylI6VeHjTHi9+2hh2PHYIWnkhU4WHl3COEnxSSa/VouvPzZ2BIWLH6fTrq7NNL3RF5hGegGG0QIDAQAB"^^xsd:string
}
graph npa:graph {
?qualification_np npa:hasHeadGraph ?qh .
?qualification_np npa:hasValidSignatureForPublicKey ?qpubkey .
}
graph ?qh {
?qualification_np np:hasAssertion ?qa .
}
graph ?qa {
?qualifier npx:qualifies ?res_np .
}
filter not exists {
graph npa:graph {
?qnewversion npa:hasHeadGraph ?qnh .
?qnewversion npa:hasValidSignatureForPublicKey ?qpubkey .
}
graph ?qnh {
?qnewversion np:hasPublicationInfo ?qni .
}
graph ?qni {
?qnewversion npx:supersedes ?qualification_np .
}
}
filter not exists {
graph npa:graph {
?qretraction npa:hasHeadGraph ?qrh .
?qretraction npa:hasValidSignatureForPublicKey ?qpubkey .
}
graph ?qrh {
?qretraction np:hasAssertion ?ra .
}
graph ?qra {
?qsomebody npx:retracts ?qualification_np .
}
}
}
}
bind (replace(str(?community), ".*#", "") as ?c)
bind (replace(str(?supercommunity), ".*#", "") as ?sc)
bind (replace(str(?question), "^.*-([^-MD]+(-[MD]+)?)$", "$1") as ?q)
bind (concat(replace(?q, "F|M", "0"), "x") as ?sort)
bind (replace(str(?resource), "^.*?(#|/)([^/#]*/?[^/#]*)/?$", "$2") as ?res)
bind (str(?resourcelabel) as ?reslabel)
bind (str(?fip_title_l) as ?fip_title)
bind ("" as ?nochoice)
} order by ?sort ?c ?fip_index ?decl ?res ?res_np ?qualification_np