Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make OntologyAnnotation work with localID as TAN #460

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be kind of reverse right?

We have one example the paff(?) subnamespace in the MS ontology. Using this as example we would have:

TSR: MS; TAN: PEFF:0001032

Then we want to return {| IDSpace = MS; LocalID = PEFF:0001032 |}

In my opinion we should give a explicitly set TSR priority.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then we would have MS:PEFF:0001032 as the short-annotation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sorry my bad! Didnt fully understand the function context. All good from my side

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
Loading