Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/prov/tests/examples.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 # coding: utf8 | |
| 2 from __future__ import (absolute_import, division, print_function, | |
| 3 unicode_literals) | |
| 4 | |
| 5 from prov.model import ProvDocument, Namespace, Literal, PROV, Identifier | |
| 6 import datetime | |
| 7 | |
| 8 | |
| 9 def primer_example(): | |
| 10 # https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/primer.pn | |
| 11 #=========================================================================== | |
| 12 # document | |
| 13 g = ProvDocument() | |
| 14 | |
| 15 # prefix ex <http://example/> | |
| 16 # prefix dcterms <http://purl.org/dc/terms/> | |
| 17 # prefix foaf <http://xmlns.com/foaf/0.1/> | |
| 18 ex = Namespace('ex', 'http://example/') # namespaces do not need to be explicitly added to a document | |
| 19 g.add_namespace("dcterms", "http://purl.org/dc/terms/") | |
| 20 g.add_namespace("foaf", "http://xmlns.com/foaf/0.1/") | |
| 21 | |
| 22 # entity(ex:article, [dcterms:title="Crime rises in cities"]) | |
| 23 # first time the ex namespace was used, it is added to the document automatically | |
| 24 g.entity(ex['article'], {'dcterms:title': "Crime rises in cities"}) | |
| 25 # entity(ex:articleV1) | |
| 26 g.entity(ex['articleV1']) | |
| 27 # entity(ex:articleV2) | |
| 28 g.entity(ex['articleV2']) | |
| 29 # entity(ex:dataSet1) | |
| 30 g.entity(ex['dataSet1']) | |
| 31 # entity(ex:dataSet2) | |
| 32 g.entity(ex['dataSet2']) | |
| 33 # entity(ex:regionList) | |
| 34 g.entity(ex['regionList']) | |
| 35 # entity(ex:composition) | |
| 36 g.entity(ex['composition']) | |
| 37 # entity(ex:chart1) | |
| 38 g.entity(ex['chart1']) | |
| 39 # entity(ex:chart2) | |
| 40 g.entity(ex['chart2']) | |
| 41 # entity(ex:blogEntry) | |
| 42 g.entity(ex['blogEntry']) | |
| 43 | |
| 44 # activity(ex:compile) | |
| 45 g.activity('ex:compile') # since ex is registered, it can be used like this | |
| 46 # activity(ex:compile2) | |
| 47 g.activity('ex:compile2') | |
| 48 # activity(ex:compose) | |
| 49 g.activity('ex:compose') | |
| 50 # activity(ex:correct, 2012-03-31T09:21:00, 2012-04-01T15:21:00) | |
| 51 g.activity('ex:correct', '2012-03-31T09:21:00', '2012-04-01T15:21:00') # date time can be provided as strings | |
| 52 # activity(ex:illustrate) | |
| 53 g.activity('ex:illustrate') | |
| 54 | |
| 55 # used(ex:compose, ex:dataSet1, -, [ prov:role = "ex:dataToCompose"]) | |
| 56 g.used('ex:compose', 'ex:dataSet1', other_attributes={'prov:role': "ex:dataToCompose"}) | |
| 57 # used(ex:compose, ex:regionList, -, [ prov:role = "ex:regionsToAggregateBy"]) | |
| 58 g.used('ex:compose', 'ex:regionList', other_attributes={'prov:role': "ex:regionsToAggregateBy"}) | |
| 59 # wasGeneratedBy(ex:composition, ex:compose, -) | |
| 60 g.wasGeneratedBy('ex:composition', 'ex:compose') | |
| 61 | |
| 62 # used(ex:illustrate, ex:composition, -) | |
| 63 g.used('ex:illustrate', 'ex:composition') | |
| 64 # wasGeneratedBy(ex:chart1, ex:illustrate, -) | |
| 65 g.wasGeneratedBy('ex:chart1', 'ex:illustrate') | |
| 66 | |
| 67 # wasGeneratedBy(ex:chart1, ex:compile, 2012-03-02T10:30:00) | |
| 68 g.wasGeneratedBy('ex:chart1', 'ex:compile', '2012-03-02T10:30:00') | |
| 69 # wasGeneratedBy(ex:chart2, ex:compile2, 2012-04-01T15:21:00) | |
| 70 # | |
| 71 # | |
| 72 # agent(ex:derek, [ prov:type="prov:Person", foaf:givenName = "Derek", | |
| 73 # foaf:mbox= "<mailto:derek@example.org>"]) | |
| 74 g.agent('ex:derek', { | |
| 75 'prov:type': PROV["Person"], 'foaf:givenName': "Derek", 'foaf:mbox': "<mailto:derek@example.org>" | |
| 76 }) | |
| 77 # wasAssociatedWith(ex:compose, ex:derek, -) | |
| 78 g.wasAssociatedWith('ex:compose', 'ex:derek') | |
| 79 # wasAssociatedWith(ex:illustrate, ex:derek, -) | |
| 80 g.wasAssociatedWith('ex:illustrate', 'ex:derek') | |
| 81 # | |
| 82 # agent(ex:chartgen, [ prov:type="prov:Organization", | |
| 83 # foaf:name = "Chart Generators Inc"]) | |
| 84 g.agent('ex:chartgen', {'prov:type': PROV["Organization"], 'foaf:name': "Chart Generators Inc"}) | |
| 85 # actedOnBehalfOf(ex:derek, ex:chartgen, ex:compose) | |
| 86 g.actedOnBehalfOf('ex:derek', 'ex:chartgen', 'ex:compose') | |
| 87 # wasAttributedTo(ex:chart1, ex:derek) | |
| 88 g.wasAttributedTo('ex:chart1', 'ex:derek') | |
| 89 | |
| 90 # wasGeneratedBy(ex:dataSet2, ex:correct, -) | |
| 91 g.wasGeneratedBy('ex:dataSet2', 'ex:correct') | |
| 92 # used(ex:correct, ex:dataSet1, -) | |
| 93 g.used('ex:correct', 'ex:dataSet1') | |
| 94 # wasDerivedFrom(ex:dataSet2, ex:dataSet1, [prov:type='prov:Revision']) | |
| 95 g.wasDerivedFrom('ex:dataSet2', 'ex:dataSet1', other_attributes={'prov:type': PROV['Revision']}) | |
| 96 # wasDerivedFrom(ex:chart2, ex:dataSet2) | |
| 97 g.wasDerivedFrom('ex:chart2', 'ex:dataSet2') | |
| 98 | |
| 99 # wasDerivedFrom(ex:blogEntry, ex:article, [prov:type='prov:Quotation']) | |
| 100 g.wasDerivedFrom('ex:blogEntry', 'ex:article', other_attributes={'prov:type': PROV['Quotation']}) | |
| 101 # specializationOf(ex:articleV1, ex:article) | |
| 102 g.specializationOf('ex:articleV1', 'ex:article') | |
| 103 # wasDerivedFrom(ex:articleV1, ex:dataSet1) | |
| 104 g.wasDerivedFrom('ex:articleV1', 'ex:dataSet1') | |
| 105 | |
| 106 # specializationOf(ex:articleV2, ex:article) | |
| 107 g.specializationOf('ex:articleV2', 'ex:article') | |
| 108 # wasDerivedFrom(ex:articleV2, ex:dataSet2) | |
| 109 g.wasDerivedFrom('ex:articleV2', 'ex:dataSet2') | |
| 110 | |
| 111 # alternateOf(ex:articleV2, ex:articleV1) | |
| 112 g.alternateOf('ex:articleV2', 'ex:articleV1') | |
| 113 | |
| 114 # endDocument | |
| 115 return g | |
| 116 | |
| 117 | |
| 118 def primer_example_alternate(): | |
| 119 g = ProvDocument(namespaces={ | |
| 120 'ex': 'http://example/', | |
| 121 'dcterms': 'http://purl.org/dc/terms/', | |
| 122 'foaf': 'http://xmlns.com/foaf/0.1/' | |
| 123 }) | |
| 124 | |
| 125 article = g.entity('ex:article', {'dcterms:title': "Crime rises in cities"}) | |
| 126 articleV1 = g.entity('ex:articleV1') | |
| 127 articleV2 = g.entity('ex:articleV2') | |
| 128 dataSet1 = g.entity('ex:dataSet1') | |
| 129 dataSet2 = g.entity('ex:dataSet2') | |
| 130 regionList = g.entity('ex:regionList') | |
| 131 composition = g.entity('ex:composition') | |
| 132 chart1 = g.entity('ex:chart1') | |
| 133 chart2 = g.entity('ex:chart2') | |
| 134 blogEntry = g.entity('ex:blogEntry') | |
| 135 | |
| 136 compile = g.activity('ex:compile') | |
| 137 compile2 = g.activity('ex:compile2') | |
| 138 compose = g.activity('ex:compose') | |
| 139 correct = g.activity('ex:correct', '2012-03-31T09:21:00', '2012-04-01T15:21:00') | |
| 140 illustrate = g.activity('ex:illustrate') | |
| 141 | |
| 142 compose.used(dataSet1, attributes={'prov:role': "ex:dataToCompose"}) | |
| 143 compose.used(regionList, attributes={'prov:role': "ex:regionsToAggregateBy"}) | |
| 144 composition.wasGeneratedBy(compose) | |
| 145 | |
| 146 illustrate.used(composition) | |
| 147 chart1.wasGeneratedBy(illustrate) | |
| 148 | |
| 149 chart1.wasGeneratedBy(compile, '2012-03-02T10:30:00') | |
| 150 | |
| 151 derek = g.agent('ex:derek', { | |
| 152 'prov:type': PROV['Person'], 'foaf:givenName': "Derek", 'foaf:mbox': "<mailto:derek@example.org>" | |
| 153 }) | |
| 154 compose.wasAssociatedWith(derek) | |
| 155 illustrate.wasAssociatedWith(derek) | |
| 156 | |
| 157 chartgen = g.agent('ex:chartgen', { | |
| 158 'prov:type': PROV["Organization"], 'foaf:name': "Chart Generators Inc" | |
| 159 }) | |
| 160 derek.actedOnBehalfOf(chartgen, compose) | |
| 161 chart1.wasAttributedTo(derek) | |
| 162 | |
| 163 dataSet2.wasGeneratedBy(correct) | |
| 164 correct.used(dataSet1) | |
| 165 dataSet2.wasDerivedFrom(dataSet1, attributes={'prov:type': PROV['Revision']}) | |
| 166 chart2.wasDerivedFrom(dataSet2) | |
| 167 | |
| 168 blogEntry.wasDerivedFrom(article, attributes={'prov:type': PROV['Quotation']}) | |
| 169 articleV1.specializationOf(article) | |
| 170 articleV1.wasDerivedFrom(dataSet1) | |
| 171 | |
| 172 articleV2.specializationOf(article) | |
| 173 articleV2.wasDerivedFrom(dataSet2) | |
| 174 | |
| 175 articleV2.alternateOf(articleV1) | |
| 176 | |
| 177 return g | |
| 178 | |
| 179 | |
| 180 def w3c_publication_1(): | |
| 181 # https://github.com/lucmoreau/ProvToolbox/blob/master/asn/src/test/resources/prov/w3c-publication1.prov-asn | |
| 182 #=========================================================================== | |
| 183 # bundle | |
| 184 # | |
| 185 # prefix ex <http://example.org/> | |
| 186 # | |
| 187 # prefix w3 <http://www.w3.org/> | |
| 188 # prefix tr <http://www.w3.org/TR/2011/> | |
| 189 # prefix process <http://www.w3.org/2005/10/Process-20051014/tr.html#> | |
| 190 # prefix email <https://lists.w3.org/Archives/Member/w3c-archive/> | |
| 191 # prefix chairs <https://lists.w3.org/Archives/Member/chairs/> | |
| 192 # prefix trans <http://www.w3.org/2005/08/01-transitions.html#> | |
| 193 # prefix rec54 <http://www.w3.org/2001/02pd/rec54#> | |
| 194 # | |
| 195 # | |
| 196 # entity(tr:WD-prov-dm-20111018, [ prov:type='rec54:WD' ]) | |
| 197 # entity(tr:WD-prov-dm-20111215, [ prov:type='rec54:WD' ]) | |
| 198 # entity(process:rec-advance, [ prov:type='prov:Plan' ]) | |
| 199 # | |
| 200 # | |
| 201 # entity(chairs:2011OctDec/0004, [ prov:type='trans:transreq' ]) | |
| 202 # entity(email:2011Oct/0141, [ prov:type='trans:pubreq' ]) | |
| 203 # entity(email:2011Dec/0111, [ prov:type='trans:pubreq' ]) | |
| 204 # | |
| 205 # | |
| 206 # wasDerivedFrom(tr:WD-prov-dm-20111215, tr:WD-prov-dm-20111018) | |
| 207 # | |
| 208 # | |
| 209 # activity(ex:act1,-,-,[prov:type="publish"]) | |
| 210 # activity(ex:act2,-,-,[prov:type="publish"]) | |
| 211 # | |
| 212 # wasGeneratedBy(tr:WD-prov-dm-20111018, ex:act1, -) | |
| 213 # wasGeneratedBy(tr:WD-prov-dm-20111215, ex:act2, -) | |
| 214 # | |
| 215 # used(ex:act1, chairs:2011OctDec/0004, -) | |
| 216 # used(ex:act1, email:2011Oct/0141, -) | |
| 217 # used(ex:act2, email:2011Dec/0111, -) | |
| 218 # | |
| 219 # agent(w3:Consortium, [ prov:type='prov:Organization' ]) | |
| 220 # | |
| 221 # wasAssociatedWith(ex:act1, w3:Consortium, process:rec-advance) | |
| 222 # wasAssociatedWith(ex:act2, w3:Consortium, process:rec-advance) | |
| 223 # | |
| 224 # endBundle | |
| 225 #=========================================================================== | |
| 226 | |
| 227 g = ProvDocument() | |
| 228 g.add_namespace('ex', 'http://example.org/') | |
| 229 g.add_namespace('w3', 'http://www.w3.org/') | |
| 230 g.add_namespace('tr', 'http://www.w3.org/TR/2011/') | |
| 231 g.add_namespace('process', 'http://www.w3.org/2005/10/Process-20051014/tr.html#') | |
| 232 g.add_namespace('email', 'https://lists.w3.org/Archives/Member/w3c-archive/') | |
| 233 g.add_namespace('chairs', 'https://lists.w3.org/Archives/Member/chairs/') | |
| 234 g.add_namespace('trans', 'http://www.w3.org/2005/08/01-transitions.html#') | |
| 235 g.add_namespace('rec54', 'http://www.w3.org/2001/02pd/rec54#') | |
| 236 | |
| 237 g.entity('tr:WD-prov-dm-20111018', {'prov:type': 'rec54:WD'}) | |
| 238 g.entity('tr:WD-prov-dm-20111215', {'prov:type': 'rec54:WD'}) | |
| 239 g.entity('process:rec-advance', {'prov:type': 'prov:Plan'}) | |
| 240 | |
| 241 g.entity('chairs:2011OctDec/0004', {'prov:type': 'trans:transreq'}) | |
| 242 g.entity('email:2011Oct/0141', {'prov:type': 'trans:pubreq'}) | |
| 243 g.entity('email:2011Dec/0111', {'prov:type': 'trans:pubreq'}) | |
| 244 | |
| 245 g.wasDerivedFrom('tr:WD-prov-dm-20111215', 'tr:WD-prov-dm-20111018') | |
| 246 | |
| 247 g.activity('ex:act1', other_attributes={'prov:type': "publish"}) | |
| 248 g.activity('ex:act2', other_attributes={'prov:type': "publish"}) | |
| 249 | |
| 250 g.wasGeneratedBy('tr:WD-prov-dm-20111018', 'ex:act1') | |
| 251 g.wasGeneratedBy('tr:WD-prov-dm-20111215', 'ex:act2') | |
| 252 | |
| 253 g.used('ex:act1', 'chairs:2011OctDec/0004') | |
| 254 g.used('ex:act1', 'email:2011Oct/0141') | |
| 255 g.used('ex:act2', 'email:2011Dec/0111') | |
| 256 | |
| 257 g.agent('w3:Consortium', other_attributes={'prov:type': "Organization"}) | |
| 258 | |
| 259 g.wasAssociatedWith('ex:act1', 'w3:Consortium', 'process:rec-advance') | |
| 260 g.wasAssociatedWith('ex:act2', 'w3:Consortium', 'process:rec-advance') | |
| 261 | |
| 262 return g | |
| 263 | |
| 264 | |
| 265 def w3c_publication_2(): | |
| 266 # https://github.com/lucmoreau/ProvToolbox/blob/master/asn/src/test/resources/prov/w3c-publication2.prov-asn | |
| 267 #=========================================================================== | |
| 268 # bundle | |
| 269 # | |
| 270 # prefix ex <http://example.org/> | |
| 271 # prefix rec <http://example.org/record> | |
| 272 # | |
| 273 # prefix w3 <http://www.w3.org/TR/2011/> | |
| 274 # prefix hg <http://dvcs.w3.org/hg/prov/raw-file/9628aaff6e20/model/releases/WD-prov-dm-20111215/> | |
| 275 # | |
| 276 # | |
| 277 # entity(hg:Overview.html, [ prov:type="file in hg" ]) | |
| 278 # entity(w3:WD-prov-dm-20111215, [ prov:type="html4" ]) | |
| 279 # | |
| 280 # | |
| 281 # activity(ex:rcp,-,-,[prov:type="copy directory"]) | |
| 282 # | |
| 283 # wasGeneratedBy(rec:g; w3:WD-prov-dm-20111215, ex:rcp, -) | |
| 284 # | |
| 285 # entity(ex:req3, [ prov:type="http://www.w3.org/2005/08/01-transitions.html#pubreq" %% xsd:anyURI ]) | |
| 286 # | |
| 287 # used(rec:u; ex:rcp,hg:Overview.html,-) | |
| 288 # used(ex:rcp, ex:req3, -) | |
| 289 # | |
| 290 # | |
| 291 # wasDerivedFrom(w3:WD-prov-dm-20111215, hg:Overview.html, ex:rcp, rec:g, rec:u) | |
| 292 # | |
| 293 # agent(ex:webmaster, [ prov:type='prov:Person' ]) | |
| 294 # | |
| 295 # wasAssociatedWith(ex:rcp, ex:webmaster, -) | |
| 296 # | |
| 297 # endBundle | |
| 298 #=========================================================================== | |
| 299 | |
| 300 ex = Namespace('ex', 'http://example.org/') | |
| 301 rec = Namespace('rec', 'http://example.org/record') | |
| 302 w3 = Namespace('w3', 'http://www.w3.org/TR/2011/') | |
| 303 hg = Namespace('hg', 'http://dvcs.w3.org/hg/prov/raw-file/9628aaff6e20/model/releases/WD-prov-dm-20111215/') | |
| 304 | |
| 305 g = ProvDocument() | |
| 306 | |
| 307 g.entity(hg['Overview.html'], {'prov:type': "file in hg"}) | |
| 308 g.entity(w3['WD-prov-dm-20111215'], {'prov:type': "html4"}) | |
| 309 | |
| 310 g.activity(ex['rcp'], None, None, {'prov:type': "copy directory"}) | |
| 311 | |
| 312 g.wasGeneratedBy('w3:WD-prov-dm-20111215', 'ex:rcp', identifier=rec['g']) | |
| 313 | |
| 314 g.entity('ex:req3', {'prov:type': Identifier("http://www.w3.org/2005/08/01-transitions.html#pubreq")}) | |
| 315 | |
| 316 g.used('ex:rcp', 'hg:Overview.html', identifier='rec:u') | |
| 317 g.used('ex:rcp', 'ex:req3') | |
| 318 | |
| 319 g.wasDerivedFrom('w3:WD-prov-dm-20111215', 'hg:Overview.html', 'ex:rcp', 'rec:g', 'rec:u') | |
| 320 | |
| 321 g.agent('ex:webmaster', {'prov:type': "Person"}) | |
| 322 | |
| 323 g.wasAssociatedWith('ex:rcp', 'ex:webmaster') | |
| 324 | |
| 325 return g | |
| 326 | |
| 327 | |
| 328 def bundles1(): | |
| 329 # https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles1.provn | |
| 330 #=============================================================================== | |
| 331 # document | |
| 332 g = ProvDocument() | |
| 333 | |
| 334 # prefix ex <http://example.org/example/> | |
| 335 EX = Namespace("ex", "http://www.example.com/") | |
| 336 g.add_namespace(EX) | |
| 337 | |
| 338 # prefix alice <http://example.org/alice/> | |
| 339 # prefix bob <http://example.org/bob/> | |
| 340 g.add_namespace('alice', 'http://example.org/alice/') | |
| 341 g.add_namespace('bob', 'http://example.org/bob/') | |
| 342 | |
| 343 # entity(bob:bundle1, [prov:type='prov:Bundle']) | |
| 344 g.entity('bob:bundle1', {'prov:type': PROV['Bundle']}) | |
| 345 # wasGeneratedBy(bob:bundle1, -, 2012-05-24T10:30:00) | |
| 346 g.wasGeneratedBy('bob:bundle1', time='2012-05-24T10:30:00') | |
| 347 # agent(ex:Bob) | |
| 348 g.agent('ex:Bob') | |
| 349 # wasAttributedTo(bob:bundle1, ex:Bob) | |
| 350 g.wasAttributedTo('bob:bundle1', 'ex:Bob') | |
| 351 | |
| 352 # entity(alice:bundle2, [ prov:type='prov:Bundle' ]) | |
| 353 g.entity('alice:bundle2', {'prov:type': PROV['Bundle']}) | |
| 354 # wasGeneratedBy(alice:bundle2, -, 2012-05-25T11:15:00) | |
| 355 g.wasGeneratedBy('alice:bundle2', time='2012-05-25T11:15:00') | |
| 356 # agent(ex:Alice) | |
| 357 g.agent('ex:Alice') | |
| 358 # wasAttributedTo(alice:bundle2, ex:Alice) | |
| 359 g.wasAttributedTo('alice:bundle2', 'ex:Alice') | |
| 360 | |
| 361 # bundle bob:bundle1 | |
| 362 b1 = g.bundle('bob:bundle1') | |
| 363 # entity(ex:report1, [ prov:type="report", ex:version=1 ]) | |
| 364 b1.entity('ex:report1', {'prov:type': "report", 'ex:version': 1}) | |
| 365 # wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01) | |
| 366 b1.wasGeneratedBy('ex:report1', time='2012-05-24T10:00:01') | |
| 367 # endBundle | |
| 368 | |
| 369 # bundle alice:bundle2 | |
| 370 b2 = g.bundle('alice:bundle2') | |
| 371 # entity(ex:report1) | |
| 372 b2.entity('ex:report1') | |
| 373 # entity(ex:report2, [ prov:type="report", ex:version=2 ]) | |
| 374 b2.entity('ex:report2', {'prov:type': "report", 'ex:version': 2}) | |
| 375 # wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01) | |
| 376 b2.wasGeneratedBy('ex:report2', time='2012-05-25T11:00:01') | |
| 377 # wasDerivedFrom(ex:report2, ex:report1) | |
| 378 b2.wasDerivedFrom('ex:report2', 'ex:report1') | |
| 379 # endBundle | |
| 380 | |
| 381 # endDocument | |
| 382 return g | |
| 383 | |
| 384 | |
| 385 def bundles2(): | |
| 386 # https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles2.provn | |
| 387 #=========================================================================== | |
| 388 # document | |
| 389 g = ProvDocument() | |
| 390 | |
| 391 # prefix ex <http://example.org/example/> | |
| 392 g.add_namespace("ex", "http://www.example.com/") | |
| 393 | |
| 394 # prefix alice <http://example.org/alice/> | |
| 395 # prefix bob <http://example.org/bob/> | |
| 396 g.add_namespace('alice', 'http://example.org/alice/') | |
| 397 g.add_namespace('bob', 'http://example.org/bob/') | |
| 398 | |
| 399 # entity(bob:bundle4, [prov:type='prov:Bundle']) | |
| 400 # wasGeneratedBy(bob:bundle4, -, 2012-05-24T10:30:00) | |
| 401 # agent(ex:Bob) | |
| 402 # wasAttributedTo(bob:bundle4, ex:Bob) | |
| 403 g.entity('bob:bundle4', {'prov:type': PROV['Bundle']}) | |
| 404 g.wasGeneratedBy('bob:bundle4', time='2012-05-24T10:30:00') | |
| 405 g.agent('ex:Bob') | |
| 406 g.wasAttributedTo('bob:bundle4', 'ex:Bob') | |
| 407 | |
| 408 # entity(alice:bundle5, [ prov:type='prov:Bundle' ]) | |
| 409 # wasGeneratedBy(alice:bundle5, -, 2012-05-25T11:15:00) | |
| 410 # agent(ex:Alice) | |
| 411 # wasAttributedTo(alice:bundle5, ex:Alice) | |
| 412 g.entity('alice:bundle5', {'prov:type': PROV['Bundle']}) | |
| 413 g.wasGeneratedBy('alice:bundle5', time='2012-05-25T11:15:00') | |
| 414 g.agent('ex:Alice') | |
| 415 g.wasAttributedTo('alice:bundle5', 'ex:Alice') | |
| 416 | |
| 417 # bundle bob:bundle4 | |
| 418 # entity(ex:report1, [ prov:type="report", ex:version=1 ]) | |
| 419 # wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01) | |
| 420 # endBundle | |
| 421 b4 = g.bundle('bob:bundle4') | |
| 422 b4.entity('ex:report1', {'prov:type': "report", 'ex:version': 1}) | |
| 423 b4.wasGeneratedBy('ex:report1', time='2012-05-24T10:00:01') | |
| 424 | |
| 425 # bundle alice:bundle5 | |
| 426 # entity(ex:report1bis) | |
| 427 # mentionOf(ex:report1bis, ex:report1, bob:bundle4) | |
| 428 # entity(ex:report2, [ prov:type="report", ex:version=2 ]) | |
| 429 # wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01) | |
| 430 # wasDerivedFrom(ex:report2, ex:report1bis) | |
| 431 # endBundle | |
| 432 b5 = g.bundle('alice:bundle5') | |
| 433 b5.entity('ex:report1bis') | |
| 434 b5.mentionOf('ex:report1bis', 'ex:report1', 'bob:bundle4') | |
| 435 b5.entity('ex:report2', [('prov:type', "report"), ('ex:version', 2)]) | |
| 436 b5.wasGeneratedBy('ex:report2', time='2012-05-25T11:00:01') | |
| 437 b5.wasDerivedFrom('ex:report2', 'ex:report1bis') | |
| 438 | |
| 439 # endDocument | |
| 440 return g | |
| 441 | |
| 442 | |
| 443 def collections(): | |
| 444 g = ProvDocument() | |
| 445 ex = Namespace('ex', 'http://example.org/') | |
| 446 | |
| 447 c1 = g.collection(ex['c1']) | |
| 448 e1 = g.entity('ex:e1') | |
| 449 g.hadMember(c1, e1) | |
| 450 | |
| 451 return g | |
| 452 | |
| 453 | |
| 454 def datatypes(): | |
| 455 g = ProvDocument() | |
| 456 ex = Namespace('ex', 'http://example.org/') | |
| 457 g.add_namespace(ex) | |
| 458 | |
| 459 attributes = { | |
| 460 'ex:int': 100, | |
| 461 'ex:float': 100.123456, | |
| 462 'ex:long': 123456789000, | |
| 463 'ex:bool': True, | |
| 464 'ex:str': 'Some string', | |
| 465 'ex:unicode': u'Some unicode string with accents: Huỳnh Trung Đông', | |
| 466 'ex:timedate': datetime.datetime(2012, 12, 12, 14, 7, 48), | |
| 467 'ex:intstr': Literal("PROV Internationalized string", PROV["InternationalizedString"], "en"), | |
| 468 } | |
| 469 multiline = """Line1 | |
| 470 Line2 | |
| 471 Line3""" | |
| 472 attributes['ex:multi-line'] = multiline | |
| 473 g.entity('ex:e1', attributes) | |
| 474 return g | |
| 475 | |
| 476 | |
| 477 def long_literals(): | |
| 478 g = ProvDocument() | |
| 479 | |
| 480 long_uri = "http://Lorem.ipsum/dolor/sit/amet/consectetur/adipiscing/elit/Quisque/vel/sollicitudin/felis/nec/" \ | |
| 481 "venenatis/massa/Aenean/lectus/arcu/sagittis/sit/amet/nisl/nec/varius/eleifend/sem/In/hac/habitasse/" \ | |
| 482 "platea/dictumst/Aliquam/eget/fermentum/enim/Curabitur/auctor/elit/non/ipsum/interdum/at/orci/aliquam/" | |
| 483 ex = Namespace('ex', long_uri) | |
| 484 g.add_namespace(ex) | |
| 485 | |
| 486 g.entity('ex:e1', { | |
| 487 'prov:label': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pellentesque luctus nulla vel ' | |
| 488 'ullamcorper. Donec sit amet ligula sit amet lorem pretium rhoncus vel vel lorem. Sed at ' | |
| 489 'consequat metus, eget eleifend massa. Fusce a facilisis turpis. Lorem volutpat.' | |
| 490 }) | |
| 491 | |
| 492 return g | |
| 493 | |
| 494 tests = [ | |
| 495 ('Bundle1', bundles1), | |
| 496 ('Bundle2', bundles2), | |
| 497 ('Primer', primer_example), | |
| 498 ('W3C Publication 1', w3c_publication_1), | |
| 499 ('W3C Publication 2', w3c_publication_2), | |
| 500 ('collections', collections), | |
| 501 ('datatypes', datatypes), | |
| 502 ('Long literals', long_literals), | |
| 503 ] |
