Skip to content

Commit

Permalink
add data column reader to assay reader
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Mar 25, 2021
1 parent c4f6df3 commit ac52305
Showing 1 changed file with 68 additions and 30 deletions.
98 changes: 68 additions & 30 deletions src/ISADotNet.XLSX/AssayFile/AnnotationTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,52 +91,90 @@ module AnnotationTable =
|> Seq.fold (fun (pl,pvl) (p,pv) -> p.Value :: pl, pv :: pvl) ([],[])
|> fun (l1,l2) -> List.rev l1, List.rev l2

let dataFileGetter = nodes |> Seq.tryPick AnnotationNode.tryGetDataFileGetter

let inputGetter,outputGetter =
match nodes |> Seq.tryPick AnnotationNode.tryGetSourceNameGetter with
| Some inputNameGetter ->
let outputNameGetter = nodes |> Seq.tryPick AnnotationNode.tryGetSampleNameGetter
let inputGetter =
fun matrix i ->
Source.create
None
(inputNameGetter matrix i)
(characteristicValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
let source =
Source.create
None
(inputNameGetter matrix i)
(characteristicValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
if dataFileGetter.IsSome then
[source;source]
else
[source]

let outputGetter =
fun matrix i ->
Sample.create
None
(outputNameGetter |> Option.bind (fun o -> o matrix i))
(characteristicValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
(factorValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
(inputGetter matrix i |> List.singleton |> Some)
|> Sample
(fun matrix i -> inputGetter matrix i |> Source |> Some),outputGetter
let data = dataFileGetter |> Option.map (fun f -> f matrix i)
let outputName =
match outputNameGetter |> Option.bind (fun o -> o matrix i) with
| Some s -> Some s
| None ->
match data with
| Some data -> data.Name
| None -> None
let sample =
Sample.create
None
outputName
(characteristicValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
(factorValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
(inputGetter matrix i |> List.distinct |> Some)
if data.IsSome then
[ProcessOutput.Sample sample; ProcessOutput.Data data.Value]
else
[ProcessOutput.Sample sample]
(fun matrix i -> inputGetter matrix i |> List.map Source |> Some),outputGetter
| None ->
let inputNameGetter = nodes |> Seq.head |> AnnotationNode.tryGetSampleNameGetter
let outputNameGetter = nodes |> Seq.last |> AnnotationNode.tryGetSampleNameGetter
let inputGetter =

fun matrix i ->
inputNameGetter
|> Option.map (fun ing ->
let source =
inputNameGetter
|> Option.map (fun ing ->
Sample.create
None
(ing matrix i)
(characteristicValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
None
None
|> ProcessInput.Sample
)
match source with
| Some source when dataFileGetter.IsSome -> Some [source;source]
| Some source -> Some [source]
| None -> None


let outputGetter =
fun matrix i ->
let data = dataFileGetter |> Option.map (fun f -> f matrix i)
let outputName =
match outputNameGetter |> Option.bind (fun o -> o matrix i) with
| Some s -> Some s
| None ->
match data with
| Some data -> data.Name
| None -> None
let sample =
Sample.create
None
(ing matrix i)
outputName
(characteristicValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
(factorValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
None
None
|> ProcessInput.Sample
)

let outputGetter =
fun matrix i ->
Sample.create
None
(outputNameGetter |> Option.bind (fun o -> o matrix i))
(characteristicValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
(factorValueGetters |> List.map (fun f -> f matrix i) |> API.Option.fromValueWithDefault [])
None
|> Sample
if data.IsSome then
[ProcessOutput.Sample sample; ProcessOutput.Data data.Value]
else
[ProcessOutput.Sample sample]
inputGetter,outputGetter

let protocol = {protocolMetaData with Parameters = API.Option.fromValueWithDefault [] parameters}
Expand All @@ -154,8 +192,8 @@ module AnnotationTable =
None
None
None
(inputGetter matrix i |> Option.map List.singleton)
(outputGetter matrix i |> List.singleton |> Some)
(inputGetter matrix i)
(outputGetter matrix i |> Some)
None

/// Merges processes with the same parameter values, grouping the input and output files
Expand Down

0 comments on commit ac52305

Please sign in to comment.