@nfdi4plants/arctrl 2.1.0-alpha.1 → 2.1.0-alpha.3

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.
@@ -1,113 +1,136 @@
1
- import { FsWorksheet } from "../fable_modules/FsSpreadsheet.6.3.0-alpha.4/FsWorksheet.fs.js";
2
- import { iterate, isEmpty as isEmpty_1, tryPick, choose, tryFind, tryHead, head, exists, map, singleton, append, delay, iterateIndexed } from "../fable_modules/fable-library-js.4.22.0/Seq.js";
3
- import { SparseRowModule_tryGetValueAt, SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_writeToSheet } from "./Metadata/SparseTable.js";
4
- import { fromRows as fromRows_1, toRows as toRows_1 } from "./Metadata/Assays.js";
5
- import { empty, isEmpty, ofSeq, singleton as singleton_1 } from "../fable_modules/fable-library-js.4.22.0/List.js";
6
- import { fromRows as fromRows_2, toRows as toRows_2 } from "./Metadata/Contacts.js";
7
- import { toConsole, printf, toFail } from "../fable_modules/fable-library-js.4.22.0/String.js";
1
+ import { iterate, isEmpty as isEmpty_1, tryPick, choose, tryFind, map, iterateIndexed, singleton, append, delay, tryHead, head, exists } from "../fable_modules/fable-library-js.4.22.0/Seq.js";
8
2
  import { getEnumerator } from "../fable_modules/fable-library-js.4.22.0/Util.js";
3
+ import { toRows, fromRows } from "./Metadata/Assays.js";
4
+ import { toRows as toRows_1, fromRows as fromRows_1 } from "./Metadata/Contacts.js";
9
5
  import { ArcAssay } from "../Core/ArcTypes.js";
10
6
  import { createMissingIdentifier } from "../Core/Helper/Identifier.js";
11
7
  import { unwrap, toArray, defaultArg } from "../fable_modules/fable-library-js.4.22.0/Option.js";
8
+ import { ofSeq, singleton as singleton_1, empty, isEmpty } from "../fable_modules/fable-library-js.4.22.0/List.js";
9
+ import { SparseRowModule_fromAllValues, SparseRowModule_getAllValues, SparseRowModule_fromFsRow, SparseRowModule_writeToSheet, SparseRowModule_fromValues, SparseRowModule_tryGetValueAt } from "./Metadata/SparseTable.js";
10
+ import { FsWorksheet } from "../fable_modules/FsSpreadsheet.6.3.0-alpha.4/FsWorksheet.fs.js";
11
+ import { toConsole, printf, toFail } from "../fable_modules/fable-library-js.4.22.0/String.js";
12
12
  import { toFsWorksheet as toFsWorksheet_1, tryFromFsWorksheet } from "./AnnotationTable/ArcTable.js";
13
13
  import { toFsWorksheet, tryFromFsWorksheet as tryFromFsWorksheet_1 } from "./DataMapTable/DataMapTable.js";
14
14
  import { FsWorkbook } from "../fable_modules/FsSpreadsheet.6.3.0-alpha.4/FsWorkbook.fs.js";
15
15
 
