-
Notifications
You must be signed in to change notification settings - Fork 2
/
playground.fsx
769 lines (618 loc) · 24.7 KB
/
playground.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
#r "nuget: FSharpAux"
#r "nuget: OBO.NET"
#r "nuget: FsSpreadsheet.ExcelIO, 4.1.0"
#I "src/ControlledVocabulary/bin/Debug/netstandard2.0"
#I "src/ControlledVocabulary/bin/Release/netstandard2.0"
#r "ControlledVocabulary.dll"
#I "src/ARCTokenization/bin/Debug/netstandard2.0"
#I "src/ARCTokenization/bin/Release/netstandard2.0"
#r "ARCTokenization.dll"
open FsSpreadsheet
open FsSpreadsheet.ExcelIO
open OBO.NET
open ControlledVocabulary
open type ControlledVocabulary.ParamBase
open ARCTokenization
open ARCTokenization.StructuralOntology
open System.IO
let arcProt = @"C:\Repos\git.nfdi4plants.org\ArcPrototype"
let afts = FileSystem.parseAbsoluteFilePaths arcProt
afts |> Seq.iter (Param.getValueAsString >> printfn "%s")
let tryParseMetadataSheetFromToken (isaFileName: string) (isaMdsParsingF: string -> IParam list) (absFileToken: IParam) =
let cvpStr = Param.getValueAsString absFileToken
printfn $"cvpStr: {cvpStr}"
//if String.contains isaFileName cvpStr then
if Path.GetFileName cvpStr = isaFileName then
try
Some (isaMdsParsingF cvpStr)
with _ ->
None
else None
afts
|> Seq.map (
fun cvp ->
printfn $"{Param.getValueAsString cvp}"
tryParseMetadataSheetFromToken "isa.investigation.xlsx" (Investigation.parseMetadataSheetFromFile()) cvp
)
|> Seq.length
let its = Investigation.parseMetadataSheetsFromTokens() afts
System.IO.Directory.GetCurrentDirectory()
let fakePath = CvParam(cvTerm = AFSO.``File Path``, v = System.IO.Directory.GetCurrentDirectory() + "/tests/ARCTokenization.Tests/Fixtures/correct/investigation_simple.xlsx")
let fakePath = CvParam(cvTerm = AFSO.``File Path``, v = "tests/ARCTokenization.Tests/Fixtures/correct/assay_simple.xlsx")
let actual = ParamBasedParsers.parseIsaMetadataSheetFromCvp "assay_simple.xlsx" Assay.parseMetadataSheetFromFile [fakePath] |> Seq.head
actual.Length
let exp =
ARCMock.AssayMetadataTokens(
Assay_File_Name = [@"measurement1\isa.assay.xlsx"],
Assay_Performer_First_Name = ["Oliver"; "Marius"],
Assay_Performer_Last_Name = ["Maus"; "Katz"],
Assay_Performer_Mid_Initials = [""; "G."],
Assay_Performer_Email = ["[email protected]"],
Assay_Performer_Affiliation = ["RPTU University of Kaiserslautern"],
Assay_Performer_Roles = ["research assistant"],
Assay_Performer_Roles_Term_Accession_Number = ["http://purl.org/spar/scoro/research-assistant"],
Assay_Performer_Roles_Term_Source_REF = ["scoro"]
)
|> List.concat
exp.Length
actual |> List.fold (fun acc ip -> $"{acc}\n{ip.Name}") "" |> printfn "%s"
exp |> List.iter (fun ip -> printfn $"{ip.Name}")
for i = 0 to 33 do
printfn $"{List.tryItem i actual |> Option.map (fun x -> x.Name) |> Option.defaultValue System.String.Empty}\t{List.tryItem i exp |> Option.map (fun x -> x.Name) |> Option.defaultValue System.String.Empty}"
let testAccession1 = "TO:00000001"
let testName1 = "Test"
let testRef1 = "TO"
let testTerm1 = CvTerm.create(accession = testAccession1, name = testName1, ref = testRef1)
let testAccession2 = "TO:00000002"
let testName2 = "5"
let testRef2 = "TO"
let testTerm2 = CvTerm.create(accession = testAccession2, name = testName2, ref = testRef2)
let ``CvParam with ParamValue.Value`` = CvParam(testTerm1, ParamValue.Value 5)
let ``CvParam with ParamValue.CvValue`` = CvParam(testTerm1, ParamValue.CvValue testTerm2)
let ``CvParam with ParamValue.WithCvUnitAccession`` = CvParam(testTerm2, ParamValue.WithCvUnitAccession (5, testTerm1))
let testCvParams =
[
``CvParam with ParamValue.Value``
``CvParam with ParamValue.CvValue``
``CvParam with ParamValue.WithCvUnitAccession``
]
let testCvp1 = CvParam("test", "test", "test", ParamValue.Value "test", Dictionary<string,IParam>() |> fun d -> d.Add("test", testCvParams.Head); d)
let testCvp2 = CvParam("test", "test", "test", ParamValue.Value "test", Dictionary<string,IParam>() |> fun d -> d.Add("test", testCvParams.Head); d)
let actual = testCvp1 = testCvp2
testCvp1.GetHashCode()
testCvp2.GetHashCode()
let expectedTermValuesSimple =
[
[""]
[""]
[""]
[""]
[""]
[""]
[""; "iid"]
[""; "ititle"]
[""; "idesc"]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""; "Maus"; "Keider"; "müller"; "oih"]
[""; "Oliver"; "andreas"]
[""; "L. I."; "C."]
[""; "[email protected]"]
[""]
[""]
[""]
[""; "Affe"]
[""]
[""]
[""]
[""]
[""; "sid"]
[""; "stitle"]
[""; "sdesc"]
[""]
[""]
[""; "sid\isa.study.xlsx"]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""; "aid\isa.assay.xlsx"; "aid2\isa.assay.xlsx"]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""; "weil"]
[""; "lukas"]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
[""]
]
let allExpectedMetadataTermsFull =
Terms.InvestigationMetadata.cvTerms
|> List.skip 1 //(ignore root term)
|> List.zip expectedTermValuesSimple
|> List.map (fun (values,term) ->
values
|> List.mapi (fun i v ->
if i = 0 then
CvParam(term, ParamValue.CvValue (CvTerm("AGMO:00000001", "Metadata Section Key", "AGMO")), [])
else
CvParam(term, ParamValue.Value v, [])
)
)
|> List.concat
allExpectedMetadataTermsFull.Length
let parsedInvestigationMetadataSimple = Investigation.parseMetadataSheetFromFile (__SOURCE_DIRECTORY__ + "/tests/ArcGraphModel.Tests/Fixtures/correct/investigation_simple.xlsx")
parsedInvestigationMetadataSimple.Length
let i_fs = FsWorkbook.fromXlsxFile (__SOURCE_DIRECTORY__ + "/tests/ArcGraphModel.Tests/Fixtures/correct/investigation_simple.xlsx")
(FsWorkbook.getWorksheetByName "isa_investigation" i_fs).CellCollection.GetCells()
|> Seq.filter(fun c -> c.RowNumber = 1)
parsedInvestigationMetadataSimple
|> List.skip 10
|> List.take 10
// Assay annotation table parsing
let assayTokens = Assay.parseAnnotationTablesFromFile (__SOURCE_DIRECTORY__ + "/tests/ArcGraphModel.Tests/Fixtures/correct/assay_with_single_characteristics.xlsx")
// Investigation metadata parsing
let investigationTokens = Investigation.parseMetadataSheetfromXlsxFile (__SOURCE_DIRECTORY__ + "/tests/ArcGraphModel.Tests/Fixtures/correct/full_investigation_mkay.xlsx")
//let inves = FsWorkbook.fromXlsxFile @"C:\Users\revil\OneDrive\CSB-Stuff\NFDI\testARC30\isa.investigation.xlsx"
//let inves = FsWorkbook.fromXlsxFile @"C:\Users\olive\OneDrive\CSB-Stuff\NFDI\testARC30\isa.investigation.xlsx"
let inves = FsWorkbook.fromXlsxFile (__SOURCE_DIRECTORY__ + "/tests/ArcGraphModel.Tests/Fixtures/correct/full_investigation_mkay.xlsx")
let invesWs = FsWorkbook.getWorksheets inves |> Seq.head
invesWs.RescanRows()
invesWs.CellCollection
invesWs.Rows[20] |> Seq.toList
//let invesWsParsed = ArcGraphModel.IO.Worksheet.parseRowsAggregated invesWs
//let invesWsParsed = ArcGraphModel.IO.Worksheet.parseColumnsAggregated invesWs
let invesWsParsed = ArcGraphModel.Worksheet.parseRowsFlat invesWs
//invesWsParsed |> Seq.cast<CvParam>
invesWsParsed |> Seq.cast<IParamBase> |> Seq.cast<CvParam>
//invesWsParsed |> List.map (fun x -> x :> CvParam)
invesWsParsed
//|> List
|> List.mapi (
fun i x ->
printfn "\n%i\n" i
match x with
| :? CvParam as p ->
printfn "CvParam"
CvBase.getCvName p |> printfn "CvName: %s"
Param.getValue p |> printfn "Value: %A"
//p.ToString()
p.Attributes.ToString() |> printfn "Attributes: %A"
//| :? UserParam as p ->
// printfn "UserParam"
// CvBase.getCvName p |> printfn "CvName: %s"
// Param.getValue p |> printfn "Value: %A"
// //p.ToString()
// p.Attributes.ToString() |> printfn "Attributes: %A"
| _ -> ()
)
invesWsParsed
invesWsParsed |> List.iter ((printfn "%A"))
invesWsParsed.Head |> printfn "%A"
invesWsParsed.Head |> printfn "%O"
(invesWsParsed.Head :?> CvAttributeCollection)
invesWsParsed.Head.ToString()
[1 .. 10] |> printfn "%A"
[1 .. 10] |> printfn "%O"
open System.Text.RegularExpressions
let namePattern = @"(?<=\[).*(?=[\]])"
let key = "Comment[<Investigation Person ORCID>]"
Regex.tryParseValue namePattern key
|> Option.map (fun n ->
CvTerm("",n,"")
)
|> Option.get
|> fun term -> CvParam(term,ParamValue.Value "Hallo",[])
let lol = CvParam("lol", "lol", "lol", ParamValue.Value "lol")
let lol2 = CvParam("lol", "lol", "lol", ParamValue.Value "lol")
lol = lol2
let dict1 = Dictionary<string,string>()
dict1.Add("kek", "lil")
let dict2 = Dictionary<string,string>()
dict2.Add("kek", "lil")
dict1 = dict2
// new CvTypes - testin' and foolin' around
//type CvParam(cvAccession : string, cvName : string, cvRefUri : string, paramValue : ParamValue, qualifiers : IDictionary<string,CvParam>) =
// inherit Dictionary<string,CvParam>(qualifiers)
// let mutable _cvContainers = Dictionary<string,CvContainer list>()
// interface ICvBase with
// member this.ID = cvAccession
// member this.Name = cvName
// member this.RefUri = cvRefUri
// interface IParamBase with
// member this.Value = paramValue
// new (id,name,ref,pv,qualifiers : seq<CvParam>) =
// let dict =
// qualifiers
// |> Seq.map (fun cvp -> (cvp :> ICvBase).Name, cvp)
// |> Dictionary.ofSeq
// CvParam (id,name,ref,pv,dict)
// new (id,name,ref,pv) =
// CvParam (id,name,ref,pv,Seq.empty)
// new ((id,name,ref) : CvTerm,pv,qualifiers : seq<CvParam>) =
// CvParam (id,name,ref,pv,qualifiers)
// new (cvTerm,pv : ParamValue) =
// CvParam (cvTerm,pv,Seq.empty)
// member this.CvContainers
// with private get() = _cvContainers
// //with get(item) = _cvContainers[item]
// and private set(item, value) = _cvContainers[item] <- value
// member this.CvContainers.Item item =
// this.CvContainers[item]
// static member addCvContainerItem (item : CvContainer list) (cvParam : CvParam) =
// cvParam.CvContainers.Add(item.Head |> CvBase.getCvName, item)
//// working backwards
//let tryAddVertex vertex graph =
// try ArrayAdjacencyGraph.Vertices.add vertex graph
// with _ -> graph
//let tryAddEdge vertex1 vertex2 edge graph =
// try ArrayAdjacencyGraph.Edges.add (vertex1, vertex2, edge) graph
// with _ -> graph
//let cvParamsToGraph (cvParams : CvParam list) =
// cvParams
// |> List.fold (
// fun graph cvp ->
// let label =
// cvp :> IParamBase
// |> ParamBase.getValue :?> IParamBase
// |> ParamBase.getValue :?> CvParam
// match BuildingBlockType.tryOfString (cvp :> ICvBase).Name with
// | Some Sample
// | Some RawDataFile
// | Some DerivedDataFile
// | Some Source ->
// let vertexId =
// label :> IParamBase
// |> ParamBase.getValue :?> ICvBase
// |> CvBase.getCvName
// let vertex = LVertex (vertexId, label)
// tryAddVertex vertex graph
// | Some Parameter
// | Some Characteristic
// | Some Factor
// | Some Component ->
// let vertex1id =
// cvp["Address"] // string * int * int
// tryAddEdge
// //| Some (Freetext e) ->
// // let vertex1id =
// // cvp["Address"] // string * int * int
// // tryAddEdge
// ) (Graph.create [] [])
//let fp = @"C:\Users\olive\OneDrive\CSB-Stuff\NFDI\testARC30\assays\aid\isa.assay.xlsx"
////let fp = @"C:\Users\revil\OneDrive\CSB-Stuff\NFDI\testARC30\assays\aid\isa.assay.xlsx"
//let wb = FsWorkbook.fromXlsxFile fp
//let shts = FsWorkbook.getWorksheets wb
////let mutable testDic = new Dictionary<string,int>()
////testDic.Add("first", 24)
////testDic.Add("second", 1337)
////testDic.Add("third", 69)
////let oldTestDic = testDic
////testDic <- new Dictionary<string,int>()
////let testDic2 = new Dictionary<int,Dictionary<int,string>>()
////let testDic3 = new Dictionary<int,string>()
////testDic3.Add(3,"sheesh")
////testDic3.Add(4,"shnash")
////testDic2.Add(2,testDic3)
////testDic2.Add(6,testDic3)
////testDic2.Values |> Seq.minBy (fun d -> d.Keys |> Seq.min) |> fun d -> d.Keys |> Seq.min
//let tbls = FsWorkbook.getTables wb
//let tblsFiltered = tbls |> List.filter (fun t -> String.contains "annotationTable" t.Name)
//let tbl1 = tblsFiltered.Head
//let associatedWorksheet = shts.Head
//let fcc = associatedWorksheet.CellCollection
////tbl1.Field("Source Name", fcc).DataCells(fcc, false) |> Seq.length
////tbl1.Field("Source Name", fcc).DataCells(fcc, true)
////tbl1.RescanRange()
////tbl1.Field("test", fcc).DataCells(fcc, false)
////tbl1.FieldNames
///// Takes an FsWorkbook and returns all Annotation Tables it contains.
//let getAnnotationTables workbook =
// let tables = FsWorkbook.getTables workbook
// tables |> List.filter (fun t -> String.contains "annotationTable" t.Name)
//(getAnnotationTables wb).Head.CellsCollection.Count
//let getColumnHeaders (table : FsTable) =
// let range = table.HeadersRow()
// range.RangeAddress
// table.GetHeaderCell
////let ioToCvParam headerCell dataCell =
////let buildingBlockToCvParam headerCell dataCells =
//let columnHeadersRowAddress = tbl1.HeadersRow().RangeAddress.FirstAddress.RowNumber
//let columnHeaders = associatedWorksheet.CellCollection.GetCellsInRow columnHeadersRowAddress |> List.ofSeq
//let nodeHeaders, edgeHeaders = columnHeaders |> List.partition (fun c -> List.contains c.Value nodeColumnNames)
//let groupedEdgeHeaders = edgeHeaders |> Seq.groupWhen (fun h -> String.contains "[" h.Value) |> List.ofSeq |> List.map List.ofSeq
////let nodeHeaders = columnHeaders |> List.filter (fun ch -> List.contains ch.Value nodeColumnNames)
////let groupedHeadersStr =
////let ftf = FsTableField()
////let header1 = tbl1.Field("Source Name", fcc)
////header1.DataCells(fcc, true)
////header1.DataCells(fcc, false) |> Seq.length
////header1.Index
////let header2 = tbl1.Field("Parameter [Protocol]", fcc)
////header2.Index
////tbl1.RescanRange()
////tbl1.FieldNames(obj)
////parse true (groupedHeaders |> Array.collect (Array.map (fun c -> c.Value)) |> List.ofArray)
////groupedHeaders |> Array.map (parse true (groupedHeaders |> Array.collect (Array.map (fun c -> c.Value)) |> List.ofArray))
////// for FsCells & CvParams
////type BuildingBlock<'a> =
//// | Triple of ('a * 'a * 'a)
//// | Quadruple of ('a * 'a * 'a * 'a)
//let parsedNodes = List.map (parseNode fcc) nodeHeaders
//let parsedEdges = List.map (parseEdges true fcc) groupedEdgeHeaders
//let nodeTypes = parsedNodes |> List.map (List.map getNodeType)
//parsedNodes.Head.Head |> ArcGraphModel.ParamBase.getValue
//parsedNodes.Head[1] |> ArcGraphModel.ParamBase.getValue
//parsedNodes.Length
//parsedNodes.Head.Length
//parsedEdges.Head.Head |> ArcGraphModel.CvBase.getCvAccession
//parsedEdges.Head.Head |> ArcGraphModel.ParamBase.getValue
//parsedEdges.Head[1] |> ArcGraphModel.ParamBase.getValue
//parsedEdges |> List.map (List.map ParamBase.getValue)
//parsedEdges |> List.map (List.map CvBase.getCvName)
//let sourceNodes, sinkNodes, protocolRefNodes = separateNodes (List.concat parsedNodes)
//let t2 = tbls.Item 1
//let assWs2 = FsTable.getWorksheetOfTable wb t2
//let fcc2 = assWs2.CellCollection
//let columnHeadersRowAddress2 = t2.HeadersRow().RangeAddress.FirstAddress.RowNumber
//let columnHeaders2 = fcc2.GetCellsInRow columnHeadersRowAddress2 |> List.ofSeq
//let nodeHeaders2, edgeHeaders2 = columnHeaders2 |> List.partition (fun c -> List.contains c.Value nodeColumnNames)
//let groupedEdgeHeaders2 = edgeHeaders2 |> Seq.groupWhen (fun h -> String.contains "[" h.Value) |> List.ofSeq |> List.map List.ofSeq
//let parsedEdges2 = groupedEdgeHeaders2 |> List.map (parseEdges true fcc2)
////let nodeHeaders2 = columnHeaders2 |> List.filter (fun ch -> List.contains ch.Value nodeColumnNames)
//let parsedNodes2 = nodeHeaders2 |> List.map (parseNode fcc2)
//let testGraph = initGraphWithElements (snd sourceNodes) parsedEdges (snd sinkNodes)
//testGraph.EdgeCount
//testGraph.VertexCount
//let extractedVertices = testGraph.GetVertices()
////let extractedVertices : LVertex<int,CvParam<string>> = testGraph.GetVertices()
//let extractedEdges = testGraph.GetEdges()
////Graph.get
//testGraph.GetLabels()
////testGraph.
//Graph.extractVerticesWithLabels
//let (sourceNodes2, sinkNodes2, protocolRefNodes2) = separateNodes (List.concat parsedNodes2)
//let testParamValue = ParamValue.Value "testParamValue.Value"
//let testCvParam = CvParam("testCvParamTAN", "testCvParamName", "testCvParamTSR", testParamValue)
//// function input
//let newSources = snd sourceNodes2
//let newSinks = snd sinkNodes2
//let newEdges = parsedEdges2
//newEdges.Length
//newEdges.Head.Length
//let graph = testGraph
// function body
//let maxIndex = testGraph.VertexCount
//let indexedSources = List.mapi (fun i s -> i + maxIndex + 1, s) newSources
//let indexedSinks = List.mapi (fun i s -> i + maxIndex + indexedSources.Length + 1, s) newSinks
//testGraph.AddManyVertices()
///// <summary>
///// Takes an indexed input list (e.g. a list of Sources) and groups them by their occurence. Returns the first index of the occurence
///// and the value as tuple.
///// </summary>
///// <example>
///// E.g.: `["Hello"; "Hello"; "Hello"; "World"; "World"; "lol"] |> List.indexed |> convolve` leads to
///// `[(0, "Hello"); (3, "World"); (5, "lol")]`
///// </example>
//let convolve input =
// input
// |> List.groupBy snd
// |> List.map (fun (k,il) -> List.map fst il |> List.min, k)
//["Hello"; "Hello"; "Hello"; "World"; "World"; "lol"] |> List.indexed |> convolve
//[["R1,C1"; "R2,C1"]; ["R1,C2"; "R2,C2"]] |> List.transpose
//let sources = snd sourceNodes
//let sources = List.init sources.Length (fun _ -> sources.Head)
//let sinks = snd sinkNodes
//let edges = parsedEdges
//extractVerticesWithLabels graph
//let toVertices paramList : LVertex<string,CvParam<string>> list =
// paramList
// |> List.map (
// fun s -> Param.getValue s, s
// )
// // since a graph must not have duplicate keys, we distinct by key here
// //|> List.distinctBy fst // do that later
//let sourceVertices = sources |> toVertices
//let sinkVertices = sinks |> toVertices
//let sourceVertices, sinkVertices, connectedEdges =
// (sources, sinks, edges)
// |||> List.map3 (
// fun source sink edge ->
// 0
// )
//let connectedEdges =
// edges
// |> List.map (
// List.mapi (
// fun i e -> fst sourceVertices[i], fst sinkVertices[i], e
// )
// )
/////
//let initGraphWithElements sources edges sinks =
// let sourceVertices : LVertex<string,CvParam<string>> list =
// sources
// |>
//let buildSourceSinkConnection sources edges sinks =
//let initGraphWithElements sources edges sinks =
// let sources = snd sourceNodes
// let sinks = snd sinkNodes
// let edges = parsedEdges
// let indexedSources = List.indexed sources
// //let indexedEdges = List.indexed edges
// let maxIndex = indexedSources.Length - 1
// let indexedSinks = List.mapi (fun i s -> i + maxIndex + 1, s) sinks
// //let convolvedSources = convolve indexedSources
// //let convolvedSinks = convolve indexedSinks
// //let links =
// // let len = indexedSources.Length
// // let newIndSinks = convolvedSinks |> List.map (fun (i,s) -> i + len, s)
// //if indexedSinks
// let sourceVertices : LVertex<'a,'b> list = indexedSources
// let sinkVertices : LVertex<'a,'b> list = indexedSinks
// let indexedEdges : LEdge<'a,'b> list list =
// edges
// |> List.map (
// List.mapi (
// fun i e -> i, i + maxIndex + 1, e
// )
// )
// Graph.create (sourceVertices @ sinkVertices) (List.concat indexedEdges)
//let testVertex : LVertex<int,string> = (0,"Hallo")
//let testVertex2 : LVertex<int,string> = (1,"Hallo")
//let testEdge : LEdge<int,string> = (0,1,"ich bin edgy")
//let testGraph2 = Graph.create [testVertex; testVertex2] [testEdge]
//(testGraph2.GetVertices(), testGraph2.GetLabels()) ||> Array.map2 (fun x y -> x,y)
//let nodeList = parsedNodes
//let linkList = parsedEdges
//let singleSourceNode = nodeList.Head.Head
//let singleSinkNode = nodeList[1].Head
//let singleEdge = linkList.Head.Head
//let singleSourceNode = nodeList.Head.Head :?> UserParam<string>
//let singleSinkNode = nodeList[1].Head :?> UserParam<string>
//let singleEdge = linkList.Head.Head :?> CvParam<string>
//let sourceNodeList, sinkNodeList =
// let part (input : ('a*'b) list) = snd input.Head
// parsedNodes
// |> List.map (List.groupBy getNodeType >> List.head)
// |> List.partition (fst >> (=) Source)
// |> fun (sonl,sinl) -> part sonl, part sinl
//sourceNodeList
//let vertexList : LVertex<int,CvParam<string>> list = [
////let vertexList : LVertex<int,UserParam<string>> list = [
// 0, singleSourceNode
// 1, singleSinkNode
//]
//let edgeList : LEdge<int,CvParam<string>> list = [
////let edgeList : LEdge<int,CvParam<string>> list = [
// (0,1,singleEdge)
//]
//groupedHeaders2 |> List.map (parseEdges true fcc2)
//groupedHeaders2.Head.Length
//groupedHeaders2 |> List.map List.length
//groupedHeaders2 |> List.mapi (fun i x -> printfn "%i" i; parseEdges true fcc2 x)
//groupedHeaders2[2].Length
//groupedHeaders2.Head |> parseEdges true fcc2
//groupedHeaders2[1] |> parseEdges true fcc2
//groupedHeaders2[2] |> parseEdges true fcc2
//groupedHeaders2[2].Head
//groupedHeaders2[2][1]
//groupedHeaders2[2][2]
//groupedHeaders2[2][3]
//FsCellsCollection.getCellsInColumn groupedHeaders2[2].Head.ColumnNumber fcc |> Seq.toList
//fcc[1,7]
//groupedHeaders2[2].Head.ColumnNumber
//groupedHeaders2[2][1]
//groupedHeaders2[2][2]
//let res = groupedHeaders2 |> List.map (parseEdges true)
//let antiEmptyChecker str = if str = "" then "(empty)" else str
//res
//|> List.collect (
// List.map (fun (c1,c2,c3) ->
// (antiEmptyChecker c1.Value, antiEmptyChecker c2.Value, antiEmptyChecker c3.Value)
// |> fun (c1n,c2n,c3n) ->
// printfn "%s %s %s" c1n c2n c3n; c1n, c2n, c3n)
//)
//assWs2.CellCollection.GetCellsInColumn(11)
//let getKvTriplets (headerTriplets : FsCell [] []) (workbook : FsWorkbook) (table : FsTable) =
// let workbook = wb
// let table = tbl1
// let headerTriplets = groupedHeaders
// let associatedWorksheet = table.GetWorksheetOfTable workbook
// let columnHeadersRowAddress = table.HeadersRow().RangeAddress.FirstAddress.RowNumber
// //let columnHeadersColAddress =
// //let columnHeadersValues = table.FieldNames(associatedWorksheet.CellCollection)
// let columnHeadersValues =
// headerTriplets
// |> Array.map (
// Array.map (
// fun c ->
// table.Field(c.Value, associatedWorksheet.CellCollection)
// )
// )
// let mutable tripleCounter = 0
// let mutable doubleCounter = 0
// //let raiseTc () =
// // if tripleCounter = 3 then tripleCounter <- 1
// // else tripleCounter <- tripleCounter + 1
// let raiseDc () =
// if doubleCounter = 2 then doubleCounter <- 1
// else doubleCounter <- doubleCounter + 1
// let satisfier = String.contains "["
// headerTriplets
// |> Array.map (
// fun ht ->
// ht
// |> Array.map (
// fun h ->
// if satisfier h then tripleCounter <- 1
// else tripleCounter <- tripleCounter + 1
// match tripleCounter with
// | 1 ->
// | x when x <= 3 && x > 1 ->
// | x when x > 3 ->
// raiseDc ()
// )
// )
// let rec loop tripleCounter doubleCounter =
// if en.MoveNext() then
// let e = en.Current
// let updatedTripleCounter = tripleCounter + 1
// let colI = cellsColl.TryGetCell
// else
//headerTriplets
//|> Seq.map (
// fun seq1 ->
// use en = input.GetEnumerator()
// loop id
//)
//0
// let rec sheesh tripleCounter doubleCounter