Skip to content

Commit

Permalink
rename CvTern Value field -> Name
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Aug 16, 2023
1 parent 2293e3f commit b3ddf3c
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 83 deletions.
6 changes: 3 additions & 3 deletions src/ARCTokenization/Address.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
10 changes: 5 additions & 5 deletions src/ARCTokenization/AnnotationTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -291,7 +291,7 @@ module AnnotationTable =
let getNodeType (cvPar : #IParamBase) =
//let castedCvPar = cvPar :?> CvParam<string> // 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"
Expand Down
2 changes: 1 addition & 1 deletion src/ARCTokenization/MetadataSheet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/ARCTokenization/Terms.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =

Expand All @@ -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 =

Expand All @@ -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")
let metadataSectionKey = CvTerm.create(accession = "AGMO:00000001", name = "Metadata Section Key", ref = "AGMO")
12 changes: 6 additions & 6 deletions src/ControlledVocabulary/CvAttributeCollection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type CvAttributeCollection(attributes : IDictionary<string,IParam>) =
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)

Expand All @@ -22,12 +22,12 @@ type CvAttributeCollection(attributes : IDictionary<string,IParam>) =

/// 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
Expand All @@ -39,7 +39,7 @@ type CvAttributeCollection(attributes : IDictionary<string,IParam>) =

/// 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
Expand All @@ -51,15 +51,15 @@ type CvAttributeCollection(attributes : IDictionary<string,IParam>) =

/// 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) =
Dictionary.containsKey name this

/// 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

Expand Down
16 changes: 8 additions & 8 deletions src/ControlledVocabulary/CvContainer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string,IParam>,
properties : IDictionary<string,seq<ICvBase>>
Expand All @@ -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

Expand All @@ -38,7 +38,7 @@ type CvContainer (


new (term : CvTerm, attributes : IDictionary<string,IParam>) =
CvContainer(term.Accession, term.Value, term.RefUri, attributes, Dictionary<string, ICvBase seq>())
CvContainer(term.Accession, term.Name, term.RefUri, attributes, Dictionary<string, ICvBase seq>())
new (term : CvTerm,attributes : seq<IParam>) =
let dict = CvAttributeCollection(attributes)
CvContainer(term, dict)
Expand Down Expand Up @@ -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.
Expand All @@ -319,15 +319,15 @@ type CvContainer (
static member setMany (values : seq<ICvBase>) (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
|> ignore

/// 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}"
$"CvContainer: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}\n\tProperties: {this.Properties.Keys |> Seq.toList}"
8 changes: 4 additions & 4 deletions src/ControlledVocabulary/CvObject.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string,IParam>) =
type CvObject<'T>(cvAccession : string, cvName : string, cvRef : string, object : 'T, attributes : Dictionary<string,IParam>) =

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}"
$"Name: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).Accession}\n\tRefUri: {(this :> ICvBase).RefUri}"
16 changes: 8 additions & 8 deletions src/ControlledVocabulary/CvParam.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ open FSharpAux
///
/// Attributes can be used to further describe the CvParam
[<StructuredFormatDisplay("{DisplayText}")>]
type CvParam(cvAccession : string, cvValue : string, cvRef : string, paramValue : ParamValue, attributes : IDictionary<string,IParam>) =
type CvParam(cvAccession : string, cvName : string, cvRef : string, paramValue : ParamValue, attributes : IDictionary<string,IParam>) =

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

Expand All @@ -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<IParam>) =
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) =
Expand Down Expand Up @@ -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
Expand All @@ -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()
10 changes: 5 additions & 5 deletions src/ControlledVocabulary/CvTerm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
//[<Struct>]
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 = ""
)
Expand Down
14 changes: 7 additions & 7 deletions src/ControlledVocabulary/ICvBase.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -24,16 +24,16 @@ 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) =
cv.RefUri

/// 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) =
Expand All @@ -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) =
Expand Down
8 changes: 4 additions & 4 deletions src/ControlledVocabulary/IParam.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down Expand Up @@ -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)
Expand Down
Loading

0 comments on commit b3ddf3c

Please sign in to comment.