From b3ddf3cc7332500b0e4869cb847b01daf20e4eca Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Wed, 16 Aug 2023 13:31:54 +0200 Subject: [PATCH] rename CvTern Value field -> Name --- src/ARCTokenization/Address.fs | 6 +++--- src/ARCTokenization/AnnotationTable.fs | 10 +++++----- src/ARCTokenization/MetadataSheet.fs | 2 +- src/ARCTokenization/Terms.fs | 8 ++++---- .../CvAttributeCollection.fs | 12 +++++------ src/ControlledVocabulary/CvContainer.fs | 16 +++++++-------- src/ControlledVocabulary/CvObject.fs | 8 ++++---- src/ControlledVocabulary/CvParam.fs | 16 +++++++-------- src/ControlledVocabulary/CvTerm.fs | 10 +++++----- src/ControlledVocabulary/ICvBase.fs | 14 ++++++------- src/ControlledVocabulary/IParam.fs | 8 ++++---- src/ControlledVocabulary/IParamBase.fs | 8 ++++---- src/ControlledVocabulary/ParamValue.fs | 20 +++++++++---------- src/ControlledVocabulary/UserParam.fs | 6 +++--- .../IntegrationTests/AssayAnnotationTable.fs | 2 +- .../IntegrationTests/InvestigationMetadata.fs | 4 ++-- tests/ARCTokenization.Tests/TestUtils.fs | 14 ++++++------- .../ControlledVocabulary.Tests/CvBaseTests.fs | 2 +- 18 files changed, 83 insertions(+), 83 deletions(-) diff --git a/src/ARCTokenization/Address.fs b/src/ARCTokenization/Address.fs index 795493e..3e5ac9a 100644 --- a/src/ARCTokenization/Address.fs +++ b/src/ARCTokenization/Address.fs @@ -4,11 +4,11 @@ open ControlledVocabulary module Address = - let column = CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCIT_C43379", value = "Column", ref = "NCIT") + let column = CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCIT_C43379", name = "Column", ref = "NCIT") - let row = CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCIT_C43378", value = "Row", ref = "NCIT") + let row = CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCIT_C43378", name = "Row", ref = "NCIT") - let worksheet = CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCIT_C73541", value = "Worksheet", ref = "NCIT") + let worksheet = CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCIT_C73541", name = "Worksheet", ref = "NCIT") //"isa_investigation!A1" diff --git a/src/ARCTokenization/AnnotationTable.fs b/src/ARCTokenization/AnnotationTable.fs index fb3da99..2f63ac1 100644 --- a/src/ARCTokenization/AnnotationTable.fs +++ b/src/ARCTokenization/AnnotationTable.fs @@ -151,7 +151,7 @@ module AnnotationTable = let cvPars = List.map4 ( fun (vl : FsCell) unt tan tsr -> - let valTerm = CvUnit.create(accession = tan.Value, value = vl.Value, ref = tsr.Value) + let valTerm = CvUnit.create(accession = tan.Value, name = vl.Value, ref = tsr.Value) CvParam(d.Value, a.Value, c.Value, WithCvUnitAccession (unt.Value, valTerm)) ) dataCellsVal dataCellsUnt dataCellsTan dataCellsTsr yield! cvPars @@ -166,7 +166,7 @@ module AnnotationTable = (dataCellsVal, dataCellsTsr, dataCellsTan) |||> List.map3 ( fun vl tsr tan -> - let valTerm = CvTerm.create(accession = tan.Value, value = vl.Value, ref = tsr.Value) + let valTerm = CvTerm.create(accession = tan.Value, name = vl.Value, ref = tsr.Value) CvParam(c.Value, a.Value, b.Value, CvValue valTerm) ) yield! cvPars @@ -182,7 +182,7 @@ module AnnotationTable = (dataCellsVal, dataCellsTsr) ||> List.map2 ( fun vl tsr -> - let valTerm = CvTerm.create (accession = "(n/a)", value = vl.Value, ref = tsr.Value) + let valTerm = CvTerm.create (accession = "(n/a)", name = vl.Value, ref = tsr.Value) CvParam("n/a", a.Value, b.Value, CvValue valTerm) ) yield! cvPars @@ -195,7 +195,7 @@ module AnnotationTable = (dataCellsTsr, dataCellsTan) ||> List.map2 ( fun tsr tan -> - let valTerm = CvTerm.create(accession = tan.Value, value = "n/a", ref = tsr.Value) + let valTerm = CvTerm.create(accession = tan.Value, name = "n/a", ref = tsr.Value) CvParam(b.Value, "(n/a)", a.Value, CvValue valTerm) ) yield! cvPars @@ -291,7 +291,7 @@ module AnnotationTable = let getNodeType (cvPar : #IParamBase) = //let castedCvPar = cvPar :?> CvParam // debatable approach //let v = Param.getCvName castedCvPar - let v = CvBase.getCvValue cvPar + let v = CvBase.getCvName cvPar match v with | "Source Name" -> Source | "Sample Name" diff --git a/src/ARCTokenization/MetadataSheet.fs b/src/ARCTokenization/MetadataSheet.fs index 49697a7..8137c08 100644 --- a/src/ARCTokenization/MetadataSheet.fs +++ b/src/ARCTokenization/MetadataSheet.fs @@ -9,7 +9,7 @@ module MetadataSheet = let (|Term|_|) (terms : CvTerm list) (key : string) : CvTerm Option = terms - |> List.tryFind (fun (term) -> term.Value = key) + |> List.tryFind (fun (term) -> term.Name = key) let (|UnMatchable|) (key : string) : string = key diff --git a/src/ARCTokenization/Terms.fs b/src/ARCTokenization/Terms.fs index 16c26ab..f96688c 100644 --- a/src/ARCTokenization/Terms.fs +++ b/src/ARCTokenization/Terms.fs @@ -24,7 +24,7 @@ module InvestigationMetadata = let cvTerms = ontology.Terms - |> List.map (fun t -> CvTerm.create(accession = t.Id, value = t.Name, ref = "INVMSO")) + |> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref = "INVMSO")) module StudyMetadata = @@ -34,7 +34,7 @@ module StudyMetadata = let cvTerms = ontology.Terms - |> List.map (fun t -> CvTerm.create(accession = t.Id, value = t.Name, ref ="STDMSO")) + |> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref ="STDMSO")) module AssayMetadata = @@ -44,8 +44,8 @@ module AssayMetadata = let cvTerms = ontology.Terms - |> List.map (fun t -> CvTerm.create(accession = t.Id, value = t.Name, ref ="ASSMSO")) + |> List.map (fun t -> CvTerm.create(accession = t.Id, name = t.Name, ref ="ASSMSO")) module StructuralTerms = - let metadataSectionKey = CvTerm.create(accession = "AGMO:00000001", value = "Metadata Section Key", ref = "AGMO") \ No newline at end of file + let metadataSectionKey = CvTerm.create(accession = "AGMO:00000001", name = "Metadata Section Key", ref = "AGMO") \ No newline at end of file diff --git a/src/ControlledVocabulary/CvAttributeCollection.fs b/src/ControlledVocabulary/CvAttributeCollection.fs index 9ed619c..ec55752 100644 --- a/src/ControlledVocabulary/CvAttributeCollection.fs +++ b/src/ControlledVocabulary/CvAttributeCollection.fs @@ -12,7 +12,7 @@ type CvAttributeCollection(attributes : IDictionary) = new(attributes) = let dict = attributes - |> Seq.map (fun cvp -> (cvp :> ICvBase).Value, cvp) + |> Seq.map (fun cvp -> (cvp :> ICvBase).Name, cvp) |> Dictionary.ofSeq CvAttributeCollection(dict) @@ -22,12 +22,12 @@ type CvAttributeCollection(attributes : IDictionary) = /// Add an IParam as an attribute. Fails, if an attribute with the same key already exists member this.AddAttribute (param : IParam) = - Dictionary.addInPlace (param |> CvBase.getCvValue) param this + Dictionary.addInPlace (param |> CvBase.getCvName) param this |> ignore /// Add an IParam as an attribute. Does not fail, if an attribute with the same key already exists member this.TryAddAttribute (param : IParam) = - let key = param |> CvBase.getCvValue + let key = param |> CvBase.getCvName if this.ContainsAttribute key then false else this.AddAttribute param @@ -39,7 +39,7 @@ type CvAttributeCollection(attributes : IDictionary) = /// Retrieves an IParam attribute by its term, if it exists, else returns None member this.TryGetAttribute (term : CvTerm) = - Dictionary.tryFind term.Value this + Dictionary.tryFind term.Name this |> Option.bind (fun param -> if CvBase.equalsTerm term param then Some param @@ -51,7 +51,7 @@ type CvAttributeCollection(attributes : IDictionary) = /// Retrieves an IParam attribute by its term, if it exists, else fails member this.GetAttribute (term : CvTerm) = - Dictionary.item term.Value this + Dictionary.item term.Name this /// Returns true, if an attribute with the given name exists in the collection member this.ContainsAttribute (name : string) = @@ -59,7 +59,7 @@ type CvAttributeCollection(attributes : IDictionary) = /// Returns true, if an attribute with the given term exists in the collection member this.ContainsAttribute (term : CvTerm) = - match Dictionary.tryFind term.Value this with + match Dictionary.tryFind term.Name this with | Some param when CvBase.equalsTerm term param -> true | _ -> false diff --git a/src/ControlledVocabulary/CvContainer.fs b/src/ControlledVocabulary/CvContainer.fs index 9b1b7c8..9215c46 100644 --- a/src/ControlledVocabulary/CvContainer.fs +++ b/src/ControlledVocabulary/CvContainer.fs @@ -13,7 +13,7 @@ module internal Dictionary = /// Represents a collection of structured properties, annotated with a controlled vocabulary term. type CvContainer ( cvAccession : string, - cvValue : string, + cvName : string, cvRef : string, attributes : IDictionary, properties : IDictionary> @@ -23,8 +23,8 @@ type CvContainer ( interface ICvBase with member this.Accession = cvAccession - member this.Value = cvValue - member this.RefUri = cvRef + member this.Name = cvName + member this.RefUri = cvRef member this.HasAttributes with get() = this.Attributes |> Seq.isEmpty |> not @@ -38,7 +38,7 @@ type CvContainer ( new (term : CvTerm, attributes : IDictionary) = - CvContainer(term.Accession, term.Value, term.RefUri, attributes, Dictionary()) + CvContainer(term.Accession, term.Name, term.RefUri, attributes, Dictionary()) new (term : CvTerm,attributes : seq) = let dict = CvAttributeCollection(attributes) CvContainer(term, dict) @@ -307,7 +307,7 @@ type CvContainer ( /// /// If a value with the same key already exist in the container, appends the new child static member addSingle (value : ICvBase) (cvContainer : CvContainer) = - Dictionary.addOrAppendInPlace value.Value value cvContainer.Properties + Dictionary.addOrAppendInPlace value.Name value cvContainer.Properties /// Sets children as a property of the CvContainer. @@ -319,7 +319,7 @@ type CvContainer ( static member setMany (values : seq) (cvContainer : CvContainer) = let propertyName = values - |> Seq.countBy (fun v -> v.Value) + |> Seq.countBy (fun v -> v.Name) |> Seq.exactlyOne |> fst Dictionary.addOrUpdateInPlace propertyName values cvContainer.Properties @@ -327,7 +327,7 @@ type CvContainer ( /// Sets a single child as a property of the CvContainer, accessible by its name. static member setSingle (value : ICvBase) (cvContainer : CvContainer) = - Dictionary.addOrUpdateInPlace value.Value (Seq.singleton value) cvContainer.Properties + Dictionary.addOrUpdateInPlace value.Name (Seq.singleton value) cvContainer.Properties override this.ToString() = - $"CvContainer: {(this :> ICvBase).Value}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}\n\tProperties: {this.Properties.Keys |> Seq.toList}" \ No newline at end of file + $"CvContainer: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}\n\tProperties: {this.Properties.Keys |> Seq.toList}" \ No newline at end of file diff --git a/src/ControlledVocabulary/CvObject.fs b/src/ControlledVocabulary/CvObject.fs index f109e7f..861b46d 100644 --- a/src/ControlledVocabulary/CvObject.fs +++ b/src/ControlledVocabulary/CvObject.fs @@ -3,20 +3,20 @@ open System.Collections.Generic /// Represents a generic object, annotated with a controlled vocabulary term -type CvObject<'T>(cvAccession : string, cvValue : string, cvRef : string, object : 'T, attributes : Dictionary) = +type CvObject<'T>(cvAccession : string, cvName : string, cvRef : string, object : 'T, attributes : Dictionary) = inherit CvAttributeCollection(attributes) interface ICvBase with member this.Accession = cvAccession - member this.Value = cvValue + member this.Name = cvName member this.RefUri = cvRef member this.HasAttributes with get() = this.Attributes |> Seq.isEmpty |> not - new (term: CvTerm, object : 'T, attributes) = CvObject (term.Accession, term.Value, term.RefUri, object, attributes) + new (term: CvTerm, object : 'T, attributes) = CvObject (term.Accession, term.Name, term.RefUri, object, attributes) member this.Object = object override this.ToString() = - $"Name: {(this :> ICvBase).Value}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}" \ No newline at end of file + $"Name: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}" \ No newline at end of file diff --git a/src/ControlledVocabulary/CvParam.fs b/src/ControlledVocabulary/CvParam.fs index 4f65c06..8a0aec1 100644 --- a/src/ControlledVocabulary/CvParam.fs +++ b/src/ControlledVocabulary/CvParam.fs @@ -10,16 +10,16 @@ open FSharpAux /// /// Attributes can be used to further describe the CvParam [] -type CvParam(cvAccession : string, cvValue : string, cvRef : string, paramValue : ParamValue, attributes : IDictionary) = +type CvParam(cvAccession : string, cvName : string, cvRef : string, paramValue : ParamValue, attributes : IDictionary) = inherit CvAttributeCollection(attributes) interface IParam with member this.Accession = cvAccession - member this.Value = cvValue - member this.RefUri = cvRef + member this.Name = cvName + member this.RefUri = cvRef member this.Value = paramValue - member this.WithValue(v : ParamValue) = CvParam(cvAccession,cvValue,cvRef,v,attributes) + member this.WithValue(v : ParamValue) = CvParam(cvAccession,cvName,cvRef,v,attributes) member this.HasAttributes with get() = this.Attributes |> Seq.isEmpty |> not @@ -32,7 +32,7 @@ type CvParam(cvAccession : string, cvValue : string, cvRef : string, paramValue CvParam (id,name,ref,ParamValue.Value v) new (term : CvTerm, pv, attributes : seq) = - CvParam (term.Accession, term.Value, term.RefUri, pv, attributes) + CvParam (term.Accession, term.Name, term.RefUri, pv, attributes) new (cvTerm,pv : ParamValue) = CvParam (cvTerm,pv,Seq.empty) new (cvTerm,v : IConvertible) = @@ -87,8 +87,8 @@ type CvParam(cvAccession : string, cvValue : string, cvRef : string, paramValue static member tryMapValue (f : ParamValue -> ParamValue option) (param : CvParam) = Param.tryMapValue f param - static member tryAddValue (value : string) (param : CvParam) = - Param.tryAddValue value param + static member tryAddName (value : string) (param : CvParam) = + Param.tryAddName value param static member tryAddAccession (id : string) (param : CvParam) = Param.tryAddAccession id param @@ -104,7 +104,7 @@ type CvParam(cvAccession : string, cvValue : string, cvRef : string, paramValue override this.ToString() = - $"CvParam: {(this :> ICvBase).Value}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}\n\tValue: {(this :> IParamBase).Value}\n\tAttributes: {this.Keys |> Seq.toList}" + $"CvParam: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}\n\tValue: {(this :> IParamBase).Value}\n\tAttributes: {this.Keys |> Seq.toList}" member this.DisplayText = this.ToString() \ No newline at end of file diff --git a/src/ControlledVocabulary/CvTerm.fs b/src/ControlledVocabulary/CvTerm.fs index cd5980d..a6dbcea 100644 --- a/src/ControlledVocabulary/CvTerm.fs +++ b/src/ControlledVocabulary/CvTerm.fs @@ -6,21 +6,21 @@ //[] type CvTerm = { Accession: string - Value: string + Name: string RefUri: string } with static member create( accession: string, - value: string, + name: string, ref : string ) = - {Accession = accession; Value = value; RefUri = ref} + {Accession = accession; Name = name; RefUri = ref} static member create( - value: string + name: string ) = CvTerm.create( - value = value, + name = name, accession = "", ref = "" ) diff --git a/src/ControlledVocabulary/ICvBase.fs b/src/ControlledVocabulary/ICvBase.fs index efb3049..3f6070b 100644 --- a/src/ControlledVocabulary/ICvBase.fs +++ b/src/ControlledVocabulary/ICvBase.fs @@ -9,8 +9,8 @@ type IAttributeCollection = /// Interface ensures the propterties necessary for CvTerm and ICvBase = abstract member Accession : string - abstract member Value : string - abstract member RefUri : string + abstract member Name : string + abstract member RefUri : string inherit IAttributeCollection @@ -24,8 +24,8 @@ module CvBase = cv.Accession /// Returns the name of the cv item - let getCvValue (cv : #ICvBase) = - cv.Value + let getCvName (cv : #ICvBase) = + cv.Name /// Returns the reference of the cv item let getCvRef (cv : #ICvBase) = @@ -33,7 +33,7 @@ module CvBase = /// Returns the full term of the cv item let getTerm (cv : #ICvBase) : CvTerm = - CvTerm.create(accession = cv.Accession, value = cv.Value, ref = cv.RefUri) + CvTerm.create(accession = cv.Accession, name = cv.Name, ref = cv.RefUri) /// Returns true, if the given term matches the term of the cv item let equalsTerm (term : CvTerm) (cv : #ICvBase) = @@ -44,8 +44,8 @@ module CvBase = getTerm cv1 = getTerm cv2 /// Returns true, if the names of the given cv items match - let equalsValue (cv1 : #ICvBase) (cv2 : #ICvBase) = - getCvValue cv1 = getCvValue cv2 + let equalsName (cv1 : #ICvBase) (cv2 : #ICvBase) = + getCvName cv1 = getCvName cv2 /// Returns Some Value of type 'T, if the given cv item can be downcast, else returns None let inline tryAs<'T when 'T :> ICvBase> (cv : ICvBase) = diff --git a/src/ControlledVocabulary/IParam.fs b/src/ControlledVocabulary/IParam.fs index 4e70a51..98fc38a 100644 --- a/src/ControlledVocabulary/IParam.fs +++ b/src/ControlledVocabulary/IParam.fs @@ -21,8 +21,8 @@ type Param = CvBase.equals param1 param2 /// Returns true, if the value of the given params match - static member equalsValue (param1 : IParam) (param2 : IParam) = - CvBase.equalsValue param1 param2 + static member equalsName (param1 : IParam) (param2 : IParam) = + CvBase.equalsName param1 param2 /// Returns Some Param, if the given cv item can be downcast, else returns None static member tryParam (cv : ICvBase) = @@ -78,8 +78,8 @@ type Param = static member tryMapValue (f : ParamValue -> ParamValue option) (param : IParam) = ParamBase.tryMapValue f param |> Option.map (fun v -> v :?> IParam) - static member tryAddValue (value : string) (param : IParam) = - ParamBase.tryAddValue value param |> Option.map (fun v -> v :?> IParam) + static member tryAddName (value : string) (param : IParam) = + ParamBase.tryAddName value param |> Option.map (fun v -> v :?> IParam) static member tryAddAccession (id : string) (param : IParam) = ParamBase.tryAddAccession id param |> Option.map (fun v -> v :?> IParam) diff --git a/src/ControlledVocabulary/IParamBase.fs b/src/ControlledVocabulary/IParamBase.fs index 709ef3c..7b43b2e 100644 --- a/src/ControlledVocabulary/IParamBase.fs +++ b/src/ControlledVocabulary/IParamBase.fs @@ -54,11 +54,11 @@ module ParamBase = | CvValue _ -> None | WithCvUnitAccession (v,_) -> Some v - let tryGetCvUnitTermValue (param : #IParamBase) = + let tryGetCvUnitTermName (param : #IParamBase) = match param.Value with | Value _ -> None | CvValue _ -> None - | WithCvUnitAccession (_,cvu) -> Some cvu.Value + | WithCvUnitAccession (_,cvu) -> Some cvu.Name let tryGetCvUnitTermAccession (param : #IParamBase) = match param.Value with @@ -81,8 +81,8 @@ module ParamBase = Some (param.WithValue(value)) | None -> None - let tryAddValue (value : string) (param : IParamBase) = - tryMapValue (ParamValue.tryAddValue value) param + let tryAddName (value : string) (param : IParamBase) = + tryMapValue (ParamValue.tryAddName value) param let tryAddAccession (acc : string) (param : IParamBase) = tryMapValue (ParamValue.tryAddAccession acc) param diff --git a/src/ControlledVocabulary/ParamValue.fs b/src/ControlledVocabulary/ParamValue.fs index a14c77c..e6fb1dd 100644 --- a/src/ControlledVocabulary/ParamValue.fs +++ b/src/ControlledVocabulary/ParamValue.fs @@ -16,29 +16,29 @@ type ParamValue = static member getValue (param:ParamValue) = match param with | Value v -> v - | CvValue cv -> cv.Value :> IConvertible + | CvValue cv -> cv.Name :> IConvertible | WithCvUnitAccession (v,_) -> v /// Returns the value of the Param as string static member getValueAsString (param:ParamValue) = match param with | Value v -> string v - | CvValue cv -> cv.Value + | CvValue cv -> cv.Name | WithCvUnitAccession (v,_) -> string v /// Returns the value of the Param as int if possible, else fails static member getValueAsInt (param:ParamValue) = match param with | Value v -> v :?> int - | CvValue cv -> cv.Value |> int + | CvValue cv -> cv.Name |> int | WithCvUnitAccession (v,_) -> v :?> int /// Returns the value of the Param as a term static member getValueAsTerm (param:ParamValue) = match param with - | Value v -> CvTerm.create(value = (v |> string)) + | Value v -> CvTerm.create(name = (v |> string)) | CvValue term -> term - | WithCvUnitAccession (v,_) -> CvTerm.create(value = (v |> string)) + | WithCvUnitAccession (v,_) -> CvTerm.create(name = (v |> string)) /// Returns the unit of the Param if it exists, else returns None static member tryGetUnit (param:ParamValue) : CvUnit option = @@ -48,17 +48,17 @@ type ParamValue = | WithCvUnitAccession (_,u) -> Some u /// Returns a new paramValue with the given name if possible, else returns None - static member tryAddValue (value : string) (param : ParamValue) = + static member tryAddName (name : string) (param : ParamValue) = match param with - | Value v -> Some (Value value) - | CvValue cv when cv.Value = "" -> Some (CvValue {cv with Value = value}) + | Value v -> Some (Value name) + | CvValue cv when cv.Name = "" -> Some (CvValue {cv with Name = name}) | CvValue term -> None | WithCvUnitAccession (_,u) -> None /// Returns a new paramValue with the given annotationID if possible, else returns None static member tryAddAccession (accession : string) (param : ParamValue) = match param with - | Value (:? string as v) -> Some (CvValue (CvTerm.create(accession = accession, value = v, ref = ""))) + | Value (:? string as v) -> Some (CvValue (CvTerm.create(accession = accession, name = v, ref = ""))) | Value v -> None | CvValue cv when cv.Accession = "" -> Some (CvValue {cv with Accession = accession}) | CvValue term -> None @@ -67,7 +67,7 @@ type ParamValue = /// Returns a new paramValue with the given reference if possible, else returns None static member tryAddReference (ref : string) (param : ParamValue) = match param with - | Value (:? string as v) -> Some (CvValue (CvTerm.create(accession = "", value = v, ref = ref))) + | Value (:? string as v) -> Some (CvValue (CvTerm.create(accession = "", name = v, ref = ref))) | Value v -> None | CvValue cv when cv.RefUri = "" -> Some (CvValue {cv with RefUri = ref}) | CvValue term -> None diff --git a/src/ControlledVocabulary/UserParam.fs b/src/ControlledVocabulary/UserParam.fs index 6653dab..f6f308c 100644 --- a/src/ControlledVocabulary/UserParam.fs +++ b/src/ControlledVocabulary/UserParam.fs @@ -11,8 +11,8 @@ type UserParam(name : string, paramValue : ParamValue, attributes : IDictionary< interface IParam with member this.Accession = name - member this.Value = name - member this.RefUri = "UserTerm" + member this.Name = name + member this.RefUri = "UserTerm" member this.Value = paramValue member this.WithValue(v : ParamValue) = UserParam(name,v,attributes) member this.HasAttributes @@ -43,7 +43,7 @@ type UserParam(name : string, paramValue : ParamValue, attributes : IDictionary< | _ -> None override this.ToString() = - $"Name: {(this :> ICvBase).Value}\n\tValue: {(this :> IParamBase).Value}\n\tQualifiers: {this.Keys |> Seq.toList}" + $"Name: {(this :> ICvBase).Name}\n\tValue: {(this :> IParamBase).Value}\n\tQualifiers: {this.Keys |> Seq.toList}" member this.DisplayText = this.ToString() \ No newline at end of file diff --git a/tests/ARCTokenization.Tests/IntegrationTests/AssayAnnotationTable.fs b/tests/ARCTokenization.Tests/IntegrationTests/AssayAnnotationTable.fs index a47c634..e2eb019 100644 --- a/tests/ARCTokenization.Tests/IntegrationTests/AssayAnnotationTable.fs +++ b/tests/ARCTokenization.Tests/IntegrationTests/AssayAnnotationTable.fs @@ -112,7 +112,7 @@ module Correct = id = "Term Accession Number (OBI:0100026)", name = "Characteristic [organism]", ref = "Term Source REF (OBI:0100026)", - pv = ParamValue.CvValue (CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCBITaxon_3702", value = "Arabidopsis thaliana", ref = "NCBITaxon")), + pv = ParamValue.CvValue (CvTerm.create(accession = "http://purl.obolibrary.org/obo/NCBITaxon_3702", name = "Arabidopsis thaliana", ref = "NCBITaxon")), attributes = [] ) ] diff --git a/tests/ARCTokenization.Tests/IntegrationTests/InvestigationMetadata.fs b/tests/ARCTokenization.Tests/IntegrationTests/InvestigationMetadata.fs index 48a3078..39f530a 100644 --- a/tests/ARCTokenization.Tests/IntegrationTests/InvestigationMetadata.fs +++ b/tests/ARCTokenization.Tests/IntegrationTests/InvestigationMetadata.fs @@ -108,7 +108,7 @@ let allExpectedMetadataTermsEmpty = //] Terms.InvestigationMetadata.cvTerms |> List.skip 1 //(ignore root term) - |> List.map (fun p -> CvParam(p, ParamValue.CvValue (CvTerm.create(accession = "AGMO:00000001", value = "Metadata Section Key", ref = "AGMO")), [])) + |> List.map (fun p -> CvParam(p, ParamValue.CvValue (CvTerm.create(accession = "AGMO:00000001", name = "Metadata Section Key", ref = "AGMO")), [])) [] let ``First Param is CvParam`` () = @@ -226,7 +226,7 @@ let allExpectedMetadataTermsFull = values |> List.mapi (fun i v -> if i = 0 then - CvParam(term, ParamValue.CvValue (CvTerm.create(accession = "AGMO:00000001", value = "Metadata Section Key", ref = "AGMO")), []) + CvParam(term, ParamValue.CvValue (CvTerm.create(accession = "AGMO:00000001", name = "Metadata Section Key", ref = "AGMO")), []) else CvParam(term, ParamValue.Value v, []) ) diff --git a/tests/ARCTokenization.Tests/TestUtils.fs b/tests/ARCTokenization.Tests/TestUtils.fs index 9fe40ce..c1c6857 100644 --- a/tests/ARCTokenization.Tests/TestUtils.fs +++ b/tests/ARCTokenization.Tests/TestUtils.fs @@ -7,16 +7,16 @@ open ARCTokenization.AnnotationTable module CvParam = - let termValuesEqual (cvpExpectec : CvParam) (cvpActual : CvParam) = + let termNamesEqual (cvpExpectec : CvParam) (cvpActual : CvParam) = Assert.Equal( - (CvBase.getCvValue cvpExpectec), - (CvBase.getCvValue cvpActual) + (CvBase.getCvName cvpExpectec), + (CvBase.getCvName cvpActual) ) let hasTermValue (expectedValue : string) (cvpActual : CvParam) = Assert.Equal( expectedValue, - (CvBase.getCvValue cvpActual) + (CvBase.getCvName cvpActual) ) let accessionsEqual (cvpExpectec : CvParam) (cvpActual : CvParam) = @@ -56,7 +56,7 @@ module CvParam = ) let structuralEquality (cvpExpectec : CvParam) (cvpActual : CvParam) = - termValuesEqual cvpExpectec cvpActual + termNamesEqual cvpExpectec cvpActual accessionsEqual cvpExpectec cvpActual refUrisEqual cvpExpectec cvpActual valuesEqual cvpExpectec cvpActual @@ -68,8 +68,8 @@ module UserParam = let termNamesEqual (upActual : UserParam) (upExpectec : UserParam) = Assert.Equal( - (CvBase.getCvValue upActual), - (CvBase.getCvValue upExpectec) + (CvBase.getCvName upActual), + (CvBase.getCvName upExpectec) ) module TokenizedAnnotationTable = diff --git a/tests/ControlledVocabulary.Tests/CvBaseTests.fs b/tests/ControlledVocabulary.Tests/CvBaseTests.fs index 42d781d..8c0c4f4 100644 --- a/tests/ControlledVocabulary.Tests/CvBaseTests.fs +++ b/tests/ControlledVocabulary.Tests/CvBaseTests.fs @@ -3,7 +3,7 @@ open ControlledVocabulary open Xunit -let assayTerm = CvTerm.create(accession = "ARCO:1234", value = "Assay",ref = "ARCO") +let assayTerm = CvTerm.create(accession = "ARCO:1234", name = "Assay",ref = "ARCO") [] let ``ICvBase can be cast to CvParam using generic tryAs`` () =