Skip to content

Commit a540949

Browse files
committed
update ro-crate context from1.2-DRAFT to 1.2 and fix bioschemas property urls
1 parent 2791d96 commit a540949

6 files changed

Lines changed: 3023 additions & 2942 deletions

File tree

src/ARCtrl/ROCrateIO.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module ARC =
2222
let id = "ro-crate-metadata.json"
2323
let schemaType = ResizeArray ["http://schema.org/CreativeWork"]
2424
let node = LDNode(id, schemaType)
25-
node.SetProperty("http://purl.org/dc/terms/conformsTo", LDRef("https://w3id.org/ro/crate/1.1"))
25+
node.SetProperty("http://purl.org/dc/terms/conformsTo", LDRef("https://w3id.org/ro/crate/1.2"))
2626
node.SetProperty("http://schema.org/about", LDRef("./"))
2727
node
2828

@@ -51,7 +51,7 @@ module ARC =
5151
LDDataset.setSDDatePublishedAsDateTime(isa, System.DateTime.Now)
5252
LDDataset.setLicenseAsCreativeWork(isa, license)
5353
let graph = isa.Flatten()
54-
let context = LDContext(baseContexts=ResizeArray[Context.initV1_1();Context.initBioschemasContext()])
54+
let context = LDContext(baseContexts=ResizeArray[Context.initV1_2();Context.initBioschemasContext()])
5555
graph.SetContext(context)
5656
graph.AddNode(ROCrate.metadataFileDescriptor)
5757
graph.Compact_InPlace()

src/Json/ROCrate/LDContext.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ module LDContext =
3131
Error fst
3232
elif helpers.isString value then
3333
let s = helpers.asString value
34-
if s = Context.proxy_V1_2DRAFT then
35-
Ok (Context.initV1_2DRAFT())
34+
if s = Context.proxy_V1_2DRAFT || s = Context.proxy_V1_2 then
35+
Ok (Context.initV1_2())
3636
elif s = Context.proxy_V1_1 then
3737
Ok (Context.initV1_1())
3838
else
@@ -48,6 +48,7 @@ module LDContext =
4848
let rec encoder (ctx: LDContext) =
4949
match ctx.Name with
5050
| Some Context.proxy_V1_2DRAFT -> Encode.string Context.proxy_V1_2DRAFT
51+
| Some Context.proxy_V1_2 -> Encode.string Context.proxy_V1_2
5152
| Some Context.proxy_V1_1 -> Encode.string Context.proxy_V1_1
5253
| _ ->
5354
let mappings =

src/ROCrate/LDTypes/ComputationalWorkflow.fs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ type LDComputationalWorkflow =
1010

1111
static member schemaType = "https://bioschemas.org/ComputationalWorkflow"
1212
// Recommended properties
13-
static member input = "https://bioschemas.org/input"
14-
static member output = "https://bioschemas.org/output"
13+
static member input = "https://bioschemas.org/properties/input"
14+
static member inputDeprecated = "https://bioschemas.org/input"
15+
static member output = "https://bioschemas.org/properties/output"
16+
static member outputDeprecated = "https://bioschemas.org/output"
1517
static member creator = "http://schema.org/creator"
1618
static member dateCreated = "http://schema.org/dateCreated"
1719
static member license = "http://schema.org/license"
@@ -28,21 +30,41 @@ type LDComputationalWorkflow =
2830

2931
// Getters and setters for recommended properties
3032
static member getInputs(cw : LDNode, ?graph : LDGraph, ?context : LDContext) =
31-
cw.GetPropertyNodes(LDComputationalWorkflow.input, ?graph = graph, ?context = context)
33+
let l = cw.GetPropertyNodes(LDComputationalWorkflow.input, ?graph = graph, ?context = context)
34+
if l.Count = 0 then
35+
// Try deprecated property
36+
cw.GetPropertyNodes(LDComputationalWorkflow.inputDeprecated, ?graph = graph, ?context = context)
37+
else
38+
l
3239

