Skip to content

Commit 536b988

Browse files
committed
Apply review changes
1 parent f525619 commit 536b988

5 files changed

Lines changed: 141 additions & 124 deletions

File tree

src/ARCtrl/packages.lock.json

Lines changed: 84 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@
88
"resolved": "1.1.0",
99
"contentHash": "YEMSyiB/HCpBgDSZUr0LHaTa9vYH+xj8Fvd/AvzUAVbLQ3Bc2l9xHOI9g4+Bh1wGsLFrhMwFW+U39D7m5a6oOw=="
1010
},
11+
"Fable.SimpleHttp": {
12+
"type": "Direct",
13+
"requested": "[3.5.0, )",
14+
"resolved": "3.5.0",
15+
"contentHash": "SWYshvAI90JcdGLsUmTWBG9eaazY6ihdIk/uehrEz/VqMx9qX+e7+PzYaw31DMwGYSva9/mpq9s69T/z8Ubl5Q==",
16+
"dependencies": {
17+
"FSharp.Core": "4.6.2",
18+
"Fable.Browser.Dom": "1.0.0",
19+
"Fable.Browser.XMLHttpRequest": "1.1.0",
20+
"Fable.Core": "3.0.0"
21+
}
22+
},
1123
"NETStandard.Library": {
1224
"type": "Direct",
1325
"requested": "[2.0.3, )",
@@ -17,47 +29,94 @@
1729
"Microsoft.NETCore.Platforms": "1.1.0"
1830
}
1931
},
20-
"Thoth.Json.Python": {
32+
"Thoth.Json.Newtonsoft": {
2133
"type": "Direct",
22-
"requested": "[0.4.0, )",
23-
"resolved": "0.4.0",
24-
"contentHash": "O86Oisv/91NpbHENz11poZh9zrTRJdAjDXHVC1JqvDDsscelI7HxOmWgks8ZFvYxbBzNJCG+FKQHC10KzyMf8g==",
34+
"requested": "[0.2.0, )",
35+
"resolved": "0.2.0",
36+
"contentHash": "dMQOT6TJftO97c8gHWFegfSw/0/E+VdhGaSkf3e1Ba+DjrAESLA9HMlYyE30x7nhn7w5SfH1WO9YyzSRTV4Ysg==",
2537
"dependencies": {
2638
"FSharp.Core": "5.0.0",
2739
"Fable.Core": "4.1.0",
28-
"Fable.Package.SDK": "1.0.0",
29-
"Fable.Python": "4.3.0",
30-
"Thoth.Json.Core": "0.4.0"
40+
"Fable.Package.SDK": "0.1.0",
41+
"Newtonsoft.Json": "13.0.1",
42+
"Thoth.Json.Core": "0.3.0"
3143
}
3244
},
33-
"Fable.Python": {
45+
"Fable.Browser.Blob": {
3446
"type": "Transitive",
35-
"resolved": "4.3.0",
36-
"contentHash": "KT5PI4NyMtVLDcmDkf5SeqwtFjVO17u27xr45qXfYWG12UePHxGjQJoI16OafIzlEQ6cHfAuRljhZGKIlvOJNQ==",
47+
"resolved": "1.1.0",
48+
"contentHash": "xMX7hPFwBUGuj75xLlH6VsVThZjRlGW4zOqXb1X+byRPLSBE91vtn9EueNUB+YpGhE9LfrtakIPNGy+dkoMkjg==",
3749
"dependencies": {
38-
"FSharp.Core": "4.7.2",
39-
"Fable.Core": "[4.1.0, 5.0.0)"
50+
"FSharp.Core": "4.6.2",
51+
"Fable.Core": "3.0.0"
52+
}
53+
},
54+
"Fable.Browser.Dom": {
55+
"type": "Transitive",
56+
"resolved": "1.0.0",
57+
"contentHash": "ZodpIKYuKnUnqN71Fi103mh0joFYrRPGwpYOrpbZ149PkVAW7DNKXgxad5lsi9df7vAe5+sBhhO71TPREZaWlw==",
58+
"dependencies": {
59+
"FSharp.Core": "4.5.2",
60+
"Fable.Browser.Blob": "1.0.0",
61+
"Fable.Browser.Event": "1.0.0",
62+
"Fable.Browser.WebStorage": "1.0.0",
63+
"Fable.Core": "3.0.0"
64+
}
65+
},
66+
"Fable.Browser.Event": {
67+
"type": "Transitive",
68+
"resolved": "1.0.0",
69+
"contentHash": "T1bGrlRJ4A2fxOfAVPzJpxanR6lkzPgJroPdSN1IU5CLdKtvRakWmYq6QKqu4dz6ZV9Z3fIPTWLZkoGKEOEo3w==",
70+
"dependencies": {
71+
"FSharp.Core": "4.5.2",
72+
"Fable.Core": "3.0.0"
73+
}
74+
},
75+
"Fable.Browser.WebStorage": {
76+
"type": "Transitive",
77+
"resolved": "1.0.0",
78+
"contentHash": "ZqnZKYkhPO+wmJPxQqtiwSc3zCC/mB37SPlVi4ZLiHoPFnra7SQ3qaRn4/ENYTeaVtVq92eVaYbTyAOnFn+GPA==",
79+
"dependencies": {
80+
"FSharp.Core": "4.5.2",
81+
"Fable.Browser.Event": "1.0.0",
82+
"Fable.Core": "3.0.0"
83+
}
84+
},
85+
"Fable.Browser.XMLHttpRequest": {
86+
"type": "Transitive",
87+
"resolved": "1.1.0",
88+
"contentHash": "27p/F8781NrnV9vQ23RhX10ww9MDkX+Yi3yTiV9s8U8Bufi/VCCjS4swX0LXvgKQANN3k87CwaNeiO75r2U7gw==",
89+
"dependencies": {
90+
"FSharp.Core": "4.6.2",
91+
"Fable.Browser.Blob": "1.1.0",
92+
"Fable.Browser.Event": "1.0.0",
93+
"Fable.Core": "3.0.0"
4094
}
4195
},
4296
"Microsoft.NETCore.Platforms": {
4397
"type": "Transitive",
4498
"resolved": "1.1.0",
4599
"contentHash": "kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A=="
46100
},
101+
"Newtonsoft.Json": {
102+
"type": "Transitive",
103+
"resolved": "13.0.1",
104+
"contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A=="
105+
},
47106
"arctrl.contract": {
48107
"type": "Project",
49108
"dependencies": {
50-
"ARCtrl.Core": "[2.1.0, )",
51-
"ARCtrl.Json": "[2.1.0, )",
52-
"ARCtrl.Spreadsheet": "[2.1.0, )",
53-
"ARCtrl.Yaml": "[2.1.0, )"
109+
"ARCtrl.Core": "[1.0.0, )",
110+
"ARCtrl.Json": "[1.0.0, )",
111+
"ARCtrl.Spreadsheet": "[1.0.0, )",
112+
"ARCtrl.Yaml": "[1.0.0, )"
54113
}
55114
},
56115
"arctrl.core": {
57116
"type": "Project",
58117
"dependencies": {
59-
"ARCtrl.CWL": "[2.1.0, )",
60-
"ARCtrl.FileSystem": "[2.1.0, )"
118+
"ARCtrl.CWL": "[1.0.0, )",
119+
"ARCtrl.FileSystem": "[1.0.0, )"
61120
}
62121
},
63122
"arctrl.cwl": {
@@ -72,8 +131,8 @@
72131
"arctrl.json": {
73132
"type": "Project",
74133
"dependencies": {
75-
"ARCtrl.Core": "[2.1.0, )",
76-
"ARCtrl.ROCrate": "[2.1.0, )",
134+
"ARCtrl.Core": "[1.0.0, )",
135+
"ARCtrl.ROCrate": "[1.0.0, )",
77136
"Thoth.Json.Core": "[0.4.0, )"
78137
}
79138
},
@@ -87,22 +146,22 @@
87146
"arctrl.spreadsheet": {
88147
"type": "Project",
89148
"dependencies": {
90-
"ARCtrl.Core": "[2.1.0, )",
91-
"ARCtrl.FileSystem": "[2.1.0, )",
149+
"ARCtrl.Core": "[1.0.0, )",
150+
"ARCtrl.FileSystem": "[1.0.0, )",
92151
"FsSpreadsheet": "[6.3.0-alpha.4, )"
93152
}
94153
},
95154
"arctrl.validationpackages": {
96155
"type": "Project",
97156
"dependencies": {
98-
"ARCtrl.Core": "[2.1.0, )"
157+
"ARCtrl.Core": "[1.0.0, )"
99158
}
100159
},
101160
"arctrl.yaml": {
102161
"type": "Project",
103162
"dependencies": {
104-
"ARCtrl.Core": "[2.1.0, )",
105-
"ARCtrl.ValidationPackages": "[2.1.0, )",
163+
"ARCtrl.Core": "[1.0.0, )",
164+
"ARCtrl.ValidationPackages": "[1.0.0, )",
106165
"YAMLicious": "[0.0.1, )"
107166
}
108167
},

src/Spreadsheet/ArcAssay.fs

Lines changed: 47 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,51 @@ module ArcAssay =
1616
let [<Literal>] obsoleteMetadataSheetName = "Assay"
1717
let [<Literal>] metadataSheetName = "isa_assay"
1818

19+
let fromRows (rows: seq<SparseRow>) =
20+
let hasPrefix =
21+
rows
22+
|> Seq.exists (fun row -> row |> Seq.head |> snd |> fun s -> s.StartsWith(assaysPrefix))
23+
let aPrefix, cPrefix =
24+
if hasPrefix then
25+
Some assaysPrefix, Some contactsPrefix
26+
else None, None
27+
let en = rows.GetEnumerator()
28+
let rec loop lastRow assays contacts rowNumber =
29+
30+
match lastRow with
31+
| Some prefix when prefix = assaysLabel || prefix = obsoleteAssaysLabel ->
32+
let currentRow, rowNumber, _, assays = Assays.fromRows aPrefix (rowNumber + 1) en
33+
loop currentRow assays contacts rowNumber
34+
35+
| Some prefix when prefix = contactsLabel ->
36+
let currentLine, rowNumber, _, contacts = Contacts.fromRows cPrefix (rowNumber + 1) en
37+
loop currentLine assays contacts rowNumber
38+
| _ ->
39+
match assays, contacts with
40+
| [], [] -> ArcAssay.create(Identifier.createMissingIdentifier())
41+
| assays, contacts ->
42+
assays
43+
|> Seq.tryHead
44+
|> Option.defaultValue (ArcAssay.create(Identifier.createMissingIdentifier()))
45+
|> ArcAssay.setPerformers (ResizeArray contacts)
46+
47+
if en.MoveNext () then
48+
let currentLine = en.Current |> SparseRow.tryGetValueAt 0
49+
loop currentLine [] [] 1
50+
51+
else
52+
failwith "empty assay metadata sheet"
53+
54+
let toRows (assay: ArcAssay) =
55+
seq {
56+
yield SparseRow.fromValues [assaysLabel]
57+
yield! Assays.toRows (Some assaysPrefix) [assay]
58+
59+
yield SparseRow.fromValues [contactsLabel]
60+
yield! Contacts.toRows (Some contactsPrefix) (List.ofSeq assay.Performers)
61+
}
62+
1963
let toMetadataSheet (assay: ArcAssay) : FsWorksheet =
20-
let toRows (assay:ArcAssay) =
21-
seq {
22-
yield SparseRow.fromValues [assaysLabel]
23-
yield! Assays.toRows (Some assaysPrefix) [assay]
24-
25-
yield SparseRow.fromValues [contactsLabel]
26-
yield! Contacts.toRows (Some contactsPrefix) (List.ofSeq assay.Performers)
27-
}
2864
let sheet = FsWorksheet(metadataSheetName)
2965
assay
3066
|> toRows
@@ -33,103 +69,29 @@ module ArcAssay =
3369

3470
let fromMetadataSheet (sheet: FsWorksheet) : ArcAssay =
3571
try
36-
let fromRows (usePrefixes: bool) (rows: seq<SparseRow>) =
37-
let aPrefix, cPrefix =
38-
if usePrefixes then
39-
Some assaysPrefix,Some contactsPrefix
40-
else None,None
41-
let en = rows.GetEnumerator()
42-
let rec loop lastLine assays contacts lineNumber =
43-
44-
match lastLine with
45-
46-
| Some k when k = assaysLabel || k = obsoleteAssaysLabel ->
47-
let currentLine, lineNumber, _, assays = Assays.fromRows aPrefix (lineNumber + 1) en
48-
loop currentLine assays contacts lineNumber
49-
50-
| Some k when k = contactsLabel ->
51-
let currentLine, lineNumber, _, contacts = Contacts.fromRows cPrefix (lineNumber + 1) en
52-
loop currentLine assays contacts lineNumber
53-
| k ->
54-
match assays, contacts with
55-
| [], [] -> ArcAssay.create(Identifier.createMissingIdentifier())
56-
| assays, contacts ->
57-
assays
58-
|> Seq.tryHead
59-
|> Option.defaultValue (ArcAssay.create(Identifier.createMissingIdentifier()))
60-
|> ArcAssay.setPerformers (ResizeArray contacts)
61-
62-
if en.MoveNext () then
63-
let currentLine = en.Current |> SparseRow.tryGetValueAt 0
64-
loop currentLine [] [] 1
65-
66-
else
67-
failwith "empty assay metadata sheet"
6872
let rows =
6973
sheet.Rows
7074
|> Seq.map SparseRow.fromFsRow
7175
let hasPrefix =
7276
rows
7377
|> Seq.exists (fun row -> row |> Seq.head |> snd |> fun s -> s.StartsWith(assaysPrefix))
7478
rows
75-
|> fromRows hasPrefix
79+
|> fromRows
7680
with
7781
| err -> failwithf "Failed while parsing metadatasheet: %s" err.Message
7882

7983
let toMetadataCollection (assay: ArcAssay) =
80-
let toRows (assay: ArcAssay) =
81-
seq {
82-
yield SparseRow.fromValues [assaysLabel]
83-
yield! Assays.toRows (Some assaysPrefix) [assay]
84-
85-
yield SparseRow.fromValues [contactsLabel]
86-
yield! Contacts.toRows (Some contactsPrefix) (List.ofSeq assay.Performers)
87-
}
8884
assay
8985
|> toRows
9086
|> Seq.map (fun row -> SparseRow.getAllValues row)
9187

9288
let fromMetadataCollection (collection: seq<seq<string option>>) : ArcAssay =
9389
try
94-
let fromRows (usePrefixes: bool) (rows: seq<SparseRow>) =
95-
let aPrefix, cPrefix =
96-
if usePrefixes then
97-
Some assaysPrefix, Some contactsPrefix
98-
else None, None
99-
let en = rows.GetEnumerator()
100-
let rec loop lastRow assays contacts rowNumber =
101-
102-
match lastRow with
103-
| Some prefix when prefix = assaysLabel || prefix = obsoleteAssaysLabel ->
104-
let currentRow, rowNumber, _, assays = Assays.fromRows aPrefix (rowNumber + 1) en
105-
loop currentRow assays contacts rowNumber
106-
107-
| Some prefix when prefix = contactsLabel ->
108-
let currentLine, rowNumber, _, contacts = Contacts.fromRows cPrefix (rowNumber + 1) en
109-
loop currentLine assays contacts rowNumber
110-
| _ ->
111-
match assays, contacts with
112-
| [], [] -> ArcAssay.create(Identifier.createMissingIdentifier())
113-
| assays, contacts ->
114-
assays
115-
|> Seq.tryHead
116-
|> Option.defaultValue (ArcAssay.create(Identifier.createMissingIdentifier()))
117-
|> ArcAssay.setPerformers (ResizeArray contacts)
118-
119-
if en.MoveNext () then
120-
let currentLine = en.Current |> SparseRow.tryGetValueAt 0
121-
loop currentLine [] [] 1
122-
123-
else
124-
failwith "empty assay metadata sheet"
12590
let rows =
12691
collection
127-
|> Seq.map SparseRow.fromAllValues
128-
let hasPrefix =
129-
rows
130-
|> Seq.exists (fun row -> row |> Seq.head |> snd |> fun s -> s.StartsWith(assaysPrefix))
92+
|> Seq.map SparseRow.fromAllValues
13193
rows
132-
|> fromRows hasPrefix
94+
|> fromRows
13395
with
13496
| err -> failwithf "Failed while parsing metadatasheet: %s" err.Message
13597

src/Spreadsheet/ArcStudy.fs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
namespace ARCtrl.Spreadsheet
22

33
open ARCtrl
4-
open FsSpreadsheet
5-
64
open ARCtrl.Helper
5+
open FsSpreadsheet
76

87
module ArcStudy =
98

@@ -25,13 +24,14 @@ module ArcStudy =
2524
|> Seq.iteri (fun rowI r -> SparseRow.writeToSheet (rowI + 1) r sheet)
2625
sheet
2726

27+
let fromRows (rows: seq<SparseRow>) =
28+
let en = rows.GetEnumerator()
29+
en.MoveNext() |> ignore
30+
let _, _, _,study = Studies.fromRows 2 en
31+
study
32+
2833
let fromMetadataSheet (sheet: FsWorksheet) : ArcStudy*ArcAssay list =
29-
try
30-
let fromRows (rows: seq<SparseRow>) =
31-
let en = rows.GetEnumerator()
32-
en.MoveNext() |> ignore
33-
let _, _, _,study = Studies.fromRows 2 en
34-
study
34+
try
3535
sheet.Rows
3636
|> Seq.map SparseRow.fromFsRow
3737
|> fromRows
@@ -46,11 +46,6 @@ module ArcStudy =
4646

4747
let fromMetadataCollection (collection: seq<seq<string option>>) : ArcStudy*ArcAssay list =
4848
try
49-
let fromRows (rows: seq<SparseRow>) =
50-
let en = rows.GetEnumerator()
51-
en.MoveNext() |> ignore
52-
let _, _, _,study = Studies.fromRows 2 en
53-
study
5449
collection
5550
|> Seq.map SparseRow.fromAllValues
5651
|> fromRows

src/Spreadsheet/Template.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
namespace ARCtrl.Spreadsheet
22

33
open FsSpreadsheet
4+
open ARCtrl
45
open ARCtrl.Helper
56
open ARCtrl.Spreadsheet
6-
open ARCtrl
77
open System.Collections.Generic
88

99
exception TemplateReadError of string

0 commit comments

Comments
 (0)