Skip to content

Commit

Permalink
Merge pull request #477 from nfdi4plants/technologyPlatform
Browse files Browse the repository at this point in the history
Fix technologyPlatform not handling parentheses
  • Loading branch information
HLWeil authored Nov 18, 2024
2 parents 3acf034 + 9d2ce07 commit 05faa0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Core/Conversion.fs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ARCtrl.Process.Conversion
module ARCtrl.Process.Conversion

open ARCtrl
open ARCtrl.Helper
Expand Down Expand Up @@ -208,7 +208,7 @@ module JsonTypes =
///
/// This function allows us, to parse them as an ontology term.
let decomposeTechnologyPlatform (name : string) =
let pattern = """(?<value>[^\(]+) \((?<ontology>[^(]*:[^)]*)\)"""
let pattern = """^(?<value>.+) \((?<ontology>[^(]*:[^)]*)\)$"""

match name with
| Regex.ActivePatterns.Regex pattern r ->
Expand Down
12 changes: 12 additions & 0 deletions tests/Core/ArcAssay.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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."
Expand Down

0 comments on commit 05faa0d

Please sign in to comment.