Skip to content

Commit

Permalink
Add function to return OboTerm as CvTerm
Browse files Browse the repository at this point in the history
  • Loading branch information
omaus committed Jun 4, 2024
1 parent 50645d7 commit 477e1e3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/OBO.NET/OboTerm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
open DBXref
open TermSynonym

open ARCtrl.ISA

open System

open ARCtrl.ISA
open ControlledVocabulary
open FSharpAux


/// Models the entities in an OBO Ontology.
type OboTerm =
Expand Down Expand Up @@ -540,6 +542,18 @@ type OboTerm =
static member getRelatedTermIds (term : OboTerm) =
term.GetRelatedTermIds()

/// Returns the corresponding CvTerm of the OboTerm.
member this.ToCvTerm() =
let tsr =
String.split ':' this.Id
|> Array.head
|> String.trim
CvTerm.create(this.Id, this.Name, tsr)

/// Returns the corresponding CvTerm of the given OboTerm.
static member toCvTerm (term : OboTerm) =
term.ToCvTerm()


/// Representation of a the relation an OboTerm can have with other OboTerms.
type TermRelation<'a> =
Expand Down
11 changes: 11 additions & 0 deletions tests/OBO.NET.Tests/OboTerm.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ namespace OBO.NET.Tests

open Expecto
open OBO.NET
open ControlledVocabulary


module OboTermTests =

let testTerm1 = OboTerm.Create("test:001", Name = "TestTerm1")

[<Tests>]
let oboTermTest =
testList "OboTerm" [
Expand Down Expand Up @@ -35,4 +38,12 @@ module OboTermTests =
]
Expect.sequenceEqual actual expected ""
]
testList "ToCvTerm" [
testCase "returns correct CvTerm" <| fun _ ->
let actual = OboTerm.toCvTerm testTerm1
let expected = CvTerm.create("test:001", "TestTerm1", "test")
Expect.equal actual.RefUri expected.RefUri "TSRs are different"
Expect.equal actual.Name expected.Name "Names are different"
Expect.equal actual.Accession expected.Accession "TANs are different"
]
]

0 comments on commit 477e1e3

Please sign in to comment.