Skip to content

Commit 327d9eb

Browse files
committed
add assay file data column parser
1 parent f783a15 commit 327d9eb

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/ISADotNet.XLSX/AssayFile/AnnotationColumn.fs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,18 @@ module AnnotationColumn =
132132
Some h
133133
| _ -> None
134134

135+
/// Parses to ColumnHeader, if the given header describes a data file
136+
let tryParseDataFileName (header:string) =
137+
match ColumnHeader.fromStringHeader header with
138+
| h when h.Kind = "Data File Name" -> Some h
139+
| h when h.Kind = "Raw Data File" -> Some h
140+
| h when h.Kind = "Derived Data File" -> Some h
141+
| h when h.Kind = "Image File" -> Some h
142+
| _ -> None
143+
144+
/// Returns true, if the given header describes a data column
145+
let isData header = tryParseDataFileName header |> Option.isSome
146+
135147
/// Returns true, if the given header describes a sample name
136148
let isSample header = tryParseSampleName header |> Option.isSome
137149

src/ISADotNet.XLSX/AssayFile/AnnotationNode.fs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,27 @@ module AnnotationNode =
171171
(unitGetter |> Option.map (fun f -> f matrix i))
172172
)
173173

174+
/// If the headers of a node depict a sample name, returns a function for parsing the values of the matrix to the sample names
175+
let tryGetDataFileGetter (headers:string seq) =
176+
Seq.tryPick tryParseDataFileName headers
177+
|> Option.map (fun h ->
178+
179+
let dataType =
180+
if h.Kind = "Image File" then Some DataFile.ImageFile
181+
elif h.Kind = "Raw Data File" then Some DataFile.RawDataFile
182+
elif h.Kind = "Derived Data File" then Some DataFile.DerivedDataFile
183+
else None
184+
let numberComment = h.Number |> Option.map (string >> (Comment.fromString "Number") >> List.singleton)
185+
186+
fun (matrix : System.Collections.Generic.Dictionary<(string * int),string>) i ->
187+
188+
Data.create
189+
None
190+
(Dictionary.tryGetValue (h.HeaderString,i) matrix)
191+
dataType
192+
numberComment
193+
)
194+
174195
/// If the headers of a node depict a sample name, returns a function for parsing the values of the matrix to the sample names
175196
let tryGetSampleNameGetter (headers:string seq) =
176197
Seq.tryPick tryParseSampleName headers

0 commit comments

Comments
 (0)