3340
static member getInputsAsFormalParameters(cw : LDNode, ?graph : LDGraph, ?context : LDContext) =
3441
let filter ldObject context = LDFormalParameter.validate(ldObject, ?context = context)
35-
cw.GetPropertyNodes(LDComputationalWorkflow.input, filter = filter, ?graph = graph, ?context = context)
42+
let l = cw.GetPropertyNodes(LDComputationalWorkflow.input, filter = filter, ?graph = graph, ?context = context)
43+
if l.Count = 0 then
44+
// Try deprecated property
45+
cw.GetPropertyNodes(LDComputationalWorkflow.inputDeprecated, filter = filter, ?graph = graph, ?context = context)
46+
else
47+
l
3648

3749
static member setInputs(cw : LDNode, inputs : ResizeArray<LDNode>, ?context : LDContext) =
3850
cw.SetProperty(LDComputationalWorkflow.input, inputs, ?context = context)
3951

4052
static member getOutputs(cw : LDNode, ?graph : LDGraph, ?context : LDContext) =
41-
cw.GetPropertyNodes(LDComputationalWorkflow.output, ?graph = graph, ?context = context)
53+
let l = cw.GetPropertyNodes(LDComputationalWorkflow.output, ?graph = graph, ?context = context)
54+
if l.Count = 0 then
55+
// Try deprecated property
56+
cw.GetPropertyNodes(LDComputationalWorkflow.outputDeprecated, ?graph = graph, ?context = context)
57+
else
58+
l
4259

4360
static member getOutputsAsFormalParameter(cw : LDNode, ?graph : LDGraph, ?context : LDContext) =
4461
let filter ldObject context = LDFormalParameter.validate(ldObject, ?context = context)
45-
cw.GetPropertyNodes(LDComputationalWorkflow.output, filter = filter, ?graph = graph, ?context = context)
62+
let l = cw.GetPropertyNodes(LDComputationalWorkflow.output, filter = filter, ?graph = graph, ?context = context)
63+
if l.Count = 0 then
64+
// Try deprecated property
65+
cw.GetPropertyNodes(LDComputationalWorkflow.outputDeprecated, filter = filter, ?graph = graph, ?context = context)
66+
else
67+
l
4668

4769
static member setOutputs(cw : LDNode, outputs : ResizeArray<LDNode>, ?context : LDContext) =
4870
cw.SetProperty(LDComputationalWorkflow.output, outputs, ?context = context)
@@ -69,15 +91,13 @@ type LDComputationalWorkflow =
6991
match cw.TryGetPropertyAsSingleton(LDComputationalWorkflow.name, ?context = context) with
7092
| Some (:? string as n) -> Some n
7193
| _ -> None
72-
73-
94+
7495
static member getNameAsString(cw : LDNode, ?context : LDContext) =
7596
match cw.TryGetPropertyAsSingleton(LDComputationalWorkflow.name, ?context = context) with
7697
| Some (:? string as n) -> n
7798
| Some _ -> failwith $"property `name` of object with @id `{cw.Id}` was not a string"
7899
| _ -> failwith $"Could not access property `name` of object with @id `{cw.Id}`"
79100

80-
81101
static member setNameAsString(cw : LDNode, name : string, ?context : LDContext) =
82102
cw.SetProperty(LDComputationalWorkflow.name, name, ?context = context)
83103

src/ROCrate/LDTypes/LabProcess.fs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ type LDLabProcess =
1818

1919
static member result = "http://schema.org/result"
2020

21-
static member executesLabProtocol = "https://bioschemas.org/executesLabProtocol"
21+
static member executesLabProtocol = "https://bioschemas.org/properties/executesLabProtocol"
2222

23-
static member parameterValue = "https://bioschemas.org/parameterValue"
23+
static member executesLabProtocolDeprecated = "https://bioschemas.org/executesLabProtocol"
24+
25+
static member parameterValue = "https://bioschemas.org/properties/parameterValue"
26+
27+
static member parameterValueDeprecated = "https://bioschemas.org/parameterValue"
2428

