diff --git a/src/Core/Conversion.fs b/src/Core/Conversion.fs index 8160b878..23485726 100644 --- a/src/Core/Conversion.fs +++ b/src/Core/Conversion.fs @@ -1,4 +1,4 @@ -module ARCtrl.Process.Conversion +module ARCtrl.Process.Conversion open ARCtrl open ARCtrl.Helper @@ -208,7 +208,7 @@ module JsonTypes = /// /// This function allows us, to parse them as an ontology term. let decomposeTechnologyPlatform (name : string) = - let pattern = """(?[^\(]+) \((?[^(]*:[^)]*)\)""" + let pattern = """^(?.+) \((?[^(]*:[^)]*)\)$""" match name with | Regex.ActivePatterns.Regex pattern r -> diff --git a/tests/Core/ArcAssay.Tests.fs b/tests/Core/ArcAssay.Tests.fs index 42aa0303..b72adada 100644 --- a/tests/Core/ArcAssay.Tests.fs +++ b/tests/Core/ArcAssay.Tests.fs @@ -487,9 +487,11 @@ let private tests_updateTable_Copy = let private tests_technologyPlatform = testList "technologyPlatformTests" [ let name = "MyOntology" + let nameWithParentheses = "MyOntology (Mine)" let tsr = "ABC" let tan = "ABC:123" let tp_Term = OntologyAnnotation(name,tsr,tan) + let tp_TermWithParentheses = OntologyAnnotation(nameWithParentheses,tsr,tan) let tp_String = OntologyAnnotation(name) testCase "compose Term" (fun () -> let s = Process.Conversion.JsonTypes.composeTechnologyPlatform tp_Term @@ -501,6 +503,16 @@ let private tests_technologyPlatform = Expect.equal pt_new.NameText name "NameText should match" Expect.equal pt_new.TermAccessionShort tan "ShortTan should match" ) + testCase "compose Term With Parentheses" (fun () -> + let s = Process.Conversion.JsonTypes.composeTechnologyPlatform tp_TermWithParentheses + Expect.equal s $"{nameWithParentheses} ({tan})" "Term was not correctly composed as string." + ) + testCase "decompose Term" (fun () -> + let s = Process.Conversion.JsonTypes.composeTechnologyPlatform tp_TermWithParentheses + let pt_new = Process.Conversion.JsonTypes.decomposeTechnologyPlatform s + Expect.equal pt_new.NameText nameWithParentheses "NameText should match" + Expect.equal pt_new.TermAccessionShort tan "ShortTan should match" + ) testCase "compose String" (fun () -> let s = Process.Conversion.JsonTypes.composeTechnologyPlatform tp_String Expect.equal s $"{name}" "String was not correctly composed as string."