16
- export function ArcAssay_toMetadataSheet(assay) {
17
- let assay_1;
18
- const sheet = new FsWorksheet("isa_assay");
19
- iterateIndexed((rowI, r) => {
20
- SparseRowModule_writeToSheet(rowI + 1, r, sheet);
21
- }, (assay_1 = assay, delay(() => append(singleton(SparseRowModule_fromValues(["ASSAY"])), delay(() => append(toRows_1("Assay", singleton_1(assay_1)), delay(() => append(singleton(SparseRowModule_fromValues(["ASSAY PERFORMERS"])), delay(() => toRows_2("Assay Person", ofSeq(assay_1.Performers)))))))))));
22
- return sheet;
23
- }
24
-
25
- export function ArcAssay_fromMetadataSheet(sheet) {
26
- try {
27
- const rows_1 = map(SparseRowModule_fromFsRow, sheet.Rows);
28
- const patternInput = exists((row) => {
29
- const s = head(row)[1];
30
- return s.startsWith("Assay");
31
- }, rows_1) ? ["Assay", "Assay Person"] : [undefined, undefined];
32
- const en = getEnumerator(rows_1);
33
- const loop = (lastLine_mut, assays_mut, contacts_mut, lineNumber_mut) => {
34
- let k;
35
- loop:
36
- while (true) {
37
- const lastLine = lastLine_mut, assays = assays_mut, contacts = contacts_mut, lineNumber = lineNumber_mut;
38
- let matchResult, k_2, k_3, k_4;
39
- if (lastLine != null) {
40
- if ((k = lastLine, (k === "ASSAY") ? true : (k === "ASSAY METADATA"))) {
41
- matchResult = 0;
42
- k_2 = lastLine;
43
- }
44
- else if (lastLine === "ASSAY PERFORMERS") {
45
- matchResult = 1;
46
- k_3 = lastLine;
47
- }
48
- else {
49
- matchResult = 2;
50
- k_4 = lastLine;
51
- }
16
+ export function ArcAssay_fromRows(rows) {
17
+ const patternInput = exists((row) => {
18
+ const s = head(row)[1];
19
+ return s.startsWith("Assay");
20
+ }, rows) ? ["Assay", "Assay Person"] : [undefined, undefined];
21
+ const en = getEnumerator(rows);
22
+ const loop = (lastRow_mut, assays_mut, contacts_mut, rowNumber_mut) => {
23
+ let prefix;
24
+ loop:
25
+ while (true) {
26
+ const lastRow = lastRow_mut, assays = assays_mut, contacts = contacts_mut, rowNumber = rowNumber_mut;
27
+ let matchResult, prefix_2, prefix_3;
28
+ if (lastRow != null) {
29
+ if ((prefix = lastRow, (prefix === "ASSAY") ? true : (prefix === "ASSAY METADATA"))) {
30
+ matchResult = 0;
31
+ prefix_2 = lastRow;
32
+ }
33
+ else if (lastRow === "ASSAY PERFORMERS") {
34
+ matchResult = 1;
35
+ prefix_3 = lastRow;
52
36
  }
53
37
  else {
54
38
  matchResult = 2;
55
- k_4 = lastLine;
56
39
  }
57
- switch (matchResult) {
58
- case 0: {
59
- const patternInput_1 = fromRows_1(patternInput[0], lineNumber + 1, en);
60
- lastLine_mut = patternInput_1[0];
61
- assays_mut = patternInput_1[3];
62
- contacts_mut = contacts;
63
- lineNumber_mut = patternInput_1[1];
64
- continue loop;
65
- }
66
- case 1: {
67
- const patternInput_2 = fromRows_2(patternInput[1], lineNumber + 1, en);
68
- lastLine_mut = patternInput_2[0];
69
- assays_mut = assays;
70
- contacts_mut = patternInput_2[3];
71
- lineNumber_mut = patternInput_2[1];
72
- continue loop;
73
- }
74
- default: {
75
- let matchResult_1, assays_2, contacts_2;
76
- if (isEmpty(assays)) {
77
- if (isEmpty(contacts)) {
78
- matchResult_1 = 0;
79
- }
80
- else {
81
- matchResult_1 = 1;
82
- assays_2 = assays;
83
- contacts_2 = contacts;
84
- }
40
+ }
41
+ else {
42
+ matchResult = 2;
43
+ }
44
+ switch (matchResult) {
45
+ case 0: {
46
+ const patternInput_1 = fromRows(patternInput[0], rowNumber + 1, en);
47
+ lastRow_mut = patternInput_1[0];
48
+ assays_mut = patternInput_1[3];
49
+ contacts_mut = contacts;
50
+ rowNumber_mut = patternInput_1[1];
51
+ continue loop;
52
+ }
53
+ case 1: {
54
+ const patternInput_2 = fromRows_1(patternInput[1], rowNumber + 1, en);
55
+ lastRow_mut = patternInput_2[0];
56
+ assays_mut = assays;
57
+ contacts_mut = patternInput_2[3];
58
+ rowNumber_mut = patternInput_2[1];
59
+ continue loop;
60
+ }
61
+ default: {
62
+ let matchResult_1, assays_2, contacts_2;
63
+ if (isEmpty(assays)) {
64
+ if (isEmpty(contacts)) {
65
+ matchResult_1 = 0;
85
66
  }
86
67
  else {
87
68
  matchResult_1 = 1;
88
69
  assays_2 = assays;
89
70
  contacts_2 = contacts;
90
71
  }
91
- switch (matchResult_1) {
92
- case 0:
93
- return ArcAssay.create(createMissingIdentifier());
94
- default: {
95
- const performers = Array.from(contacts_2);
96
- const assay = defaultArg(tryHead(assays_2), ArcAssay.create(createMissingIdentifier()));
97
- return ArcAssay.setPerformers(performers, assay);
98
- }
72
+ }
73
+ else {
74
+ matchResult_1 = 1;
75
+ assays_2 = assays;
76
+ contacts_2 = contacts;
77
+ }
78
+ switch (matchResult_1) {
79
+ case 0:
80
+ return ArcAssay.create(createMissingIdentifier());
81
+ default: {
82
+ const performers = Array.from(contacts_2);
83
+ const assay = defaultArg(tryHead(assays_2), ArcAssay.create(createMissingIdentifier()));
84
+ return ArcAssay.setPerformers(performers, assay);
99
85
  }
100
86
  }
101
87
  }
102
- break;
103
88
  }
104
- };
105
- if (en["System.Collections.IEnumerator.MoveNext"]()) {
106
- return loop(SparseRowModule_tryGetValueAt(0, en["System.Collections.Generic.IEnumerator`1.get_Current"]()), empty(), empty(), 1);
107
- }
108
- else {
109
- throw new Error("empty assay metadata sheet");
89
+ break;
110
90
  }
91
+ };
92
+ if (en["System.Collections.IEnumerator.MoveNext"]()) {
93
+ return loop(SparseRowModule_tryGetValueAt(0, en["System.Collections.Generic.IEnumerator`1.get_Current"]()), empty(), empty(), 1);
94
+ }
95
+ else {
96
+ throw new Error("empty assay metadata sheet");
97
+ }
98
+ }
99
+
100
+ export function ArcAssay_toRows(assay) {
101
+ return delay(() => append(singleton(SparseRowModule_fromValues(["ASSAY"])), delay(() => append(toRows("Assay", singleton_1(assay)), delay(() => append(singleton(SparseRowModule_fromValues(["ASSAY PERFORMERS"])), delay(() => toRows_1("Assay Person", ofSeq(assay.Performers)))))))));
102
+ }
103
+
104
+ export function ArcAssay_toMetadataSheet(assay) {
105
+ const sheet = new FsWorksheet("isa_assay");
106
+ iterateIndexed((rowI, r) => {
107
+ SparseRowModule_writeToSheet(rowI + 1, r, sheet);
108
+ }, ArcAssay_toRows(assay));
109
+ return sheet;
110
+ }
111
+
112
+ export function ArcAssay_fromMetadataSheet(sheet) {
113
+ try {
114
+ const rows = map(SparseRowModule_fromFsRow, sheet.Rows);
115
+ const hasPrefix = exists((row) => {
116
+ const s = head(row)[1];
117
+ return s.startsWith("Assay");
118
+ }, rows);
119
+ return ArcAssay_fromRows(rows);
120
+ }
121
+ catch (err) {
122
+ const arg = err.message;
123
+ return toFail(printf("Failed while parsing metadatasheet: %s"))(arg);
124
+ }
125
+ }
126
+
127
+ export function ArcAssay_toMetadataCollection(assay) {
128
+ return map(SparseRowModule_getAllValues, ArcAssay_toRows(assay));
129
+ }
130
+
131
+ export function ArcAssay_fromMetadataCollection(collection) {
132
+ try {
133
+ return ArcAssay_fromRows(map(SparseRowModule_fromAllValues, collection));
111
134
  }
112
135
  catch (err) {
113
136
  const arg = err.message;
@@ -3,7 +3,7 @@ import { record_type, list_type, string_type } from "../fable_modules/fable-libr
3
3
  import { Remark, Comment$_$reflection } from "../Core/Comment.js";
4
4
  import { head, tail, isEmpty, ofSeq, concat, unzip, append, reverse, cons, empty, map, ofArray } from "../fable_modules/fable-library-js.4.22.0/List.js";
5
5
  import { Remark_wrapRemark, Comment_toString, Comment_fromString } from "./Metadata/Comment.js";
6
- import { SparseRowModule_writeToSheet, SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_tryGetValueAt, SparseTable_ToRows_759CAFC1, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133 } from "./Metadata/SparseTable.js";
6
+ import { SparseRowModule_writeToSheet, SparseRowModule_fromFsRow, SparseRowModule_fromAllValues, SparseRowModule_getAllValues, SparseRowModule_fromValues, SparseRowModule_tryGetValueAt, SparseTable_ToRows_759CAFC1, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133 } from "./Metadata/SparseTable.js";
7
7
  import { addToDict } from "../fable_modules/fable-library-js.4.22.0/MapUtil.js";
8
8
  import { value as value_1, defaultArg } from "../fable_modules/fable-library-js.4.22.0/Option.js";
9
9
  import { Option_fromValueWithDefault, ResizeArray_iter } from "../Core/Helper/Collections.js";
@@ -14,7 +14,7 @@ import { toRows, fromRows } from "./Metadata/OntologySourceReference.js";
14
14
  import { toRows as toRows_1, fromRows as fromRows_1 } from "./Metadata/Publication.js";
15
15
  import { toRows as toRows_2, fromRows as fromRows_2 } from "./Metadata/Contacts.js";
16
16
  import { toRows as toRows_3, fromRows as fromRows_3 } from "./Metadata/Study.js";
17
- import { iterateIndexed, map as map_1, tryFind as tryFind_1, toList, collect, singleton, append as append_1, delay } from "../fable_modules/fable-library-js.4.22.0/Seq.js";
17
+ import { iterateIndexed, tryFind as tryFind_1, map as map_1, toList, collect, singleton, append as append_1, delay } from "../fable_modules/fable-library-js.4.22.0/Seq.js";
18
18
  import { tryFind, ofList } from "../fable_modules/fable-library-js.4.22.0/Map.js";
19
19
  import { printf, toFail } from "../fable_modules/fable-library-js.4.22.0/String.js";
20
20
  import { FsWorksheet } from "../fable_modules/FsSpreadsheet.6.3.0-alpha.4/FsWorksheet.fs.js";
@@ -102,7 +102,7 @@ export function ArcInvestigation_fromRows(rows) {
102
102
  loop:
103
103
  while (true) {
104
104
  const lastLine = lastLine_mut, ontologySourceReferences = ontologySourceReferences_mut, investigationInfo = investigationInfo_mut, publications = publications_mut, contacts = contacts_mut, studies = studies_mut, remarks = remarks_mut, lineNumber = lineNumber_mut;
105
- let matchResult, k_5, k_6, k_7, k_8, k_9, k_10;
105
+ let matchResult, k_5, k_6, k_7, k_8, k_9;
106
106
  if (lastLine != null) {
107
107
  switch (lastLine) {
108
108
  case "ONTOLOGY SOURCE REFERENCE": {
@@ -130,15 +130,12 @@ export function ArcInvestigation_fromRows(rows) {
130
130
  k_9 = lastLine;
131
131
  break;
132
132
  }
133
- default: {
133
+ default:
134
134
  matchResult = 5;
135
- k_10 = lastLine;
136
- }
137
135
  }
138
136
  }
139
137
  else {
140
138
  matchResult = 5;
141
- k_10 = lastLine;
142
139
  }
143
140
  switch (matchResult) {
144
141
  case 0: {
@@ -283,6 +280,14 @@ export function ArcInvestigation_toRows(investigation) {
283
280
  })()));
284
281
  }
285
282
 
283
+ export function ArcInvestigation_toMetadataCollection(investigation) {
284
+ return map_1(SparseRowModule_getAllValues, ArcInvestigation_toRows(investigation));
285
+ }
286
+
287
+ export function ArcInvestigation_fromMetadataCollection(collection) {
288
+ return ArcInvestigation_fromRows(map_1(SparseRowModule_fromAllValues, collection));
289
+ }
290
+
286
291
  export function ArcInvestigation_isMetadataSheetName(name) {
287
292
  if (name === "isa_investigation") {
288
293
  return true;
@@ -1,10 +1,10 @@
1
1
  import { FsWorksheet } from "../fable_modules/FsSpreadsheet.6.3.0-alpha.4/FsWorksheet.fs.js";
2
2
  import { iterate, tryPick, tryFind, map, append, iterateIndexed } from "../fable_modules/fable-library-js.4.22.0/Seq.js";
3
- import { SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_writeToSheet } from "./Metadata/SparseTable.js";
4
- import { fromRows as fromRows_1, toRows } from "./Metadata/Study.js";
3
+ import { SparseRowModule_fromAllValues, SparseRowModule_getAllValues, SparseRowModule_fromFsRow, SparseRowModule_fromValues, SparseRowModule_writeToSheet } from "./Metadata/SparseTable.js";
4
+ import { fromRows, toRows } from "./Metadata/Study.js";
5
+ import { getEnumerator } from "../fable_modules/fable-library-js.4.22.0/Util.js";
5
6
  import { toConsole, printf, toFail } from "../fable_modules/fable-library-js.4.22.0/String.js";
6
7
  import { unwrap, toArray, defaultArg } from "../fable_modules/fable-library-js.4.22.0/Option.js";
7
- import { getEnumerator } from "../fable_modules/fable-library-js.4.22.0/Util.js";
8
8
  import { ArcStudy } from "../Core/ArcTypes.js";
9
9
  import { createMissingIdentifier } from "../Core/Helper/Identifier.js";
10
10
  import { empty } from "../fable_modules/fable-library-js.4.22.0/List.js";
@@ -22,10 +22,30 @@ export function ArcStudy_toMetadataSheet(study, assays) {
22
22
  return sheet;
23
23
  }
24
24
 
25
+ export function ArcStudy_fromRows(rows) {
26
+ const en = getEnumerator(rows);
27
+ en["System.Collections.IEnumerator.MoveNext"]();
28
+ return fromRows(2, en)[3];
29
+ }
30
+
25
31
  export function ArcStudy_fromMetadataSheet(sheet) {
26
- let en;
27
32
  try {
28
- return defaultArg((en = getEnumerator(map(SparseRowModule_fromFsRow, sheet.Rows)), (void en["System.Collections.IEnumerator.MoveNext"](), fromRows_1(2, en)[3])), [ArcStudy.create(createMissingIdentifier()), empty()]);
33
+ return defaultArg(ArcStudy_fromRows(map(SparseRowModule_fromFsRow, sheet.Rows)), [ArcStudy.create(createMissingIdentifier()), empty()]);
34
+ }
35
+ catch (err) {
36
+ const arg = err.message;
37
+ return toFail(printf("Failed while parsing metadatasheet: %s"))(arg);
38
+ }
39
+ }
40
+
41
+ export function ArcStudy_toMetadataCollection(study, assays) {
42
+ let source_1;
43
+ return map(SparseRowModule_getAllValues, (source_1 = toRows(study, assays), append([SparseRowModule_fromValues(["STUDY"])], source_1)));
44
+ }
45
+
46
+ export function ArcStudy_fromMetadataCollection(collection) {
47
+ try {
48
+ return defaultArg(ArcStudy_fromRows(map(SparseRowModule_fromAllValues, collection)), [ArcStudy.create(createMissingIdentifier()), empty()]);
29
49
  }
30
50
  catch (err) {
31
51
  const arg = err.message;
@@ -4,7 +4,7 @@ import { ofSeq, append as append_1, reverse, map, empty, ofArray } from "../fabl
4
4
  import { toRows, fromRows, toSparseTable, fromSparseTable } from "./Metadata/OntologyAnnotation.js";
5
5
  import { Comment$_$reflection } from "../Core/Comment.js";
6
6
  import { Comment_fromString } from "./Metadata/Comment.js";
7
- import { SparseRowModule_fromFsRow, SparseRowModule_writeToSheet, SparseRowModule_fromValues, SparseRowModule_tryGetValueAt, SparseTable_ToRows_759CAFC1, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133 } from "./Metadata/SparseTable.js";
7
+ import { SparseRowModule_fromAllValues, SparseRowModule_getAllValues, SparseRowModule_fromFsRow, SparseRowModule_writeToSheet, SparseRowModule_fromValues, SparseRowModule_tryGetValueAt, SparseTable_ToRows_759CAFC1, SparseTable_FromRows_Z5579EC29, SparseTable, SparseTable_Create_Z2192E64B, SparseTable__TryGetValueDefault_5BAE6133 } from "./Metadata/SparseTable.js";
8
8
  import { createMissingIdentifier } from "../Core/Helper/Identifier.js";
9
9
  import { addToDict } from "../fable_modules/fable-library-js.4.22.0/MapUtil.js";
10
10
  import { List_distinct } from "../fable_modules/fable-library-js.4.22.0/Seq2.js";
@@ -281,6 +281,14 @@ export function Template_fromMetadataSheet(sheet) {
281
281
  return Metadata_Template_fromRows(map_1(SparseRowModule_fromFsRow, sheet.Rows));
282
282
  }
283
283
 
284
+ export function Template_toMetadataCollection(template) {
285
+ return map_1(SparseRowModule_getAllValues, Metadata_Template_toRows(template));
286
+ }
287
+
288
+ export function Template_fromMetadataCollection(collection) {
289
+ return Metadata_Template_fromRows(map_1(SparseRowModule_fromAllValues, collection));
290
+ }
291
+
284
292
  /**
285
293
  * Reads an assay from a spreadsheet
286
294
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nfdi4plants/arctrl",
3
- "version": "2.1.0-alpha.1",
3
+ "version": "2.1.0-alpha.3",
4
4
  "description": "Top level ARC DataModel and API function descriptions.",
5
5
  "type": "module",
6
6
  "main": "index.js",