2529
static member endTime = "http://schema.org/endTime"
2630

@@ -88,14 +92,22 @@ type LDLabProcess =
8892
let filter ldObject context = LDLabProtocol.validate(ldObject, ?context = context)
8993
match lp.TryGetPropertyAsSingleNode(LDLabProcess.executesLabProtocol, ?graph = graph, ?context = context) with
9094
| Some l when filter l context -> Some l
91-
| _ -> None
95+
| _ ->
96+
match lp.TryGetPropertyAsSingleNode(LDLabProcess.executesLabProtocolDeprecated, ?graph = graph, ?context = context) with
97+
| Some l when filter l context -> Some l
98+
| _ -> None
9299

93100
static member setExecutesLabProtocol(lp : LDNode, executesLabProtocol : LDNode, ?context : LDContext) =
94101
lp.SetProperty(LDLabProcess.executesLabProtocol, executesLabProtocol, ?context = context)
95102

96103
static member getParameterValues(lp : LDNode, ?graph : LDGraph, ?context : LDContext) =
97104
let filter ldObject context = LDPropertyValue.validate(ldObject, ?context = context)
98-
lp.GetPropertyNodes(LDLabProcess.parameterValue, filter = filter, ?graph = graph, ?context = context)
105+
let l = lp.GetPropertyNodes(LDLabProcess.parameterValue, filter = filter, ?graph = graph, ?context = context)
106+
if l.Count = 0 then
107+
// Try deprecated property
108+
lp.GetPropertyNodes(LDLabProcess.parameterValueDeprecated, filter = filter, ?graph = graph, ?context = context)
109+
else
110+
l
99111

100112
static member setParameterValues(lp : LDNode, parameterValues : ResizeArray<LDNode>, ?context : LDContext) =
101113
lp.SetProperty(LDLabProcess.parameterValue, parameterValues, ?context = context)

src/ROCrate/LDTypes/LabProtocol.fs

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,29 @@ type LDLabProtocol =
1111

1212
static member description = "http://schema.org/description"
1313

14-
static member intendedUse = "https://bioschemas.org/intendedUse"
15-
1614
static member name = "http://schema.org/name"
1715

18-
static member comment = "http://schema.org/comment"
16+
static member computationalTool = "https://bioschemas.org/properties/computationalTool"
17+
18+
static member computationalToolDeprecated = "https://bioschemas.org/computationalTool"
19+
20+
static member labEquipment = "https://bioschemas.org/properties/labEquipment"
21+
22+
static member labEquipmentDeprecated = "https://bioschemas.org/labEquipment"
1923

20-
static member computationalTool = "https://bioschemas.org/computationalTool"
24+
static member reagent = "https://bioschemas.org/properties/reagent"
2125

22-
static member labEquipment = "https://bioschemas.org/labEquipment"
26+
static member reagentDeprecated = "https://bioschemas.org/reagent"
2327

24-
static member reagent = "https://bioschemas.org/reagent"
28+
static member intendedUse = "https://bioschemas.org/properties/intendedUse"
29+
30+
static member intendedUseDeprecated = "https://bioschemas.org/intendedUse"
2531

2632
static member url = "http://schema.org/url"
2733

2834
static member version = "http://schema.org/version"
2935

36+
static member comment = "http://schema.org/comment"
3037

3138
static member tryGetDescriptionAsString(lp : LDNode, ?context : LDContext) =
3239
match lp.TryGetPropertyAsSingleton(LDLabProtocol.description, ?context = context) with
@@ -39,7 +46,10 @@ type LDLabProtocol =
3946
static member tryGetIntendedUseAsString(lp : LDNode, ?context : LDContext) =
4047
match lp.TryGetPropertyAsSingleton(LDLabProtocol.intendedUse, ?context = context) with
4148
| Some (:? string as iu) -> Some iu
42-
| _ -> None
49+
| _ ->
50+
match lp.TryGetPropertyAsSingleton(LDLabProtocol.intendedUseDeprecated, ?context = context) with
51+
| Some (:? string as iu) -> Some iu
52+
| _ -> None
4353

