Skip to content

Commit

Permalink
Merge pull request #460 from nfdi4plants/ontologyAnnotationFix
Browse files Browse the repository at this point in the history
Make OntologyAnnotation work with localID as TAN
  • Loading branch information
HLWeil authored Oct 23, 2024
2 parents edb22da + 77d1054 commit 924a87d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
10 changes: 8 additions & 2 deletions src/Core/OntologyAnnotation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ type OntologyAnnotation(?name,?tsr,?tan, ?comments) =

member this.TANInfo =
match this.TermAccessionNumber with
| Some v ->
Regex.tryParseTermAnnotation v
| Some tan ->
match Regex.tryParseTermAnnotation tan with
| Some ta -> Some ta
| None ->
match this.TermSourceREF with
| Some "" | None -> None
| Some tsr ->
Some {| IDSpace = tsr; LocalID = tan |}
| None -> None

member this.NameText =
Expand Down
20 changes: 14 additions & 6 deletions tests/Core/OntologyAnnotation.Tests.fs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module OntologyAnnotation.Tests
module OntologyAnnotation.Tests

open TestingUtils
open ARCtrl

module private Helper =
let short = "EFO:0000721"
let uri = "https://bioregistry.io/EFO:0000721"
let otherParseable = "http://www.ebi.ac.uk/efo/EFO_0000721"
module Helper =
let tsr = "EFO"
let localID = "0000721"
let short = $"{tsr}:{localID}"
let uri = $"https://bioregistry.io/{tsr}:{localID}"
let otherParseable = $"http://www.ebi.ac.uk/efo/{tsr}_{localID}"
let other = "Unparseable"

open Helper
Expand Down Expand Up @@ -79,7 +81,13 @@ let private tests_equals = testList "Equals" [
Expect.notEqual oa1 oa2 ""
]

let private tests_constructor = testList "constructor" [
let private tests_constructor = testList "constructor" [
testCase "FromSplitTSRAndLocalID" (fun () ->
let oa = OntologyAnnotation(tsr = tsr, tan = localID)
Expect.equal oa.TermAccessionNumber.Value localID "TAN incorrect"
Expect.equal oa.TermAccessionShort short "short TAN incorrect"
Expect.equal oa.TermAccessionOntobeeUrl uri "uri TAN incorrect"
)
testCase "FromShort" (fun () ->
let oa = OntologyAnnotation(tan = short)
Expect.equal oa.TermAccessionNumber.Value short "TAN incorrect"
Expand Down

0 comments on commit 924a87d

Please sign in to comment.