-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.fsx
192 lines (140 loc) · 4.39 KB
/
test.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
#r "nuget: FSharpAux.Core,2.0.0"
#r "nuget: FsSpreadsheet, 1.3.0-preview"
#r "nuget: FsSpreadsheet.ExcelIO"
//#I @"src\ArcGraphModel\bin\Release\net6.0"
#I @"src\ArcGraphModel.IO\bin\Release\net6.0"
#r "ArcGraphModel.dll"
#r "ArcGraphModel.IO.dll"
#r "nuget: ArcGraphModel, 0.1.0-preview.1"
open FsSpreadsheet
open ArcGraphModel
open ArcGraphModel.IO
open FSharpAux
open FsSpreadsheet.ExcelIO
//fsi.AddPrinter (fun (cvp : CvParam) ->
// cvp.ToString()
//)
//fsi.AddPrinter (fun (cvp : CvContainer) ->
// cvp.ToString()
//)
fsi.AddPrinter (fun (cvp : ICvBase) ->
match cvp with
| :? UserParam as cvp -> $"UserParam [{CvBase.getCvName cvp}]"
| :? CvParam as cvp -> $"CvParam [{CvBase.getCvName cvp}]"
| :? CvContainer as cvp -> $"CvContainer [{CvBase.getCvName cvp}]"
| _ -> $"ICvBase [{CvBase.getCvName cvp}]"
)
let p = @"C:\Users\HLWei\Downloads\testArc\isa.investigation.xlsx"
let shortP = @"C:\Users\HLWei\Downloads\testArc\testPersons.xlsx"
let pa = @"C:\Users\HLWei\Downloads\testArc\testAssay.xlsx"
let inv = FsWorkbook.fromXlsxFile pa
let worksheet =
let ws = inv.GetWorksheets().Head
ws.RescanRows()
ws
let tokens =
//worksheet.Tables.[0].Columns(worksheet.CellCollection)
//|> Seq.toList
//|> List.choose (fun r ->
// match r.Cells |> Tokenization.parseLine |> Seq.toList with
// | [] -> None
// | l -> Some l
// )
//|> List.concat
worksheet
|> Worksheet.parseTableColumns
tokens
|> Seq.head
|> CvAttributeCollection.tryGetAttribute (CvTerm.getName Address.worksheet)
|> Option.get
|> Param.getValue
tokens.[tokens.Length - 1].ToString()
tokens
|> List.choose (CvBase.tryAs<IParam>)
|> List.map (fun param ->
CvBase.getTerm param,
Param.getValue param
)
let containers =
tokens
|> TokenAggregation.aggregateTokens
|> List.filter (fun cv -> CvBase.is<UserParam> cv |> not)
containers
|> List.choose (CvContainer.tryCvContainer)
|> List.filter (CvBase.equalsTerm Terms.assay)
|> List.item 0
|> CvContainer.getSingleAs<IParam>("File Name")
|> Param.getValue
containers.[2].ToString()
containers
|> Seq.choose CvContainer.tryCvContainer
|> Seq.filter (fun cv -> CvBase.equalsTerm Terms.assay cv )
|> Seq.head
|> CvContainer.getSingleParam "File Name"
|> Param.getValue
//let paramLine =
// [
// FsCell("Investigation Person Last Name")
// FsCell("Müller")
// ]
//let paramLine2 =
// [
// FsCell("Factor [temperature]")
// FsCell("5")
// ]
//let paramToken =
// let attributes =
// [
// CvParam(Terms.investigation,ParamValue.Value "") :> IParam
// CvParam(Terms.person,ParamValue.Value "")
// ]
// CvParam(Terms.familyName,ParamValue.Value "Müller", attributes)
//let containerLine =
// [
// FsCell("INVESTIGATION CONTACTS")
// ]
//let cvParams = Line.convertTokens paramLine2
//cvParams.Length
//cvParams.Head
//|> CvBase.getCvName
//cvParams.Head
//|> ParamBase.getValue
//let tripletLines =
// [
// [
// FsCell("Investigation Publication Status")
// FsCell("Pending")
// ]
// [
// FsCell("Investigation Publication Status Term Accession Number")
// FsCell("ontobee.com/PO_123")
// ]
// [
// FsCell("Investigation Publication Status Term Source REF")
// FsCell("PO")
// ]
// ]
//let tripletToken =
// let attributes =
// [
// CvParam(Terms.investigation,ParamValue.Value "") :> IParam
// CvParam(Terms.publication,ParamValue.Value "")
// ]
// let attributes2 =
// [
// CvParam(Terms.investigation,ParamValue.Value "") :> IParam
// CvParam(Terms.publication,ParamValue.Value "")
// CvParam(Terms.status,ParamValue.Value "")
// ]
// [
// CvParam(Terms.status,ParamValue.Value "Pending", attributes)
// CvParam(Terms.annotationID,ParamValue.Value "ontobee.com/PO_123", attributes)
// CvParam(Terms.termSourceRef,ParamValue.Value "PO", attributes2)
// ]
//let combinedToken =
// let attributes =
// [
// CvParam(Terms.investigation,ParamValue.Value "") :> IParam
// CvParam(Terms.publication,ParamValue.Value "")
// ]
// CvParam(Terms.status,ParamValue.CvValue ("ontobee.com/PO_123","Pending","PO"), attributes)