Skip to content

Commit

Permalink
improve query model value retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed May 9, 2022
1 parent ba81b27 commit 8b7f1c7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
37 changes: 28 additions & 9 deletions src/ISADotnet/QueryModel/ProcessSequence.fs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ type QProcessSequence (sheets : QSheet list) =

loop (QProcessSequence.getFinalOutputs ps) []

static member getNodesOfBy (predicate : QueryModel.IOType -> bool) (sample : string) (ps : #QProcessSequence) =
QProcessSequence.getSubTreeOf sample ps
|> QProcessSequence.getNodesBy predicate

/// Returns the initial inputs final outputs of the assay, to which no processPoints
static member getRootInputsOfBy (predicate : QueryModel.IOType -> bool) (sample : string) (ps : #QProcessSequence) =
QProcessSequence.getSubTreeOf sample ps
Expand Down Expand Up @@ -374,6 +378,9 @@ type QProcessSequence (sheets : QSheet list) =
member this.Samples() =
QProcessSequence.getNodesBy (fun (io : IOType) -> io.isSample) this

member this.SamplesOf(node) =
QProcessSequence.getNodesOfBy (fun (io : IOType) -> io.isSample) node this

member this.FirstSamples() =
QProcessSequence.getRootInputsBy (fun (io : IOType) -> io.isSample) this

Expand All @@ -389,9 +396,15 @@ type QProcessSequence (sheets : QSheet list) =
member this.Sources() =
QProcessSequence.getNodesBy (fun (io : IOType) -> io.isSource) this

member this.SourcesOf(node) =
QProcessSequence.getNodesOfBy (fun (io : IOType) -> io.isSource) node this

member this.Data() =
QProcessSequence.getNodesBy (fun (io : IOType) -> io.isData) this

member this.DataOf(node) =
QProcessSequence.getNodesOfBy (fun (io : IOType) -> io.isData) node this

member this.FirstData() =
QProcessSequence.getRootInputsBy (fun (io : IOType) -> io.isData) this

Expand All @@ -407,6 +420,9 @@ type QProcessSequence (sheets : QSheet list) =
member this.RawData() =
QProcessSequence.getNodesBy (fun (io : IOType) -> io.isRawData) this

member this.RawDataOf(node) =
QProcessSequence.getNodesOfBy (fun (io : IOType) -> io.isRawData) node this

member this.FirstRawData() =
QProcessSequence.getRootInputsBy (fun (io : IOType) -> io.isRawData) this

Expand All @@ -422,6 +438,9 @@ type QProcessSequence (sheets : QSheet list) =
member this.ProcessedData() =
QProcessSequence.getNodesBy (fun (io : IOType) -> io.isProcessedData) this

member this.ProcessedDataOf(node) =
QProcessSequence.getNodesOfBy (fun (io : IOType) -> io.isProcessedData) node this

member this.FirstProcessedData() =
QProcessSequence.getRootInputsBy (fun (io : IOType) -> io.isProcessedData) this

Expand All @@ -445,31 +464,31 @@ type QProcessSequence (sheets : QSheet list) =
QProcessSequence.getSucceedingValuesOf this name

member this.CharacteristicsOf(name) =
this.ValuesOf(name).Characteristics
this.ValuesOf(name).Characteristics()

member this.PreviousCharacteristicsOf(name) =
this.PreviousValuesOf(name).Characteristics
this.PreviousValuesOf(name).Characteristics()

member this.SucceedingCharacteristicsOf(name) =
this.SucceedingValuesOf(name).Characteristics
this.SucceedingValuesOf(name).Characteristics()

member this.ParametersOf(name) =
this.ValuesOf(name).Parameters
this.ValuesOf(name).Parameters()

member this.PreviousParametersOf(name) =
this.PreviousValuesOf(name).Parameters
this.PreviousValuesOf(name).Parameters()

member this.SucceedingParametersOf(name) =
this.SucceedingValuesOf(name).Parameters
this.SucceedingValuesOf(name).Parameters()

member this.FactorsOf(name) =
this.ValuesOf(name).Factors
this.ValuesOf(name).Factors()

member this.PreviousFactorsOf(name) =
this.PreviousValuesOf(name).Factors
this.PreviousValuesOf(name).Factors()

member this.SucceedingFactorsOf(name) =
this.SucceedingValuesOf(name).Factors
this.SucceedingValuesOf(name).Factors()

//static member toString (rwa : QAssay) = JsonSerializer.Serialize<QAssay>(rwa,JsonExtensions.options)

Expand Down
4 changes: 4 additions & 0 deletions src/ISADotnet/QueryModel/ValueCollection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type ValueCollection(values : ISAValue list) =

member this.Item(i : int) = values.[i]

member this.Item(category : string) = values |> List.pick (fun v -> if v.Category.NameText = category then Some v else None)

member this.Item(category : OntologyAnnotation) = values |> List.pick (fun v -> if v.Category = category then Some v else None)

member this.Values = values
Expand Down Expand Up @@ -80,6 +82,8 @@ type IOValueCollection(values : KeyValuePair<string*string,ISAValue> list) =

member this.Item(i : int) = values.[i]

member this.Item(category : string) = values |> List.pick (fun kv -> if kv.Value.Category.NameText = category then Some kv.Key else None)

member this.Item(ioKey : string*string) = values |> List.pick (fun kv -> if ioKey = kv.Key then Some kv.Value else None)

member this.Item(category : OntologyAnnotation) = values |> List.pick (fun kv -> if kv.Value.Category = category then Some kv.Key else None)
Expand Down

0 comments on commit 8b7f1c7

Please sign in to comment.