@nfdi4plants/arctrl 2.0.0-alpha.7 → 2.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,65 +14,86 @@ import { unwrap, defaultArg } from "../../fable_modules/fable-library-js.4.16.0/
14
14
  import { Decode_uri } from "../Decode.js";
15
15
  import { Protocol } from "../../Core/Process/Protocol.js";
16
16
  import { ProtocolParameter_ISAJson_decoder, ProtocolParameter_ISAJson_encoder } from "./ProtocolParameter.js";
17
+ import { encode } from "../IDTable.js";
17
18
  import { fromString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Decode.fs.js";
18
19
  import { toString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Encode.fs.js";
19
20
 
20
21
  export function Protocol_ROCrate_genID(studyName, assayName, processName, p) {
21
- const matchValue = p.Uri;
22
- if (matchValue == null) {
23
- const matchValue_1 = p.Name;
24
- if (matchValue_1 == null) {
25
- let matchResult, an, pn, sn, pn_1, sn_1, pn_2;
26
- if (studyName == null) {
27
- if (assayName == null) {
28
- if (processName != null) {
29
- matchResult = 2;
30
- pn_2 = processName;
22
+ const matchValue = p.ID;
23
+ let matchResult, id_1;
24
+ if (matchValue != null) {
25
+ if (matchValue !== "") {
26
+ matchResult = 0;
27
+ id_1 = matchValue;
28
+ }
29
+ else {
30
+ matchResult = 1;
31
+ }
32
+ }
33
+ else {
34
+ matchResult = 1;
35
+ }
36
+ switch (matchResult) {
37
+ case 0:
38
+ return id_1;
39
+ default: {
40
+ const matchValue_1 = p.Uri;
41
+ if (matchValue_1 == null) {
42
+ const matchValue_2 = p.Name;
43
+ if (matchValue_2 == null) {
44
+ let matchResult_1, an, pn, sn, pn_1, sn_1, pn_2;
45
+ if (studyName == null) {
46
+ if (assayName == null) {
47
+ if (processName != null) {
48
+ matchResult_1 = 2;
49
+ pn_2 = processName;
50
+ }
51
+ else {
52
+ matchResult_1 = 3;
53
+ }
54
+ }
55
+ else {
56
+ matchResult_1 = 3;
57
+ }
58
+ }
59
+ else if (assayName == null) {
60
+ if (processName != null) {
61
+ matchResult_1 = 1;
62
+ pn_1 = processName;
63
+ sn_1 = studyName;
64
+ }
65
+ else {
66
+ matchResult_1 = 3;
67
+ }
68
+ }
69
+ else if (processName != null) {
70
+ matchResult_1 = 0;
71
+ an = assayName;
72
+ pn = processName;
73
+ sn = studyName;
31
74
  }
32
75
  else {
33
- matchResult = 3;
76
+ matchResult_1 = 3;
77
+ }
78
+ switch (matchResult_1) {
79
+ case 0:
80
+ return (((("#Protocol_" + replace(sn, " ", "_")) + "_") + replace(an, " ", "_")) + "_") + replace(pn, " ", "_");
81
+ case 1:
82
+ return (("#Protocol_" + replace(sn_1, " ", "_")) + "_") + replace(pn_1, " ", "_");
83
+ case 2:
84
+ return "#Protocol_" + replace(pn_2, " ", "_");
85
+ default:
86
+ return "#EmptyProtocol";
34
87
  }
35
88
  }
36
89
  else {
37
- matchResult = 3;
38
- }
39
- }
40
- else if (assayName == null) {
41
- if (processName != null) {
42
- matchResult = 1;
43
- pn_1 = processName;
44
- sn_1 = studyName;
45
- }
46
- else {
47
- matchResult = 3;
90
+ return "#Protocol_" + replace(matchValue_2, " ", "_");
48
91
  }
49
92
  }
50
- else if (processName != null) {
51
- matchResult = 0;
52
- an = assayName;
53
- pn = processName;
54
- sn = studyName;
55
- }
56
93
  else {
57
- matchResult = 3;
58
- }
59
- switch (matchResult) {
60
- case 0:
61
- return (((("#Protocol_" + replace(sn, " ", "_")) + "_") + replace(an, " ", "_")) + "_") + replace(pn, " ", "_");
62
- case 1:
63
- return (("#Protocol_" + replace(sn_1, " ", "_")) + "_") + replace(pn_1, " ", "_");
64
- case 2:
65
- return "#Protocol_" + replace(pn_2, " ", "_");
66
- default:
67
- return "#EmptyProtocol";
94
+ return matchValue_1;
68
95
  }
69
96
  }
70
- else {
71
- return "#Protocol_" + replace(matchValue_1, " ", "_");
72
- }
73
- }
74
- else {
75
- return matchValue;
76
97
  }
77
98
  }
78
99
 
@@ -94,8 +115,8 @@ export const Protocol_ROCrate_decoder = object((get$) => {
94
115
  return new Protocol((objectArg_3 = get$.Optional, objectArg_3.Field("@id", Decode_uri)), (objectArg_4 = get$.Optional, objectArg_4.Field("name", string)), (objectArg_5 = get$.Optional, objectArg_5.Field("protocolType", OntologyAnnotation_ROCrate_decoderDefinedTerm)), (objectArg_6 = get$.Optional, objectArg_6.Field("description", string)), (objectArg_7 = get$.Optional, objectArg_7.Field("uri", Decode_uri)), (objectArg_8 = get$.Optional, objectArg_8.Field("version", string)), void 0, components, (arg_19 = list_5(Comment_ROCrate_decoder), (objectArg_9 = get$.Optional, objectArg_9.Field("comments", arg_19))));
95
116
  });
96
117
 
97
- export function Protocol_ISAJson_encoder(oa) {
98
- return new Json(5, [choose((tupledArg) => {
118
+ export function Protocol_ISAJson_encoder(studyName, assayName, processName, idMap, oa) {
119
+ const f = (oa_1) => (new Json(5, [choose((tupledArg) => {
99
120
  const v = tupledArg[1];
100
121
  if (equals(v, new Json(3, []))) {
101
122
  return void 0;
@@ -103,7 +124,13 @@ export function Protocol_ISAJson_encoder(oa) {
103
124
  else {
104
125
  return [tupledArg[0], v];
105
126
  }
106
- }, ofArray([tryInclude("@id", (value) => (new Json(0, [value])), oa.ID), tryInclude("name", (value_2) => (new Json(0, [value_2])), oa.Name), tryInclude("protocolType", OntologyAnnotation_ISAJson_encoder, oa.ProtocolType), tryInclude("description", (value_4) => (new Json(0, [value_4])), oa.Description), tryInclude("uri", (value_6) => (new Json(0, [value_6])), oa.Uri), tryInclude("version", (value_8) => (new Json(0, [value_8])), oa.Version), tryIncludeListOpt("parameters", ProtocolParameter_ISAJson_encoder, oa.Parameters), tryIncludeListOpt("components", Component_ISAJson_encoder, oa.Components), tryIncludeListOpt("comments", Comment_ISAJson_encoder, oa.Comments)]))]);
127
+ }, ofArray([tryInclude("@id", (value) => (new Json(0, [value])), Protocol_ROCrate_genID(studyName, assayName, processName, oa_1)), tryInclude("name", (value_2) => (new Json(0, [value_2])), oa_1.Name), tryInclude("protocolType", (oa_2) => OntologyAnnotation_ISAJson_encoder(idMap, oa_2), oa_1.ProtocolType), tryInclude("description", (value_4) => (new Json(0, [value_4])), oa_1.Description), tryInclude("uri", (value_6) => (new Json(0, [value_6])), oa_1.Uri), tryInclude("version", (value_8) => (new Json(0, [value_8])), oa_1.Version), tryIncludeListOpt("parameters", (value_10) => ProtocolParameter_ISAJson_encoder(idMap, value_10), oa_1.Parameters), tryIncludeListOpt("components", (c) => Component_ISAJson_encoder(idMap, c), oa_1.Components), tryIncludeListOpt("comments", (comment) => Comment_ISAJson_encoder(idMap, comment), oa_1.Comments)]))]));
128
+ if (idMap != null) {
129
+ return encode((p_1) => Protocol_ROCrate_genID(studyName, assayName, processName, p_1), f, oa, idMap);
130
+ }
131
+ else {
132
+ return f(oa);
133
+ }
107
134
  }
108
135
 
109
136
  export const Protocol_ISAJson_decoder = object((get$) => {
@@ -121,15 +148,16 @@ export function ARCtrl_Process_Protocol__Protocol_fromISAJsonString_Static_Z721C
121
148
  }
122
149
  }
123
150
 
124
- export function ARCtrl_Process_Protocol__Protocol_toISAJsonString_Static_71136F3F(spaces) {
151
+ export function ARCtrl_Process_Protocol__Protocol_toISAJsonString_Static_Z3B036AA(spaces, useIDReferencing) {
152
+ const idMap = defaultArg(useIDReferencing, false) ? (new Map([])) : void 0;
125
153
  return (f) => {
126
- const value = Protocol_ISAJson_encoder(f);
154
+ const value = Protocol_ISAJson_encoder(void 0, void 0, void 0, idMap, f);
127
155
  return toString(defaultSpaces(spaces), value);
128
156
  };
129
157
  }
130
158
 
131
159
  export function ARCtrl_Process_Protocol__Protocol_ToISAJsonString_71136F3F(this$, spaces) {
132
- return ARCtrl_Process_Protocol__Protocol_toISAJsonString_Static_71136F3F(unwrap(spaces))(this$);
160
+ return ARCtrl_Process_Protocol__Protocol_toISAJsonString_Static_Z3B036AA(spaces)(this$);
133
161
  }
134
162
 
135
163
  export function ARCtrl_Process_Protocol__Protocol_fromROCrateString_Static_Z721C83C5(s) {
@@ -1,8 +1,9 @@
1
- import { singleton, choose } from "../../fable_modules/fable-library-js.4.16.0/List.js";
1
+ import { OntologyAnnotation_ISAJson_decoder, OntologyAnnotation_ISAJson_encoder, OntologyAnnotation_ROCrate_genID } from "../OntologyAnnotation.js";
2
+ import { ofArray, choose } from "../../fable_modules/fable-library-js.4.16.0/List.js";
2
3
  import { equals } from "../../fable_modules/fable-library-js.4.16.0/Util.js";
3
4
  import { Json } from "../../fable_modules/Thoth.Json.Core.0.2.1/Types.fs.js";
4
5
  import { defaultSpaces, tryInclude } from "../Encode.js";
5
- import { OntologyAnnotation_ISAJson_decoder, OntologyAnnotation_ISAJson_encoder } from "../OntologyAnnotation.js";
6
+ import { encode } from "../IDTable.js";
6
7
  import { object } from "../../fable_modules/Thoth.Json.Core.0.2.1/Decode.fs.js";
7
8
  import { ProtocolParameter } from "../../Core/Process/ProtocolParameter.js";
8
9
  import { fromString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Decode.fs.js";
@@ -10,8 +11,18 @@ import { printf, toText } from "../../fable_modules/fable-library-js.4.16.0/Stri
10
11
  import { toString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Encode.fs.js";
11
12
  import { unwrap } from "../../fable_modules/fable-library-js.4.16.0/Option.js";
12
13
 
13
- export function ProtocolParameter_ISAJson_encoder(value) {
14
- return new Json(5, [choose((tupledArg) => {
14
+ export function ProtocolParameter_ISAJson_genID(p) {
15
+ const matchValue = p.ParameterName;
16
+ if (matchValue == null) {
17
+ return "#EmptyProtocolParameter";
18
+ }
19
+ else {
20
+ return `#ProtocolParameter/${OntologyAnnotation_ROCrate_genID(matchValue)}`;
21
+ }
22
+ }
23
+
24
+ export function ProtocolParameter_ISAJson_encoder(idMap, value) {
25
+ const f = (value_1) => (new Json(5, [choose((tupledArg) => {
15
26
  const v = tupledArg[1];
16
27
  if (equals(v, new Json(3, []))) {
17
28
  return void 0;
@@ -19,7 +30,13 @@ export function ProtocolParameter_ISAJson_encoder(value) {
19
30
  else {
20
31
  return [tupledArg[0], v];
21
32
  }
22
- }, singleton(tryInclude("parameterName", OntologyAnnotation_ISAJson_encoder, value.ParameterName)))]);
33
+ }, ofArray([tryInclude("@id", (value_2) => (new Json(0, [value_2])), ProtocolParameter_ISAJson_genID(value_1)), tryInclude("parameterName", (oa) => OntologyAnnotation_ISAJson_encoder(idMap, oa), value_1.ParameterName)]))]));
34
+ if (idMap != null) {
35
+ return encode(ProtocolParameter_ISAJson_genID, f, value, idMap);
36
+ }
37
+ else {
38
+ return f(value);
39
+ }
23
40
  }
24
41
 
25
42
  export const ProtocolParameter_ISAJson_decoder = object((get$) => {
@@ -39,7 +56,7 @@ export function ARCtrl_Process_ProtocolParameter__ProtocolParameter_fromISAJsonS
39
56
 
40
57
  export function ARCtrl_Process_ProtocolParameter__ProtocolParameter_toISAJsonString_Static_71136F3F(spaces) {
41
58
  return (v) => {
42
- const value = ProtocolParameter_ISAJson_encoder(v);
59
+ const value = ProtocolParameter_ISAJson_encoder(void 0, v);
43
60
  return toString(defaultSpaces(spaces), value);
44
61
  };
45
62
  }
@@ -14,6 +14,7 @@ import { Option_fromValueWithDefault } from "../../Core/Helper/Collections.js";
14
14
  import { Decode_objectNoAdditionalProperties, Decode_uri } from "../Decode.js";
15
15
  import { Source_ISAJson_decoder, Source_ISAJson_encoder, Source_ROCrate_decoder } from "./Source.js";
16
16
  import { Sample } from "../../Core/Process/Sample.js";
17
+ import { encode } from "../IDTable.js";
17
18
  import { fromString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Decode.fs.js";
18
19
  import { toString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Encode.fs.js";
19
20
 
@@ -79,8 +80,8 @@ export const Sample_ROCrate_decoder = object((get$) => {
79
80
  return new Sample((objectArg_1 = get$.Optional, objectArg_1.Field("@id", Decode_uri)), (objectArg_2 = get$.Optional, objectArg_2.Field("name", string)), patternInput[0], patternInput[1], (arg_7 = list_6(Source_ROCrate_decoder), (objectArg_3 = get$.Optional, objectArg_3.Field("derivesFrom", arg_7))));
80
81
  });
81
82
 
82
- export function Sample_ISAJson_encoder(oa) {
83
- return new Json(5, [choose((tupledArg) => {
83
+ export function Sample_ISAJson_encoder(idMap, oa) {
84
+ const f = (oa_1) => (new Json(5, [choose((tupledArg) => {
84
85
  const v = tupledArg[1];
85
86
  if (equals(v, new Json(3, []))) {
86
87
  return void 0;
@@ -88,7 +89,13 @@ export function Sample_ISAJson_encoder(oa) {
88
89
  else {
89
90
  return [tupledArg[0], v];
90
91
  }
91
- }, ofArray([tryInclude("@id", (value) => (new Json(0, [value])), oa.ID), tryInclude("name", (value_2) => (new Json(0, [value_2])), oa.Name), tryIncludeListOpt("characteristics", MaterialAttributeValue_ISAJson_encoder, oa.Characteristics), tryIncludeListOpt("factorValues", FactorValue_ISAJson_encoder, oa.FactorValues), tryIncludeListOpt("derivesFrom", Source_ISAJson_encoder, oa.DerivesFrom)]))]);
92
+ }, ofArray([tryInclude("@id", (value) => (new Json(0, [value])), Sample_ROCrate_genID(oa_1)), tryInclude("name", (value_2) => (new Json(0, [value_2])), oa_1.Name), tryIncludeListOpt("characteristics", (oa_2) => MaterialAttributeValue_ISAJson_encoder(idMap, oa_2), oa_1.Characteristics), tryIncludeListOpt("factorValues", (fv) => FactorValue_ISAJson_encoder(idMap, fv), oa_1.FactorValues), tryIncludeListOpt("derivesFrom", (oa_3) => Source_ISAJson_encoder(idMap, oa_3), oa_1.DerivesFrom)]))]));
93
+ if (idMap != null) {
94
+ return encode(Sample_ROCrate_genID, f, oa, idMap);
95
+ }
96
+ else {
97
+ return f(oa);
98
+ }
92
99
  }
93
100
 
94
101
  export const Sample_ISAJson_allowedFields = ofArray(["@id", "name", "characteristics", "factorValues", "derivesFrom", "@type", "@context"]);
@@ -108,15 +115,16 @@ export function ARCtrl_Process_Sample__Sample_fromISAJsonString_Static_Z721C83C5
108
115
  }
109
116
  }
110
117
 
111
- export function ARCtrl_Process_Sample__Sample_toISAJsonString_Static_71136F3F(spaces) {
118
+ export function ARCtrl_Process_Sample__Sample_toISAJsonString_Static_Z3B036AA(spaces, useIDReferencing) {
119
+ const idMap = defaultArg(useIDReferencing, false) ? (new Map([])) : void 0;
112
120
  return (f) => {
113
- const value = Sample_ISAJson_encoder(f);
114
- return toString(defaultSpaces(spaces), value);
121
+ const value_1 = Sample_ISAJson_encoder(idMap, f);
122
+ return toString(defaultSpaces(spaces), value_1);
115
123
  };
116
124
  }
117
125
 
118
- export function ARCtrl_Process_Sample__Sample_ToISAJsonString_71136F3F(this$, spaces) {
119
- return ARCtrl_Process_Sample__Sample_toISAJsonString_Static_71136F3F(unwrap(spaces))(this$);
126
+ export function ARCtrl_Process_Sample__Sample_ToISAJsonString_Z3B036AA(this$, spaces, useIDReferencing) {
127
+ return ARCtrl_Process_Sample__Sample_toISAJsonString_Static_Z3B036AA(unwrap(spaces), unwrap(useIDReferencing))(this$);
120
128
  }
121
129
 
122
130
  export function ARCtrl_Process_Sample__Sample_fromROCrateString_Static_Z721C83C5(s) {
@@ -10,9 +10,10 @@ import { context_jsonvalue } from "../context/rocrate/isa_source_context.js";
10
10
  import { list as list_2, string, object } from "../../fable_modules/Thoth.Json.Core.0.2.1/Decode.fs.js";
11
11
  import { Decode_objectNoAdditionalProperties, Decode_uri } from "../Decode.js";
12
12
  import { Source } from "../../Core/Process/Source.js";
13
+ import { encode } from "../IDTable.js";
13
14
  import { fromString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Decode.fs.js";
15
+ import { unwrap, defaultArg } from "../../fable_modules/fable-library-js.4.16.0/Option.js";
14
16
  import { toString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Encode.fs.js";
15
- import { unwrap } from "../../fable_modules/fable-library-js.4.16.0/Option.js";
16
17
 
17
18
  export function Source_ROCrate_genID(s) {
18
19
  const matchValue = s.ID;
@@ -47,8 +48,8 @@ export const Source_ROCrate_decoder = object((get$) => {
47
48
  return new Source((objectArg = get$.Optional, objectArg.Field("@id", Decode_uri)), (objectArg_1 = get$.Optional, objectArg_1.Field("name", string)), (arg_5 = list_2(MaterialAttributeValue_ROCrate_decoder), (objectArg_2 = get$.Optional, objectArg_2.Field("characteristics", arg_5))));
48
49
  });
49
50
 
50
- export function Source_ISAJson_encoder(oa) {
51
- return new Json(5, [choose((tupledArg) => {
51
+ export function Source_ISAJson_encoder(idMap, oa) {
52
+ const f = (oa_1) => (new Json(5, [choose((tupledArg) => {
52
53
  const v = tupledArg[1];
53
54
  if (equals(v, new Json(3, []))) {
54
55
  return void 0;
@@ -56,7 +57,13 @@ export function Source_ISAJson_encoder(oa) {
56
57
  else {
57
58
  return [tupledArg[0], v];
58
59
  }
59
- }, ofArray([tryInclude("@id", (value) => (new Json(0, [value])), oa.ID), tryInclude("name", (value_2) => (new Json(0, [value_2])), oa.Name), tryIncludeListOpt("characteristics", MaterialAttributeValue_ISAJson_encoder, oa.Characteristics)]))]);
60
+ }, ofArray([tryInclude("@id", (value) => (new Json(0, [value])), Source_ROCrate_genID(oa_1)), tryInclude("name", (value_2) => (new Json(0, [value_2])), oa_1.Name), tryIncludeListOpt("characteristics", (oa_2) => MaterialAttributeValue_ISAJson_encoder(idMap, oa_2), oa_1.Characteristics)]))]));
61
+ if (idMap != null) {
62
+ return encode(Source_ROCrate_genID, f, oa, idMap);
63
+ }
64
+ else {
65
+ return f(oa);
66
+ }
60
67
  }
61
68
 
62
69
  export const Source_ISAJson_allowedFields = ofArray(["@id", "name", "characteristics", "@type", "@context"]);
@@ -76,15 +83,16 @@ export function ARCtrl_Process_Source__Source_fromISAJsonString_Static_Z721C83C5
76
83
  }
77
84
  }
78
85
 
79
- export function ARCtrl_Process_Source__Source_toISAJsonString_Static_71136F3F(spaces) {
86
+ export function ARCtrl_Process_Source__Source_toISAJsonString_Static_Z3B036AA(spaces, useIDReferencing) {
87
+ const idMap = defaultArg(useIDReferencing, false) ? (new Map([])) : void 0;
80
88
  return (f) => {
81
- const value = Source_ISAJson_encoder(f);
82
- return toString(defaultSpaces(spaces), value);
89
+ const value_1 = Source_ISAJson_encoder(idMap, f);
90
+ return toString(defaultSpaces(spaces), value_1);
83
91
  };
84
92
  }
85
93
 
86
- export function ARCtrl_Process_Source__Source_ToISAJsonString_71136F3F(this$, spaces) {
87
- return ARCtrl_Process_Source__Source_toISAJsonString_Static_71136F3F(unwrap(spaces))(this$);
94
+ export function ARCtrl_Process_Source__Source_ToISAJsonString_Z3B036AA(this$, spaces, useIDReferencing) {
95
+ return ARCtrl_Process_Source__Source_toISAJsonString_Static_Z3B036AA(unwrap(spaces), unwrap(useIDReferencing))(this$);
88
96
  }
89
97
 
90
98
  export function ARCtrl_Process_Source__Source_fromROCrateString_Static_Z721C83C5(s) {
@@ -7,7 +7,7 @@ import { Source_ISAJson_encoder } from "./Source.js";
7
7
  import { Sample_ISAJson_encoder } from "./Sample.js";
8
8
  import { Material_ISAJson_encoder } from "./Material.js";
9
9
 
10
- export function encoder(ps) {
10
+ export function encoder(idMap, ps) {
11
11
  const source = getSources(ps);
12
12
  const samples = getSamples(ps);
13
13
  const materials = getMaterials(ps);
@@ -19,6 +19,6 @@ export function encoder(ps) {
19
19
  else {
20
20
  return [tupledArg[0], v];
21
21
  }
22
- }, ofArray([tryIncludeList("sources", Source_ISAJson_encoder, source), tryIncludeList("samples", Sample_ISAJson_encoder, samples), tryIncludeList("otherMaterials", Material_ISAJson_encoder, materials)]))]);
22
+ }, ofArray([tryIncludeList("sources", (oa) => Source_ISAJson_encoder(idMap, oa), source), tryIncludeList("samples", (oa_1) => Sample_ISAJson_encoder(idMap, oa_1), samples), tryIncludeList("otherMaterials", (c) => Material_ISAJson_encoder(idMap, c), materials)]))]);
23
23
  }
24
24
 
@@ -8,14 +8,14 @@ import { printf, toText } from "../../fable_modules/fable-library-js.4.16.0/Stri
8
8
  import { toString } from "../../fable_modules/Thoth.Json.JavaScript.0.1.0/Encode.fs.js";
9
9
  import { defaultSpaces } from "../Encode.js";
10
10
 
11
- export function Value_ISAJson_encoder(value) {
11
+ export function Value_ISAJson_encoder(idMap, value) {
12
12
  switch (value.tag) {
13
13
  case 1:
14
14
  return new Json(7, [value.fields[0] >>> 0]);
15
15
  case 3:
16
16
  return new Json(0, [value.fields[0]]);
17
17
  case 0:
18
- return OntologyAnnotation_ISAJson_encoder(value.fields[0]);
18
+ return OntologyAnnotation_ISAJson_encoder(idMap, value.fields[0]);
19
19
  default:
20
20
  return new Json(2, [value.fields[0]]);
21
21
  }
@@ -35,7 +35,7 @@ export function ARCtrl_Process_Value__Value_fromISAJsonString_Static_Z721C83C5(s
35
35
 
36
36
  export function ARCtrl_Process_Value__Value_toISAJsonString_Static_71136F3F(spaces) {
37
37
  return (v) => {
38
- const value = Value_ISAJson_encoder(v);
38
+ const value = Value_ISAJson_encoder(void 0, v);
39
39
  return toString(defaultSpaces(spaces), value);
40
40
  };
41
41
  }
@@ -6,7 +6,7 @@ import { OntologyAnnotation_ROCrate_decoderDefinedTerm, OntologyAnnotation_ROCra
6
6
  import { Comment_ISAJson_encoder, Comment_ROCrate_decoderDisambiguatingDescription, Comment_ROCrate_encoderDisambiguatingDescription, Comment_decoder, Comment_encoder } from "./Comment.js";
7
7
  import { string, object } from "../fable_modules/Thoth.Json.Core.0.2.1/Decode.fs.js";
8
8
  import { Publication } from "../Core/Publication.js";
9
- import { unwrap } from "../fable_modules/fable-library-js.4.16.0/Option.js";
9
+ import { defaultArg, unwrap } from "../fable_modules/fable-library-js.4.16.0/Option.js";
10
10
  import { Decode_noAdditionalProperties, Decode_resizeArray, Decode_uri } from "./Decode.js";
11
11
  import { printf, toText, replace } from "../fable_modules/fable-library-js.4.16.0/String.js";
12
12
  import { Person_ROCrate_decodeAuthorListString, Person_ROCrate_encodeAuthorListString } from "./Person.js";
@@ -70,7 +70,7 @@ export const Publication_ROCrate_decoder = object((get$) => {
70
70
  return new Publication(unwrap((objectArg = get$.Optional, objectArg.Field("pubMedID", Decode_uri))), unwrap((objectArg_1 = get$.Optional, objectArg_1.Field("doi", string))), unwrap((objectArg_2 = get$.Optional, objectArg_2.Field("authorList", Person_ROCrate_decodeAuthorListString))), unwrap((objectArg_3 = get$.Optional, objectArg_3.Field("title", string))), unwrap((objectArg_4 = get$.Optional, objectArg_4.Field("status", OntologyAnnotation_ROCrate_decoderDefinedTerm))), unwrap((arg_11 = Decode_resizeArray(Comment_ROCrate_decoderDisambiguatingDescription), (objectArg_5 = get$.Optional, objectArg_5.Field("comments", arg_11)))));
71
71
  });
72
72
 
73
- export function Publication_ISAJson_encoder(oa) {
73
+ export function Publication_ISAJson_encoder(idMap, oa) {
74
74
  return new Json(5, [choose((tupledArg) => {
75
75
  const v = tupledArg[1];
76
76
  if (equals(v, new Json(3, []))) {
@@ -79,7 +79,7 @@ export function Publication_ISAJson_encoder(oa) {
79
79
  else {
80
80
  return [tupledArg[0], v];
81
81
  }
82
- }, ofArray([tryInclude("pubMedID", (value) => (new Json(0, [value])), oa.PubMedID), tryInclude("doi", (value_2) => (new Json(0, [value_2])), oa.DOI), tryInclude("authorList", (value_4) => (new Json(0, [value_4])), oa.Authors), tryInclude("title", (value_6) => (new Json(0, [value_6])), oa.Title), tryInclude("status", OntologyAnnotation_encoder, oa.Status), tryIncludeSeq("comments", Comment_ISAJson_encoder, oa.Comments)]))]);
82
+ }, ofArray([tryInclude("pubMedID", (value) => (new Json(0, [value])), oa.PubMedID), tryInclude("doi", (value_2) => (new Json(0, [value_2])), oa.DOI), tryInclude("authorList", (value_4) => (new Json(0, [value_4])), oa.Authors), tryInclude("title", (value_6) => (new Json(0, [value_6])), oa.Title), tryInclude("status", OntologyAnnotation_encoder, oa.Status), tryIncludeSeq("comments", (comment) => Comment_ISAJson_encoder(idMap, comment), oa.Comments)]))]);
83
83
  }
84
84
 
85
85
  export const Publication_ISAJson_allowedFields = ofArray(["pubMedID", "doi", "authorList", "title", "status", "comments"]);
@@ -141,14 +141,15 @@ export function ARCtrl_Publication__Publication_fromISAJsonString_Static_Z721C83
141
141
  }
142
142
  }
143
143
 
144
- export function ARCtrl_Publication__Publication_toISAJsonString_Static_71136F3F(spaces) {
144
+ export function ARCtrl_Publication__Publication_toISAJsonString_Static_Z3B036AA(spaces, useIDReferencing) {
145
+ const idMap = defaultArg(useIDReferencing, false) ? (new Map([])) : void 0;
145
146
  return (obj) => {
146
- const value = Publication_ISAJson_encoder(obj);
147
+ const value = Publication_ISAJson_encoder(idMap, obj);
147
148
  return toString(defaultSpaces(spaces), value);
148
149
  };
149
150
  }
150
151
 
151
- export function ARCtrl_Publication__Publication_ToISAJsonString_71136F3F(this$, spaces) {
152
- return ARCtrl_Publication__Publication_toISAJsonString_Static_71136F3F(unwrap(spaces))(this$);
152
+ export function ARCtrl_Publication__Publication_ToISAJsonString_Z3B036AA(this$, spaces, useIDReferencing) {
153
+ return ARCtrl_Publication__Publication_toISAJsonString_Static_Z3B036AA(unwrap(spaces), unwrap(useIDReferencing))(this$);
153
154
  }
154
155
 
package/Json/Study.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Option_fromValueWithDefault, ResizeArray_map } from "../Core/Helper/Collections.js";
2
- import { defaultArgWith, map, bind, unwrap, value as value_14, defaultArg } from "../fable_modules/fable-library-js.4.16.0/Option.js";
2
+ import { defaultArgWith, map, bind, unwrap, value as value_17, defaultArg } from "../fable_modules/fable-library-js.4.16.0/Option.js";
3
3
  import { empty, map as map_1, singleton, ofArray, choose, tryFind } from "../fable_modules/fable-library-js.4.16.0/List.js";
4
4
  import { ArcStudy, ArcAssay } from "../Core/ArcTypes.js";
5
5
  import { disposeSafe, getEnumerator, equals } from "../fable_modules/fable-library-js.4.16.0/Util.js";
@@ -19,22 +19,23 @@ import { list as list_1 } from "../fable_modules/Thoth.Json.Core.0.2.1/Encode.fs
19
19
  import { Process_ISAJson_decoder, Process_ISAJson_encoder, Process_ROCrate_decoder, Process_ROCrate_encoder } from "./Process/Process.js";
20
20
  import { Assay_ISAJson_decoder, Assay_ISAJson_encoder, Assay_ROCrate_decoder, Assay_ROCrate_encoder } from "./Assay.js";
21
21
  import { context_jsonvalue } from "./context/rocrate/isa_study_context.js";
22
- import { getUnits, getCharacteristics, getFactors, getProtocols } from "../Core/Process/ProcessSequence.js";
23
- import { Protocol_ISAJson_encoder } from "./Process/Protocol.js";
24
- import { encoder } from "./Process/StudyMaterials.js";
22
+ import { getProtocols, getCharacteristics, getFactors, getUnits } from "../Core/Process/ProcessSequence.js";
25
23
  import { Factor_ISAJson_encoder } from "./Process/Factor.js";
26
24
  import { MaterialAttribute_ISAJson_encoder } from "./Process/MaterialAttribute.js";
25
+ import { encoder as encoder_4 } from "./Process/StudyMaterials.js";
26
+ import { Protocol_ISAJson_encoder } from "./Process/Protocol.js";
27
+ import { encode } from "./IDTable.js";
27
28
  import { isEmpty } from "../fable_modules/fable-library-js.4.16.0/Seq.js";
28
29
  import { fromString } from "../fable_modules/Thoth.Json.JavaScript.0.1.0/Decode.fs.js";
29
30
  import { toString } from "../fable_modules/Thoth.Json.JavaScript.0.1.0/Encode.fs.js";
30
- import { encode, decode } from "./Table/Compression.js";
31
+ import { encode as encode_1, decode } from "./Table/Compression.js";
31
32
 
32
33
  /**
33
34
  * Get registered assays or get assays from `assays` if IsSome
34
35
  */
35
36
  export function Study_Helper_getAssayInformation(assays, study) {
36
37
  if (assays != null) {
37
- return ResizeArray_map((assayId) => defaultArg(tryFind((a) => (a.Identifier === assayId), value_14(assays)), ArcAssay.init(assayId)), study.RegisteredAssayIdentifiers);
38
+ return ResizeArray_map((assayId) => defaultArg(tryFind((a) => (a.Identifier === assayId), value_17(assays)), ArcAssay.init(assayId)), study.RegisteredAssayIdentifiers);
38
39
  }
39
40
  else {
40
41
  return study.GetRegisteredAssaysOrIdentifier();
@@ -121,48 +122,60 @@ export const Study_ROCrate_decoder = object((get$) => {
121
122
  /**
122
123
  * If assays.IsSome then try to get registered assays from external list, otherwise try to access investigation or create empty defaults.
123
124
  */
124
- export function Study_ISAJson_encoder(assays, s) {
125
- const study = s.Copy(true);
126
- const fileName = Study_fileNameFromIdentifier(study.Identifier);
127
- let assays_1;
128
- const n = [];
129
- let enumerator = getEnumerator(Study_Helper_getAssayInformation(assays, study));
130
- try {
131
- while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
132
- const a = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
133
- const assay = a.Copy();
134
- let enumerator_1 = getEnumerator(assay.Performers);
135
- try {
136
- while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
137
- const person_1 = Person_setSourceAssayComment(enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"](), assay.Identifier);
138
- void (study.Contacts.push(person_1));
125
+ export function Study_ISAJson_encoder(idMap, assays, s) {
126
+ const f = (s_1) => {
127
+ let studyName, studyName_1, studyName_2;
128
+ const study = s_1.Copy(true);
129
+ const fileName = Study_fileNameFromIdentifier(study.Identifier);
130
+ let assays_1;
131
+ const n = [];
132
+ let enumerator = getEnumerator(Study_Helper_getAssayInformation(assays, study));
133
+ try {
134
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
135
+ const a = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
136
+ const assay = a.Copy();
137
+ let enumerator_1 = getEnumerator(assay.Performers);
138
+ try {
139
+ while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
140
+ const person_1 = Person_setSourceAssayComment(enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"](), assay.Identifier);
141
+ void (study.Contacts.push(person_1));
142
+ }
139
143
  }
144
+ finally {
145
+ disposeSafe(enumerator_1);
146
+ }
147
+ assay.Performers = [];
148
+ void (n.push(assay));
140
149
  }
141
- finally {
142
- disposeSafe(enumerator_1);
143
- }
144
- assay.Performers = [];
145
- void (n.push(assay));
146
150
  }
151
+ finally {
152
+ disposeSafe(enumerator);
153
+ }
154
+ assays_1 = n;
155
+ const processes = ARCtrl_ArcTables__ArcTables_GetProcesses(study);
156
+ const encodedUnits = tryIncludeList("unitCategories", (oa) => OntologyAnnotation_ISAJson_encoder(idMap, oa), getUnits(processes));
157
+ const encodedFactors = tryIncludeList("factors", (value_1) => Factor_ISAJson_encoder(idMap, value_1), getFactors(processes));
158
+ const encodedCharacteristics = tryIncludeList("characteristicCategories", (value_3) => MaterialAttribute_ISAJson_encoder(idMap, value_3), getCharacteristics(processes));
159
+ const encodedMaterials = tryInclude("materials", (ps) => encoder_4(idMap, ps), Option_fromValueWithDefault(empty(), processes));
160
+ let encodedProtocols;
161
+ const value_5 = getProtocols(processes);
162
+ encodedProtocols = tryIncludeList("protocols", (studyName = s_1.Identifier, (oa_1) => Protocol_ISAJson_encoder(studyName, void 0, void 0, idMap, oa_1)), value_5);
163
+ return new Json(5, [choose((tupledArg) => {
164
+ const v = tupledArg[1];
165
+ if (equals(v, new Json(3, []))) {
166
+ return void 0;
167
+ }
168
+ else {
169
+ return [tupledArg[0], v];
170
+ }
171
+ }, ofArray([["@id", new Json(0, [Study_ROCrate_genID(study)])], ["filename", new Json(0, [fileName])], ["identifier", new Json(0, [study.Identifier])], tryInclude("title", (value_9) => (new Json(0, [value_9])), study.Title), tryInclude("description", (value_11) => (new Json(0, [value_11])), study.Description), tryInclude("submissionDate", (value_13) => (new Json(0, [value_13])), study.SubmissionDate), tryInclude("publicReleaseDate", (value_15) => (new Json(0, [value_15])), study.PublicReleaseDate), tryIncludeSeq("publications", (oa_2) => Publication_ISAJson_encoder(idMap, oa_2), study.Publications), tryIncludeSeq("people", (person_2) => Person_ISAJson_encoder(idMap, person_2), study.Contacts), tryIncludeSeq("studyDesignDescriptors", (oa_3) => OntologyAnnotation_ISAJson_encoder(idMap, oa_3), study.StudyDesignDescriptors), encodedProtocols, encodedMaterials, tryIncludeList("processSequence", (studyName_1 = s_1.Identifier, (oa_4) => Process_ISAJson_encoder(studyName_1, void 0, idMap, oa_4)), processes), tryIncludeSeq("assays", (studyName_2 = s_1.Identifier, (a_2) => Assay_ISAJson_encoder(studyName_2, idMap, a_2)), assays_1), encodedFactors, encodedCharacteristics, encodedUnits, tryIncludeSeq("comments", (comment) => Comment_ISAJson_encoder(idMap, comment), study.Comments)]))]);
172
+ };
173
+ if (idMap != null) {
174
+ return encode(Study_ROCrate_genID, f, s, idMap);
147
175
  }
148
- finally {
149
- disposeSafe(enumerator);
176
+ else {
177
+ return f(s);
150
178
  }
151
- assays_1 = n;
152
- const processes = ARCtrl_ArcTables__ArcTables_GetProcesses(study);
153
- const protocols = getProtocols(processes);
154
- const factors = getFactors(processes);
155
- const characteristics = getCharacteristics(processes);
156
- const units = getUnits(processes);
157
- return new Json(5, [choose((tupledArg) => {
158
- const v = tupledArg[1];
159
- if (equals(v, new Json(3, []))) {
160
- return void 0;
161
- }
162
- else {
163
- return [tupledArg[0], v];
164
- }
165
- }, ofArray([["filename", new Json(0, [fileName])], ["identifier", new Json(0, [study.Identifier])], tryInclude("title", (value_2) => (new Json(0, [value_2])), study.Title), tryInclude("description", (value_4) => (new Json(0, [value_4])), study.Description), tryInclude("submissionDate", (value_6) => (new Json(0, [value_6])), study.SubmissionDate), tryInclude("publicReleaseDate", (value_8) => (new Json(0, [value_8])), study.PublicReleaseDate), tryIncludeSeq("publications", Publication_ISAJson_encoder, study.Publications), tryIncludeSeq("people", Person_ISAJson_encoder, study.Contacts), tryIncludeSeq("studyDesignDescriptors", OntologyAnnotation_ISAJson_encoder, study.StudyDesignDescriptors), tryIncludeList("protocols", Protocol_ISAJson_encoder, protocols), tryInclude("materials", encoder, Option_fromValueWithDefault(empty(), processes)), tryIncludeList("factors", Factor_ISAJson_encoder, factors), tryIncludeList("characteristicCategories", MaterialAttribute_ISAJson_encoder, characteristics), tryIncludeList("unitCategories", OntologyAnnotation_ISAJson_encoder, units), tryIncludeList("processSequence", Process_ISAJson_encoder, processes), tryIncludeSeq("assays", Assay_ISAJson_encoder, assays_1), tryIncludeSeq("comments", Comment_ISAJson_encoder, study.Comments)]))]);
166
179
  }
167
180
 
168
181
  export const Study_ISAJson_allowedFields = ofArray(["@id", "filename", "identifier", "title", "description", "submissionDate", "publicReleaseDate", "publications", "people", "studyDesignDescriptors", "protocols", "materials", "assays", "factors", "characteristicCategories", "unitCategories", "processSequence", "comments", "@type", "@context"]);
@@ -187,7 +200,7 @@ export const Study_ISAJson_decoder = Decode_objectNoAdditionalProperties(Study_I
187
200
  personsRaw = objectArg_4.Field("people", arg_10);
188
201
  const persons = [];
189
202
  if (personsRaw != null) {
190
- let enumerator = getEnumerator(value_14(personsRaw));
203
+ let enumerator = getEnumerator(value_17(personsRaw));
191
204
  try {
192
205
  while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
193
206
  const person = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
@@ -196,7 +209,7 @@ export const Study_ISAJson_decoder = Decode_objectNoAdditionalProperties(Study_I
196
209
  try {
197
210
  while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
198
211
  const assayIdentifier = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
199
- const enumerator_2 = getEnumerator(value_14(assays));
212
+ const enumerator_2 = getEnumerator(value_17(assays));
200
213
  try {
201
214
  while (enumerator_2["System.Collections.IEnumerator.MoveNext"]()) {
202
215
  const assay = enumerator_2["System.Collections.Generic.IEnumerator`1.get_Current"]();
@@ -268,7 +281,7 @@ export function ARCtrl_ArcStudy__ArcStudy_fromCompressedJsonString_Static_Z721C8
268
281
  }
269
282
 
270
283
  export function ARCtrl_ArcStudy__ArcStudy_toCompressedJsonString_Static_71136F3F(spaces) {
271
- return (obj) => toString(defaultArg(spaces, 0), encode(Study_encoderCompressed, obj));
284
+ return (obj) => toString(defaultArg(spaces, 0), encode_1(Study_encoderCompressed, obj));
272
285
  }
273
286
 
274
287
  export function ARCtrl_ArcStudy__ArcStudy_ToCompressedJsonString_71136F3F(this$, spaces) {
@@ -309,14 +322,15 @@ export function ARCtrl_ArcStudy__ArcStudy_fromISAJsonString_Static_Z721C83C5(s)
309
322
  }
310
323
  }
311
324
 
312
- export function ARCtrl_ArcStudy__ArcStudy_toISAJsonString_Static_3BA23086(assays, spaces) {
325
+ export function ARCtrl_ArcStudy__ArcStudy_toISAJsonString_Static_Z3FD920F1(assays, spaces, useIDReferencing) {
326
+ const idMap = defaultArg(useIDReferencing, false) ? (new Map([])) : void 0;
313
327
  return (obj) => {
314
- const value = Study_ISAJson_encoder(assays, obj);
328
+ const value = Study_ISAJson_encoder(idMap, assays, obj);
315
329
  return toString(defaultSpaces(spaces), value);
316
330
  };
317
331
  }
318
332
 
319
- export function ARCtrl_ArcStudy__ArcStudy_ToISAJsonString_3BA23086(this$, assays, spaces) {
320
- return ARCtrl_ArcStudy__ArcStudy_toISAJsonString_Static_3BA23086(unwrap(assays), unwrap(spaces))(this$);
333
+ export function ARCtrl_ArcStudy__ArcStudy_ToISAJsonString_Z3FD920F1(this$, assays, spaces, useIDReferencing) {
334
+ return ARCtrl_ArcStudy__ArcStudy_toISAJsonString_Static_Z3FD920F1(unwrap(assays), unwrap(spaces), unwrap(useIDReferencing))(this$);
321
335
  }
322
336