Skip to content

Commit

Permalink
add component and protocoltype parsers to assay xlsx table reader
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Jul 26, 2022
1 parent 75afe60 commit 1a981e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ISADotNet.QueryModel/Row.fs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ type QRow =
|> List.map (fun ((inputName,outputName),ios) ->

let characteristics =
ios |> List.collect (fst >> API.ProcessInput.tryGetCharacteristics >> (Option.defaultValue []))
ios |> List.collect (fst >> API.ProcessInput.tryGetCharacteristicValues >> (Option.defaultValue []))
|> List.distinct
let factors =
ios |> List.collect (snd >> API.ProcessOutput.tryGetFactorValues >> (Option.defaultValue []))
Expand Down
9 changes: 9 additions & 0 deletions src/ISADotNet.XLSX/AssayFile/AnnotationNode.fs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,15 @@ module AnnotationNode =
OntologyAnnotation.fromStringWithComments value termAccession termSource [order]
)

/// If the headers of a node depict a protocolType, returns a function for parsing the values of the matrix to the values of this type
let tryGetProtocolREFGetter (columnOrder : int) (headers:string seq) =
Seq.tryPick tryParseProtocolREFHeader headers
|> Option.map (fun h ->

fun matrix i ->
Dictionary.tryGetString (i,h.HeaderString) matrix |> Option.defaultValue ""
)

/// If the headers of a node depict a parameter, returns the parameter and a function for parsing the values of the matrix to the values of this parameter
let tryGetParameterGetter (columnOrder : int) (headers:string seq) =
Seq.tryPick tryParseParameterHeader headers
Expand Down
6 changes: 6 additions & 0 deletions src/ISADotnet/OptionExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ module Option =
| Some v -> f v
| None -> f d
|> fromValueWithDefault d

/// Applies the function f on the value of the option if it exists, else returns the default value.
let mapOrDefault (d : 'T Option) (f: 'U -> 'T) (o : 'U option) =
match o with
| Some v -> Some (f v)
| None -> d

0 comments on commit 1a981e9

Please sign in to comment.