4454
static member setIntendedUseAsString(lp : LDNode, intendedUse : string, ?context : LDContext) =
4555
lp.SetProperty(LDLabProtocol.intendedUse, intendedUse, ?context = context)
@@ -48,7 +58,10 @@ type LDLabProtocol =
4858
let filter ldObject context = LDDefinedTerm.validate(ldObject, ?context = context)
4959
match lp.TryGetPropertyAsSingleNode(LDLabProtocol.intendedUse, ?graph = graph, ?context = context) with
5060
| Some iu when filter iu context -> Some iu
51-
| _ -> None
61+
| _ ->
62+
match lp.TryGetPropertyAsSingleNode(LDLabProtocol.intendedUseDeprecated, ?graph = graph, ?context = context) with
63+
| Some iu when filter iu context -> Some iu
64+
| _ -> None
5265

5366
static member setIntendedUseAsDefinedTerm(lp : LDNode, intendedUse : LDNode, ?context : LDContext) =
5467
lp.SetProperty(LDLabProtocol.intendedUse, intendedUse, ?context = context)
@@ -74,19 +87,34 @@ type LDLabProtocol =
7487
lp.SetProperty(LDLabProtocol.comment, comments, ?context = context)
7588

7689
static member getComputationalTools(lp : LDNode, ?graph : LDGraph, ?context : LDContext) =
77-
lp.GetPropertyNodes(LDLabProtocol.computationalTool, ?graph = graph, ?context = context)
90+
let l = lp.GetPropertyNodes(LDLabProtocol.computationalTool, ?graph = graph, ?context = context)
91+
if l.Count = 0 then
92+
// try deprecated property
93+
lp.GetPropertyNodes(LDLabProtocol.computationalToolDeprecated, ?graph = graph, ?context = context)
94+
else
95+
l
7896

7997
static member setComputationalTools(lp : LDNode, computationalTools : ResizeArray<LDNode>, ?context : LDContext) =
8098
lp.SetProperty(LDLabProtocol.computationalTool, computationalTools, ?context = context)
8199

82100
static member getLabEquipments(lp : LDNode, ?graph : LDGraph, ?context : LDContext) =
83-
lp.GetPropertyNodes(LDLabProtocol.labEquipment, ?graph = graph, ?context = context)
101+
let l = lp.GetPropertyNodes(LDLabProtocol.labEquipment, ?graph = graph, ?context = context)
102+
if l.Count = 0 then
103+
// try deprecated property
104+
lp.GetPropertyNodes(LDLabProtocol.labEquipmentDeprecated, ?graph = graph, ?context = context)
105+
else
106+
l
84107

85108
static member setLabEquipments(lp : LDNode, labEquipments : ResizeArray<LDNode>, ?context : LDContext) =
86109
lp.SetProperty(LDLabProtocol.labEquipment, labEquipments, ?context = context)
87110

88111
static member getReagents(lp : LDNode, ?graph : LDGraph, ?context : LDContext) =
89-
lp.GetPropertyNodes(LDLabProtocol.reagent, ?graph = graph, ?context = context)
112+
let l = lp.GetPropertyNodes(LDLabProtocol.reagent, ?graph = graph, ?context = context)
113+
if l.Count = 0 then
114+
// try deprecated property
115+
lp.GetPropertyNodes(LDLabProtocol.reagentDeprecated, ?graph = graph, ?context = context)
116+
else
117+
l
90118

91119
static member setReagents(lp : LDNode, reagents : ResizeArray<LDNode>, ?context : LDContext) =
92120
lp.SetProperty(LDLabProtocol.reagent, reagents, ?context = context)

0 commit comments

Comments
 (0)