Skip to content

Commit

Permalink
add components to querymodel and assay xlsx writing
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Aug 2, 2022
1 parent 9b85296 commit f8f94c6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
10 changes: 6 additions & 4 deletions src/ISADotNet.QueryModel/Row.fs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,20 @@ type QRow =
Vals = Values |> Option.defaultValue []
}

static member create(?Input,?Output,?InputType,?OutputType,?CharValues,?ParamValues,?FactorValues) : QRow =
let combineValues (characteristics : MaterialAttributeValue list) (parameters : ProcessParameterValue list) (factors : FactorValue list) : ISAValue list =
static member create(?Input,?Output,?InputType,?OutputType,?CharValues,?ParamValues,?FactorValues,?Components) : QRow =
let combineValues (characteristics : MaterialAttributeValue list) (parameters : ProcessParameterValue list) (factors : FactorValue list) (components : Component list) : ISAValue list =
(characteristics |> List.map Characteristic)
@ (parameters |> List.map Parameter)
@ (factors |> List.map Factor)
@ (components |> List.map Component)
|> List.sortBy (fun v -> v.TryValueIndex() |> Option.defaultValue System.Int32.MaxValue)

{
Input = Input |> Option.defaultValue ""
Output = Output |> Option.defaultValue ""
InputType = InputType
OutputType = OutputType
Vals = combineValues (CharValues |> Option.defaultValue []) (ParamValues |> Option.defaultValue []) (FactorValues |> Option.defaultValue [])
Vals = combineValues (CharValues |> Option.defaultValue []) (ParamValues |> Option.defaultValue []) (FactorValues |> Option.defaultValue []) (Components |> Option.defaultValue [])
}

static member fromProcess (proc : Process) : QRow list =
Expand All @@ -129,11 +130,12 @@ type QRow =
let factors =
ios |> List.collect (snd >> API.ProcessOutput.tryGetFactorValues >> (Option.defaultValue []))
|> List.distinct
let components = proc.ExecutesProtocol |> Option.bind (fun p -> p.Components) |> Option.defaultValue []

let inputType = ios |> List.map (fst >> IOType.fromInput) |> IOType.reduce
let outputType = ios |> List.map (snd >> IOType.fromOutput) |> IOType.reduce

QRow.create(inputName, outputName, inputType, outputType, characteristics, parameterValues, factors)
QRow.create(inputName, outputName, inputType, outputType, characteristics, parameterValues, factors, components)

)

Expand Down
11 changes: 11 additions & 0 deletions src/ISADotNet.QueryModel/Sheet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ module ProtocolExtensions =
OntologyAnnotation.isChildTerm(parentProtocolType,pt,obo)
| _ -> false


type ProtocolDescriptor<'T> =
| ForAll of 'T
| ForSpecific of Map<int,'T>

with member this.TryGet(i) =
match this with
| ForAll x -> Some x
| ForSpecific m -> Map.tryFind i m


/// Queryable type representing a collection of processes implementing the same protocol. Or in ISAtab / ISAXLSX logic a sheet in an assay or study file.
///
/// Values are represented rowwise with input and output entities.
Expand Down
2 changes: 1 addition & 1 deletion src/ISADotNet.QueryModel/Value.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module ISAValueExtensions =
member this.HeaderText =
match this with
| Parameter p -> $"Parameter [{this.NameText}]"
| Characteristic c -> $"Characteristics [{this.NameText}]"
| Characteristic c -> $"Characteristic [{this.NameText}]"
| Factor f -> $"Factor [{this.NameText}]"
| Component c -> $"Component [{this.NameText}]"

Expand Down
11 changes: 1 addition & 10 deletions src/ISADotNet.XLSX/AssayFile/AnnotationTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ module AnnotationTable =
/// Merges processes with the same parameter values, grouping the input and output files
let mergeIdenticalProcesses processNameRoot (processes : seq<Process>) =
processes
|> Seq.groupBy (fun p -> p.ExecutesProtocol.Value.ProtocolType, p.ExecutesProtocol.Value.Name, p.ParameterValues)
|> Seq.groupBy (fun p -> p.ExecutesProtocol.Value.ProtocolType, p.ExecutesProtocol.Value.Name, p.ParameterValues, p.ExecutesProtocol.Value.Components)
|> Seq.mapi (fun i (_,processGroup) ->
let p = processGroup |> Seq.choose (fun pr -> pr.ExecutesProtocol) |> Seq.toList |> Protocol.mergeIndicesToRange
processGroup
Expand Down Expand Up @@ -364,15 +364,6 @@ module QSheet =
open FsSpreadsheet.DSL
open ISADotNet.QueryModel

type ProtocolDescriptor<'T> =
| ForAll of 'T
| ForSpecific of Map<int,'T>

with member this.TryGet(i) =
match this with
| ForAll x -> Some x
| ForSpecific m -> Map.tryFind i m

let toSheet i (s : QueryModel.QSheet) =
let hasRef,refs =
if s.Protocols |> List.exists (fun p -> p.Name.IsSome && p.Name.Value <> s.SheetName) then
Expand Down

0 comments on commit f8f94c6

Please sign in to comment.