Skip to content

Commit

Permalink
add additional methods to QueryModel
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed May 18, 2022
1 parent be34819 commit 8701a22
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 25 deletions.
78 changes: 54 additions & 24 deletions src/ISADotnet/QueryModel/ProcessSequence.fs
Original file line number Diff line number Diff line change
Expand Up @@ -456,42 +456,72 @@ type QProcessSequence (sheets : QSheet list) =
member this.LastProcessedDataOf(node) =
QProcessSequence.getFinalOutputsOfBy (fun (io : IOType) -> io.isProcessedData) node this

member this.ValuesOf(name) =
(QProcessSequence.getPreviousValuesOf this name).Values @ (QProcessSequence.getSucceedingValuesOf this name).Values
member this.Values() =
this.Sheets
|> List.collect (fun s -> s.Values.Values().Values)
|> ValueCollection

member this.Values(ontology : OntologyAnnotation ) =
this.Sheets
|> List.collect (fun s -> s.Values.Values().Filter(ontology).Values)
|> ValueCollection

member this.Values(name : string ) =
this.Sheets
|> List.collect (fun s -> s.Values.Values().Filter(name).Values)
|> ValueCollection

member this.PreviousValuesOf(name) =
QProcessSequence.getPreviousValuesOf this name
member this.Factors() =
this.Values().Factors()

member this.Parameters() =
this.Values().Parameters()

member this.Characteristics() =
this.Values().Characteristics()

member this.ValuesOf(node) =
(QProcessSequence.getPreviousValuesOf this node).Values @ (QProcessSequence.getSucceedingValuesOf this node).Values
|> ValueCollection

member this.PreviousValuesOf(node) =
QProcessSequence.getPreviousValuesOf this node

member this.SucceedingValuesOf(node) =
QProcessSequence.getSucceedingValuesOf this node

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

member this.SucceedingValuesOf(name) =
QProcessSequence.getSucceedingValuesOf this name
member this.PreviousCharacteristicsOf(node) =
this.PreviousValuesOf(node).Characteristics()

member this.CharacteristicsOf(name) =
this.ValuesOf(name).Characteristics()
member this.SucceedingCharacteristicsOf(node) =
this.SucceedingValuesOf(node).Characteristics()

member this.PreviousCharacteristicsOf(name) =
this.PreviousValuesOf(name).Characteristics()
member this.ParametersOf(node) =
this.ValuesOf(node).Parameters()

member this.SucceedingCharacteristicsOf(name) =
this.SucceedingValuesOf(name).Characteristics()
member this.PreviousParametersOf(node) =
this.PreviousValuesOf(node).Parameters()

member this.ParametersOf(name) =
this.ValuesOf(name).Parameters()
member this.SucceedingParametersOf(node) =
this.SucceedingValuesOf(node).Parameters()

member this.PreviousParametersOf(name) =
this.PreviousValuesOf(name).Parameters()
member this.FactorsOf(node) =
this.ValuesOf(node).Factors()

member this.SucceedingParametersOf(name) =
this.SucceedingValuesOf(name).Parameters()
member this.PreviousFactorsOf(node) =
this.PreviousValuesOf(node).Factors()

member this.FactorsOf(name) =
this.ValuesOf(name).Factors()
member this.SucceedingFactorsOf(node) =
this.SucceedingValuesOf(node).Factors()

member this.PreviousFactorsOf(name) =
this.PreviousValuesOf(name).Factors()
member this.Contains(ontology : OntologyAnnotation) =
this.Values().Contains ontology

member this.SucceedingFactorsOf(name) =
this.SucceedingValuesOf(name).Factors()
member this.Contains(name : string) =
this.Values().Contains name

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

Expand Down
30 changes: 29 additions & 1 deletion src/ISADotnet/QueryModel/ValueCollection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ type ValueCollection(values : ISAValue list) =

member this.Values = values

member this.Filter(category : string) = values |> List.filter (fun v -> v.Category.NameText = category) |> ValueCollection

member this.Filter(category : OntologyAnnotation) = values |> List.filter (fun v -> v.Category = category) |> ValueCollection

member this.Characteristics(?Name) =
values
|> List.filter (fun v ->
Expand Down Expand Up @@ -65,6 +69,19 @@ type ValueCollection(values : ISAValue list) =
|> List.filter (fun v -> v.Category.NameText = name)
|> ValueCollection

member this.Distinct() =
values
|> List.distinct
|> ValueCollection

member this.Contains(category : OntologyAnnotation) =
values
|> List.exists (fun v -> v.Category = category)

member this.Contains(name : string) =
values
|> List.exists (fun v -> v.NameText = name)

interface IEnumerable<ISAValue> with
member this.GetEnumerator() = (Seq.ofList values).GetEnumerator()

Expand All @@ -88,6 +105,17 @@ type IOValueCollection(values : KeyValuePair<string*string,ISAValue> list) =

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

member this.Values(?Name) =
values
|> List.choose (fun kv ->
match Name with
| Some name ->
if kv.Value.NameText = name then Some kv.Value
else None
| None -> Some kv.Value
)
|> ValueCollection

member this.Characteristics(?Name) =
values
|> List.filter (fun kv ->
Expand Down Expand Up @@ -140,7 +168,7 @@ type IOValueCollection(values : KeyValuePair<string*string,ISAValue> list) =
values
|> List.groupBy (fun kv -> snd kv.Key)
|> List.map (fun (sink,vals) -> sink, vals |> List.map (fun kv -> fst kv.Key,kv.Value))

interface IEnumerable<KeyValuePair<string*string,ISAValue>> with
member this.GetEnumerator() = (Seq.ofList values).GetEnumerator()

Expand Down

0 comments on commit 8701a22

Please sign in to comment.