From a8dff3ebfb98b3aacc023c43cbe246a1ebbe478d Mon Sep 17 00:00:00 2001 From: Oliver Maus Date: Tue, 30 Apr 2024 16:15:17 +0200 Subject: [PATCH 1/6] Add code generation --- OBO.NET.sln | 7 +++ src/OBO.NET.CodeGeneration/CodeGeneration.fs | 61 +++++++++++++++++++ .../OBO.NET.CodeGeneration.fsproj | 36 +++++++++++ 3 files changed, 104 insertions(+) create mode 100644 src/OBO.NET.CodeGeneration/CodeGeneration.fs create mode 100644 src/OBO.NET.CodeGeneration/OBO.NET.CodeGeneration.fsproj diff --git a/OBO.NET.sln b/OBO.NET.sln index 50d76eb..f24aa44 100644 --- a/OBO.NET.sln +++ b/OBO.NET.sln @@ -34,6 +34,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{C8635ABF-202 .github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml EndProjectSection EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OBO.NET.CodeGeneration", "src\OBO.NET.CodeGeneration\OBO.NET.CodeGeneration.fsproj", "{67194ACF-4022-4B1A-B849-E574C74CC3E3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -52,6 +54,10 @@ Global {56A33646-9976-4155-A731-224F688D9F6F}.Debug|Any CPU.Build.0 = Debug|Any CPU {56A33646-9976-4155-A731-224F688D9F6F}.Release|Any CPU.ActiveCfg = Release|Any CPU {56A33646-9976-4155-A731-224F688D9F6F}.Release|Any CPU.Build.0 = Release|Any CPU + {67194ACF-4022-4B1A-B849-E574C74CC3E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {67194ACF-4022-4B1A-B849-E574C74CC3E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {67194ACF-4022-4B1A-B849-E574C74CC3E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {67194ACF-4022-4B1A-B849-E574C74CC3E3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -60,6 +66,7 @@ Global {9B04A234-E7AC-4960-99A2-3E1B7B05F32A} = {BC99056C-0431-4FBE-8396-DAB1FFFF2A8F} {0A4EF63F-C659-4AB6-AF88-CB444A98C434} = {A989E8E9-BC2B-4E53-97EC-FE0E9ED342F9} {56A33646-9976-4155-A731-224F688D9F6F} = {5FA53C60-C472-4A99-A3F7-8098B4606CBE} + {67194ACF-4022-4B1A-B849-E574C74CC3E3} = {BC99056C-0431-4FBE-8396-DAB1FFFF2A8F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {54B9E6DB-7B93-4B11-AF6D-F46EF21F9781} diff --git a/src/OBO.NET.CodeGeneration/CodeGeneration.fs b/src/OBO.NET.CodeGeneration/CodeGeneration.fs new file mode 100644 index 0000000..edf62db --- /dev/null +++ b/src/OBO.NET.CodeGeneration/CodeGeneration.fs @@ -0,0 +1,61 @@ +namespace OBO.NET.CodeGeneration + + +open OBO.NET +open FSharpAux +open type System.Environment + + +module CodeGeneration = + + [] + let baseString = """namespace ARCTokenization.StructuralOntology + + open ControlledVocabulary + + module = + +""" + + /// Takes an OboTerm and returns its name but with all spaces replaced by underscores. + let toUnderscoredName (term : OboTerm) = + term.Name + |> String.replace " " "_" + + /// Returns true if a string contains special characters or starts with a number. + let checkForSpecialCharacters str = + let spChs = System.Text.RegularExpressions.Regex("(^\d|[^a-zA-Z0-9_])") + (spChs.Match str).Success + + /// Takes a string and returns it with back ticks ("``") at the beginning and the end. + let addBackTicks str = + $"``{str}``" + + /// Takes an OboTerm and returns its TermSourceRef as string. + let toTermSourceRef (term : OboTerm) = + term.Id + |> String.takeWhile ((<>) ':') + + /// Takes an OboTerm and transforms it into an F# code string for structural ontology libraries. + let toCodeString (term : OboTerm) = + let underscoredName = toUnderscoredName term + let curatedName = + if checkForSpecialCharacters underscoredName then + addBackTicks underscoredName + else underscoredName + $" let {curatedName} = CvTerm.create(\"{term.Id}\", \"{term.Name}\", \"{toTermSourceRef term}\"){NewLine}{NewLine}" + + /// Takes a module name and an OboOntology and returns the F# code of the whole term list for structural ontology libraries. + let toSourceCode moduleName (onto : OboOntology) = + let concattedSingleValues = String.init onto.Terms.Length (fun i -> $"{toCodeString onto.Terms[i]}") + let updatedBaseString = String.replace "" moduleName baseString + $"{updatedBaseString}{concattedSingleValues}" + + /// Takes a module name and an OboOntology and writes the ontology's terms as F# code for structural ontology libraries as a source file at the given path. + let toFile moduleName (onto : OboOntology) path = + System.IO.File.WriteAllText(path, toSourceCode moduleName onto) + + /// Takes a module name and the path to an OBO file and writes the ontology's terms as F# code for structural ontology libraries as a source file at the given output path. + let fromOboFileToSourceFile moduleName inputPath outputPath = + OboOntology.fromFile false inputPath + |> fun o -> toFile moduleName o outputPath \ No newline at end of file diff --git a/src/OBO.NET.CodeGeneration/OBO.NET.CodeGeneration.fsproj b/src/OBO.NET.CodeGeneration/OBO.NET.CodeGeneration.fsproj new file mode 100644 index 0000000..009a627 --- /dev/null +++ b/src/OBO.NET.CodeGeneration/OBO.NET.CodeGeneration.fsproj @@ -0,0 +1,36 @@ + + + + netstandard2.0 + true + + true + + true + + true + snupkg + + + + + + + + + + + + Oliver Maus, F# open source contributors + An OBO file format to F# source code generator, written in F#. + An OBO file format to F# source code generator, written in F#. + MIT + https://github.com/CSBiology/OBO.NET + ontology fsharp file obo codegeneration code generation + https://github.com/CSBiology/OBO.NET + git + https://github.com/CSBiology/OBO.NET/blob/main/LICENSE + https://github.com/CSBiology/OBO.NET/blob/main/RELEASE_NOTES.md + + + \ No newline at end of file From a804343a9cca9963e18786d6c6d02de58d8fea3d Mon Sep 17 00:00:00 2001 From: Oliver Maus Date: Tue, 30 Apr 2024 16:59:26 +0200 Subject: [PATCH 2/6] Add unit tests for code generation --- OBO.NET.sln | 9 ++- .../CodeGeneration.Tests.fs | 55 +++++++++++++++++++ tests/OBO.NET.CodeGeneration.Tests/Main.fs | 7 +++ .../OBO.NET.CodeGeneration.Tests.fsproj | 28 ++++++++++ 4 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs create mode 100644 tests/OBO.NET.CodeGeneration.Tests/Main.fs create mode 100644 tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj diff --git a/OBO.NET.sln b/OBO.NET.sln index f24aa44..2db7238 100644 --- a/OBO.NET.sln +++ b/OBO.NET.sln @@ -34,7 +34,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{C8635ABF-202 .github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml EndProjectSection EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OBO.NET.CodeGeneration", "src\OBO.NET.CodeGeneration\OBO.NET.CodeGeneration.fsproj", "{67194ACF-4022-4B1A-B849-E574C74CC3E3}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "OBO.NET.CodeGeneration", "src\OBO.NET.CodeGeneration\OBO.NET.CodeGeneration.fsproj", "{67194ACF-4022-4B1A-B849-E574C74CC3E3}" +EndProject +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OBO.NET.CodeGeneration.Tests", "tests\OBO.NET.CodeGeneration.Tests\OBO.NET.CodeGeneration.Tests.fsproj", "{75C2BDF9-A623-4C77-8382-798271D772B4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -58,6 +60,10 @@ Global {67194ACF-4022-4B1A-B849-E574C74CC3E3}.Debug|Any CPU.Build.0 = Debug|Any CPU {67194ACF-4022-4B1A-B849-E574C74CC3E3}.Release|Any CPU.ActiveCfg = Release|Any CPU {67194ACF-4022-4B1A-B849-E574C74CC3E3}.Release|Any CPU.Build.0 = Release|Any CPU + {75C2BDF9-A623-4C77-8382-798271D772B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75C2BDF9-A623-4C77-8382-798271D772B4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75C2BDF9-A623-4C77-8382-798271D772B4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75C2BDF9-A623-4C77-8382-798271D772B4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -67,6 +73,7 @@ Global {0A4EF63F-C659-4AB6-AF88-CB444A98C434} = {A989E8E9-BC2B-4E53-97EC-FE0E9ED342F9} {56A33646-9976-4155-A731-224F688D9F6F} = {5FA53C60-C472-4A99-A3F7-8098B4606CBE} {67194ACF-4022-4B1A-B849-E574C74CC3E3} = {BC99056C-0431-4FBE-8396-DAB1FFFF2A8F} + {75C2BDF9-A623-4C77-8382-798271D772B4} = {A989E8E9-BC2B-4E53-97EC-FE0E9ED342F9} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {54B9E6DB-7B93-4B11-AF6D-F46EF21F9781} diff --git a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs new file mode 100644 index 0000000..973d6c3 --- /dev/null +++ b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs @@ -0,0 +1,55 @@ +namespace OBO.NET.CodeGeneration.Tests + +open Expecto +open OBO.NET +open OBO.NET.CodeGeneration +open FSharpAux +open ARCTokenization.StructuralOntology +open ARCTokenization.Terms +open type System.Environment + + +module CodeGenerationTests = + + [] + let toUnderscoredNameTest = + testList "toUnderscoredName" [ + testCase "returns correct underscored name" <| fun _ -> + let expected = "Investigation_Metadata" + let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toUnderscoredName + Expect.equal actual expected "underscored name is not correct" + ] + + [] + let toTermSourceRefTest = + testList "toTermSourceRef" [ + testCase "returns correct TermSourceRef" <| fun _ -> + let expected = "INVMSO" + let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toTermSourceRef + Expect.equal actual expected "TermSourceRef is not correct" + ] + + [] + let toCodeStringTest = + testList "toCodeString" [ + testCase "returns correct F# code" <| fun _ -> + let expected = $" let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine}" + let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toCodeString + Expect.equal actual expected "F# code is not correct" + ] + + [] + let toSourceCodeTest = + testList "toSourceCode" [ + testCase "returns correct source code" <| fun _ -> + let expected = + $"namespace ARCTokenization.StructuralOntology{NewLine}{NewLine} open ControlledVocabulary{NewLine}{NewLine} module Investigation ={NewLine}{NewLine} let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine} let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create(\"INVMSO:00000002\", \"ONTOLOGY SOURCE REFERENCE\", \"INVMSO\"){NewLine}{NewLine} let Term_Source_Name = CvTerm.create(\"INVMSO:00000003\", \"Term Source Name\", \"INVMSO\")" + |> String.replace "\r" "" + let actual = + CodeGeneration.toSourceCode "Investigation" InvestigationMetadata.ontology + |> String.splitS NewLine + |> Array.take 11 + |> String.concat "\n" + |> String.replace "\r" "" + Expect.equal actual expected "Source code is not correct" + ] \ No newline at end of file diff --git a/tests/OBO.NET.CodeGeneration.Tests/Main.fs b/tests/OBO.NET.CodeGeneration.Tests/Main.fs new file mode 100644 index 0000000..3dc55a1 --- /dev/null +++ b/tests/OBO.NET.CodeGeneration.Tests/Main.fs @@ -0,0 +1,7 @@ +open OBO.NET.CodeGeneration.Tests + +open Expecto + + +[] +let main argv = Tests.runTestsInAssemblyWithCLIArgs [] argv \ No newline at end of file diff --git a/tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj b/tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj new file mode 100644 index 0000000..38c6d85 --- /dev/null +++ b/tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj @@ -0,0 +1,28 @@ + + + + net6.0 + + false + false + true + + + + + + + + + + + + + + + + + + + + From 7e603b2bbac1da1cfdd49387792642de6520c522 Mon Sep 17 00:00:00 2001 From: Oliver Maus Date: Fri, 3 May 2024 15:57:50 +0200 Subject: [PATCH 3/6] Do minor changes (WIP) --- src/OBO.NET.CodeGeneration/CodeGeneration.fs | 2 +- .../OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/OBO.NET.CodeGeneration/CodeGeneration.fs b/src/OBO.NET.CodeGeneration/CodeGeneration.fs index edf62db..989f236 100644 --- a/src/OBO.NET.CodeGeneration/CodeGeneration.fs +++ b/src/OBO.NET.CodeGeneration/CodeGeneration.fs @@ -24,7 +24,7 @@ module CodeGeneration = /// Returns true if a string contains special characters or starts with a number. let checkForSpecialCharacters str = - let spChs = System.Text.RegularExpressions.Regex("(^\d|[^a-zA-Z0-9_])") + let spChs = System.Text.RegularExpressions.Regex(@"(^\d|[^a-zA-Z0-9_])") (spChs.Match str).Success /// Takes a string and returns it with back ticks ("``") at the beginning and the end. diff --git a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs index 973d6c3..4d52b45 100644 --- a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs +++ b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs @@ -11,7 +11,6 @@ open type System.Environment module CodeGenerationTests = - [] let toUnderscoredNameTest = testList "toUnderscoredName" [ testCase "returns correct underscored name" <| fun _ -> @@ -20,7 +19,6 @@ module CodeGenerationTests = Expect.equal actual expected "underscored name is not correct" ] - [] let toTermSourceRefTest = testList "toTermSourceRef" [ testCase "returns correct TermSourceRef" <| fun _ -> @@ -29,7 +27,6 @@ module CodeGenerationTests = Expect.equal actual expected "TermSourceRef is not correct" ] - [] let toCodeStringTest = testList "toCodeString" [ testCase "returns correct F# code" <| fun _ -> @@ -38,7 +35,6 @@ module CodeGenerationTests = Expect.equal actual expected "F# code is not correct" ] - [] let toSourceCodeTest = testList "toSourceCode" [ testCase "returns correct source code" <| fun _ -> @@ -52,4 +48,7 @@ module CodeGenerationTests = |> String.concat "\n" |> String.replace "\r" "" Expect.equal actual expected "Source code is not correct" - ] \ No newline at end of file + ] + + [] + let all = testList "CodeGeneration" [toUnderscoredNameTest; toTermSourceRefTest; toCodeStringTest; toSourceCodeTest] \ No newline at end of file From 2874a9dedeeca5e26e434c4fd7213b2e90e49110 Mon Sep 17 00:00:00 2001 From: omaus Date: Tue, 7 May 2024 13:59:29 +0200 Subject: [PATCH 4/6] Add requested changes --- build/ProjectInfo.fs | 1 + playground.fsx | 35 + .../CodeGeneration.Tests.fs | 10 +- .../OBO.NET.CodeGeneration.Tests.fsproj | 4 + .../References/ReferenceOboFile.obo | 673 ++++++++++++++++++ .../References/ReferenceSourceFile.fs | 11 + 6 files changed, 730 insertions(+), 4 deletions(-) create mode 100644 tests/OBO.NET.CodeGeneration.Tests/References/ReferenceOboFile.obo create mode 100644 tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs diff --git a/build/ProjectInfo.fs b/build/ProjectInfo.fs index c55378d..594706f 100644 --- a/build/ProjectInfo.fs +++ b/build/ProjectInfo.fs @@ -7,6 +7,7 @@ let project = "OBO.NET" let testProjects = [ "tests/OBO.NET.Tests/OBO.NET.Tests.fsproj" + "tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj" ] let solutionFile = $"{project}.sln" diff --git a/playground.fsx b/playground.fsx index 419f8d1..76fa227 100644 --- a/playground.fsx +++ b/playground.fsx @@ -1,3 +1,38 @@ +#I "src/OBO.NET/bin/Debug/netstandard2.0" +#I "src/OBO.NET/bin/Release/netstandard2.0" +#I "src/OBO.NET.CodeGeneration/bin/Debug/netstandard2.0" +#I "src/OBO.NET.CodeGeneration/bin/Release/netstandard2.0" + +#r "OBO.NET.dll" +#r "OBO.NET.CodeGeneration.dll" + +open OBO.NET +open OBO.NET.CodeGeneration + +#r "nuget: FSharpAux" +#r "nuget: ARCTokenization" + +open FSharpAux +open ARCTokenization.Terms + +open type System.Environment + +let expected = + $"namespace ARCTokenization.StructuralOntology{NewLine}{NewLine} open ControlledVocabulary{NewLine}{NewLine} module Investigation ={NewLine}{NewLine} let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine} let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create(\"INVMSO:00000002\", \"ONTOLOGY SOURCE REFERENCE\", \"INVMSO\"){NewLine}{NewLine} let Term_Source_Name = CvTerm.create(\"INVMSO:00000003\", \"Term Source Name\", \"INVMSO\")" + |> String.replace "\r" "" +let actual = + CodeGeneration.toSourceCode "Investigation" InvestigationMetadata.ontology + |> String.splitS NewLine + |> Array.take 11 + |> String.concat "\n" + |> String.replace "\r" "" + +OBO.NET.OboOntology.toFile @"C:\Repos\CSBiology\OBO.NET\tests\OBO.NET.CodeGeneration.Tests\References\ReferenceOboFile.obo" InvestigationMetadata.ontology + + +// DEPRECATED + + #I "src/FsOboParser/bin/Debug/netstandard2.0" #I "src/FsOboParser/bin/Release/netstandard2.0" #r "FsOboParser.dll" diff --git a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs index 4d52b45..de499fc 100644 --- a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs +++ b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs @@ -11,11 +11,13 @@ open type System.Environment module CodeGenerationTests = + let refObo = OboOntology.fromFile false (System.IO.Path.Combine(__SOURCE_DIRECTORY__, "References/ReferenceOboFile.obo")) + let toUnderscoredNameTest = testList "toUnderscoredName" [ testCase "returns correct underscored name" <| fun _ -> let expected = "Investigation_Metadata" - let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toUnderscoredName + let actual = List.head refObo.Terms |> CodeGeneration.toUnderscoredName Expect.equal actual expected "underscored name is not correct" ] @@ -23,7 +25,7 @@ module CodeGenerationTests = testList "toTermSourceRef" [ testCase "returns correct TermSourceRef" <| fun _ -> let expected = "INVMSO" - let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toTermSourceRef + let actual = List.head refObo.Terms |> CodeGeneration.toTermSourceRef Expect.equal actual expected "TermSourceRef is not correct" ] @@ -31,7 +33,7 @@ module CodeGenerationTests = testList "toCodeString" [ testCase "returns correct F# code" <| fun _ -> let expected = $" let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine}" - let actual = List.head InvestigationMetadata.ontology.Terms |> CodeGeneration.toCodeString + let actual = List.head refObo.Terms |> CodeGeneration.toCodeString Expect.equal actual expected "F# code is not correct" ] @@ -42,7 +44,7 @@ module CodeGenerationTests = $"namespace ARCTokenization.StructuralOntology{NewLine}{NewLine} open ControlledVocabulary{NewLine}{NewLine} module Investigation ={NewLine}{NewLine} let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine} let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create(\"INVMSO:00000002\", \"ONTOLOGY SOURCE REFERENCE\", \"INVMSO\"){NewLine}{NewLine} let Term_Source_Name = CvTerm.create(\"INVMSO:00000003\", \"Term Source Name\", \"INVMSO\")" |> String.replace "\r" "" let actual = - CodeGeneration.toSourceCode "Investigation" InvestigationMetadata.ontology + CodeGeneration.toSourceCode "Investigation" refObo |> String.splitS NewLine |> Array.take 11 |> String.concat "\n" diff --git a/tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj b/tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj index 38c6d85..6582b4f 100644 --- a/tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj +++ b/tests/OBO.NET.CodeGeneration.Tests/OBO.NET.CodeGeneration.Tests.fsproj @@ -9,10 +9,14 @@ + + + + diff --git a/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceOboFile.obo b/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceOboFile.obo new file mode 100644 index 0000000..2400ed3 --- /dev/null +++ b/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceOboFile.obo @@ -0,0 +1,673 @@ +[Term] +id: INVMSO:00000001 +name: Investigation Metadata +def: "" + +[Term] +id: INVMSO:00000002 +name: ONTOLOGY SOURCE REFERENCE +def: "" +relationship: part_of INVMSO:00000001 + +[Term] +id: INVMSO:00000003 +name: Term Source Name +def: "" +relationship: part_of INVMSO:00000002 +relationship: follows INVMSO:00000002 + +[Term] +id: INVMSO:00000004 +name: Term Source File +def: "" +relationship: part_of INVMSO:00000002 +relationship: follows INVMSO:00000003 + +[Term] +id: INVMSO:00000005 +name: Term Source Version +def: "" +relationship: part_of INVMSO:00000002 +relationship: follows INVMSO:00000004 + +[Term] +id: INVMSO:00000006 +name: Term Source Description +def: "" +relationship: part_of INVMSO:00000002 +relationship: follows INVMSO:00000005 + +[Term] +id: INVMSO:00000007 +name: INVESTIGATION +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000006 + +[Term] +id: INVMSO:00000008 +name: Investigation Identifier +def: "A unique identifier for the Investigation" +relationship: part_of INVMSO:00000007 +relationship: follows INVMSO:00000007 + +[Term] +id: INVMSO:00000009 +name: Investigation Title +def: "A short description of the Investigation" +relationship: part_of INVMSO:00000007 +relationship: follows INVMSO:00000008 + +[Term] +id: INVMSO:00000010 +name: Investigation Description +def: "" +relationship: part_of INVMSO:00000007 +relationship: follows INVMSO:00000009 + +[Term] +id: INVMSO:00000011 +name: Investigation Submission Date +def: "" +relationship: part_of INVMSO:00000007 +relationship: follows INVMSO:00000010 + +[Term] +id: INVMSO:00000012 +name: Investigation Public Release Date +def: "" +relationship: part_of INVMSO:00000007 +relationship: follows INVMSO:00000011 + +[Term] +id: INVMSO:00000013 +name: INVESTIGATION PUBLICATIONS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000012 + +[Term] +id: INVMSO:00000014 +name: Investigation Publication PubMed ID +def: "" +relationship: part_of INVMSO:00000013 +relationship: follows INVMSO:00000013 + +[Term] +id: INVMSO:00000015 +name: Investigation Publication DOI +def: "" +relationship: part_of INVMSO:00000013 +relationship: follows INVMSO:00000014 + +[Term] +id: INVMSO:00000016 +name: Investigation Publication Author List +def: "" +relationship: part_of INVMSO:00000013 +relationship: follows INVMSO:00000015 + +[Term] +id: INVMSO:00000017 +name: Investigation Publication Title +def: "" +relationship: part_of INVMSO:00000013 +relationship: follows INVMSO:00000016 + +[Term] +id: INVMSO:00000018 +name: Investigation Publication Status +def: "" +relationship: part_of INVMSO:00000013 +relationship: follows INVMSO:00000017 + +[Term] +id: INVMSO:00000019 +name: Investigation Publication Status Term Accession Number +def: "" +relationship: part_of INVMSO:00000013 +relationship: follows INVMSO:00000018 + +[Term] +id: INVMSO:00000020 +name: Investigation Publication Status Term Source REF +def: "" +relationship: part_of INVMSO:00000013 +relationship: follows INVMSO:00000019 + +[Term] +id: INVMSO:00000021 +name: INVESTIGATION CONTACTS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000020 + +[Term] +id: INVMSO:00000022 +name: Investigation Person Last Name +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000021 + +[Term] +id: INVMSO:00000023 +name: Investigation Person First Name +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000022 + +[Term] +id: INVMSO:00000024 +name: Investigation Person Mid Initials +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000023 + +[Term] +id: INVMSO:00000025 +name: Investigation Person Email +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000024 + +[Term] +id: INVMSO:00000026 +name: Investigation Person Phone +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000025 + +[Term] +id: INVMSO:00000027 +name: Investigation Person Fax +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000026 + +[Term] +id: INVMSO:00000028 +name: Investigation Person Address +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000027 + +[Term] +id: INVMSO:00000029 +name: Investigation Person Affiliation +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000028 + +[Term] +id: INVMSO:00000030 +name: Investigation Person Roles +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000029 + +[Term] +id: INVMSO:00000031 +name: Investigation Person Roles Term Accession Number +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000030 + +[Term] +id: INVMSO:00000032 +name: Investigation Person Roles Term Source REF +def: "" +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000031 + +[Term] +id: INVMSO:00000093 +name: Comment[] +def: "" +synonym: "Comment[Investigation Person ORCID]" EXACT [] +synonym: "Comment[ORCID]" EXACT [] +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000032 +is_obsolete + +[Term] +id: INVMSO:00000094 +name: Comment[Investigation Person ORCID] +def: "" +synonym: "Comment[]" EXACT [] +synonym: "Comment[ORCID]" EXACT [] +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000032 +is_obsolete + +[Term] +id: INVMSO:00000095 +name: Comment[ORCID] +def: "" +synonym: "Comment[Investigation Person ORCID]" EXACT [] +synonym: "Comment[]" EXACT [] +relationship: part_of INVMSO:00000021 +relationship: follows INVMSO:00000032 + +[Term] +id: INVMSO:00000033 +name: STUDY +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000032 +relationship: follows INVMSO:00000093 +relationship: follows INVMSO:00000094 +relationship: follows INVMSO:00000095 + +[Term] +id: INVMSO:00000034 +name: Study Identifier +def: "" +relationship: part_of INVMSO:00000033 +relationship: follows INVMSO:00000033 + +[Term] +id: INVMSO:00000035 +name: Study Title +def: "" +relationship: part_of INVMSO:00000033 +relationship: follows INVMSO:00000034 + +[Term] +id: INVMSO:00000036 +name: Study Description +def: "" +relationship: part_of INVMSO:00000033 +relationship: follows INVMSO:00000035 + +[Term] +id: INVMSO:00000037 +name: Study Submission Date +def: "" +relationship: part_of INVMSO:00000033 +relationship: follows INVMSO:00000036 + +[Term] +id: INVMSO:00000038 +name: Study Public Release Date +def: "" +relationship: part_of INVMSO:00000033 +relationship: follows INVMSO:00000037 + +[Term] +id: INVMSO:00000039 +name: Study File Name +def: "" +relationship: part_of INVMSO:00000033 +relationship: follows INVMSO:00000038 + +[Term] +id: INVMSO:00000040 +name: STUDY DESIGN DESCRIPTORS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000039 + +[Term] +id: INVMSO:00000041 +name: Study Design Type +def: "" +relationship: part_of INVMSO:00000040 +relationship: follows INVMSO:00000040 + +[Term] +id: INVMSO:00000042 +name: Study Design Type Term Accession Number +def: "" +relationship: part_of INVMSO:00000040 +relationship: follows INVMSO:00000041 + +[Term] +id: INVMSO:00000043 +name: Study Design Type Term Source REF +def: "" +relationship: part_of INVMSO:00000040 +relationship: follows INVMSO:00000042 + +[Term] +id: INVMSO:00000044 +name: STUDY PUBLICATIONS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000043 + +[Term] +id: INVMSO:00000045 +name: Study Publication PubMed ID +def: "" +relationship: part_of INVMSO:00000044 +relationship: follows INVMSO:00000044 + +[Term] +id: INVMSO:00000046 +name: Study Publication DOI +def: "" +relationship: part_of INVMSO:00000044 +relationship: follows INVMSO:00000045 + +[Term] +id: INVMSO:00000047 +name: Study Publication Author List +def: "" +relationship: part_of INVMSO:00000044 +relationship: follows INVMSO:00000046 + +[Term] +id: INVMSO:00000048 +name: Study Publication Title +def: "" +relationship: part_of INVMSO:00000044 +relationship: follows INVMSO:00000047 + +[Term] +id: INVMSO:00000049 +name: Study Publication Status +def: "" +relationship: part_of INVMSO:00000044 +relationship: follows INVMSO:00000048 + +[Term] +id: INVMSO:00000050 +name: Study Publication Status Term Accession Number +def: "" +relationship: part_of INVMSO:00000044 +relationship: follows INVMSO:00000049 + +[Term] +id: INVMSO:00000051 +name: Study Publication Status Term Source REF +def: "" +relationship: part_of INVMSO:00000044 +relationship: follows INVMSO:00000050 + +[Term] +id: INVMSO:00000052 +name: STUDY FACTORS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000051 + +[Term] +id: INVMSO:00000053 +name: Study Factor Name +def: "" +relationship: part_of INVMSO:00000052 +relationship: follows INVMSO:00000052 + +[Term] +id: INVMSO:00000054 +name: Study Factor Type +def: "" +relationship: part_of INVMSO:00000052 +relationship: follows INVMSO:00000053 + +[Term] +id: INVMSO:00000055 +name: Study Factor Type Term Accession Number +def: "" +relationship: part_of INVMSO:00000052 +relationship: follows INVMSO:00000054 + +[Term] +id: INVMSO:00000056 +name: Study Factor Type Term Source REF +def: "" +relationship: part_of INVMSO:00000052 +relationship: follows INVMSO:00000055 + +[Term] +id: INVMSO:00000057 +name: STUDY ASSAYS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000056 + +[Term] +id: INVMSO:00000058 +name: Study Assay Measurement Type +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000057 + +[Term] +id: INVMSO:00000059 +name: Study Assay Measurement Type Term Accession Number +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000058 + +[Term] +id: INVMSO:00000060 +name: Study Assay Measurement Type Term Source REF +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000059 + +[Term] +id: INVMSO:00000061 +name: Study Assay Technology Type +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000060 + +[Term] +id: INVMSO:00000062 +name: Study Assay Technology Type Term Accession Number +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000061 + +[Term] +id: INVMSO:00000063 +name: Study Assay Technology Type Term Source REF +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000062 + +[Term] +id: INVMSO:00000064 +name: Study Assay Technology Platform +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000063 + +[Term] +id: INVMSO:00000065 +name: Study Assay File Name +def: "" +relationship: part_of INVMSO:00000057 +relationship: follows INVMSO:00000064 + +[Term] +id: INVMSO:00000066 +name: STUDY PROTOCOLS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000065 + +[Term] +id: INVMSO:00000067 +name: Study Protocol Name +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000066 + +[Term] +id: INVMSO:00000068 +name: Study Protocol Type +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000067 + +[Term] +id: INVMSO:00000069 +name: Study Protocol Type Term Accession Number +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000068 + +[Term] +id: INVMSO:00000070 +name: Study Protocol Type Term Source REF +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000069 + +[Term] +id: INVMSO:00000071 +name: Study Protocol Description +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000070 + +[Term] +id: INVMSO:00000072 +name: Study Protocol URI +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000071 + +[Term] +id: INVMSO:00000073 +name: Study Protocol Version +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000072 + +[Term] +id: INVMSO:00000074 +name: Study Protocol Parameters Name +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000073 + +[Term] +id: INVMSO:00000075 +name: Study Protocol Parameters Term Accession Number +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000074 + +[Term] +id: INVMSO:00000076 +name: Study Protocol Parameters Term Source REF +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000075 + +[Term] +id: INVMSO:00000077 +name: Study Protocol Components Name +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000076 + +[Term] +id: INVMSO:00000078 +name: Study Protocol Components Type +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000077 + +[Term] +id: INVMSO:00000079 +name: Study Protocol Components Type Term Accession Number +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000078 + +[Term] +id: INVMSO:00000080 +name: Study Protocol Components Type Term Source REF +def: "" +relationship: part_of INVMSO:00000066 +relationship: follows INVMSO:00000079 + +[Term] +id: INVMSO:00000081 +name: STUDY CONTACTS +def: "" +relationship: part_of INVMSO:00000001 +relationship: follows INVMSO:00000080 + +[Term] +id: INVMSO:00000082 +name: Study Person Last Name +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000081 + +[Term] +id: INVMSO:00000083 +name: Study Person First Name +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000082 + +[Term] +id: INVMSO:00000084 +name: Study Person Mid Initials +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000083 + +[Term] +id: INVMSO:00000085 +name: Study Person Email +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000084 + +[Term] +id: INVMSO:00000086 +name: Study Person Phone +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000085 + +[Term] +id: INVMSO:00000087 +name: Study Person Fax +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000086 + +[Term] +id: INVMSO:00000088 +name: Study Person Address +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000087 + +[Term] +id: INVMSO:00000089 +name: Study Person Affiliation +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000088 + +[Term] +id: INVMSO:00000090 +name: Study Person Roles +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000089 + +[Term] +id: INVMSO:00000091 +name: Study Person Roles Term Accession Number +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000090 + +[Term] +id: INVMSO:00000092 +name: Study Person Roles Term Source REF +def: "" +relationship: part_of INVMSO:00000081 +relationship: follows INVMSO:00000091 + diff --git a/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs b/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs new file mode 100644 index 0000000..9195ed5 --- /dev/null +++ b/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs @@ -0,0 +1,11 @@ +namespace ARCTokenization.StructuralOntology + + open ControlledVocabulary + + module Investigation = + + let Investigation_Metadata = CvTerm.create("INVMSO:00000001", "Investigation Metadata", "INVMSO") + + let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create("INVMSO:00000002", "ONTOLOGY SOURCE REFERENCE", "INVMSO") + + let Term_Source_Name = CvTerm.create("INVMSO:00000003", "Term Source Name", "INVMSO") \ No newline at end of file From 2144050b20b5b53830eaf235d6c5934b0420ce52 Mon Sep 17 00:00:00 2001 From: Oliver Maus Date: Tue, 14 May 2024 16:30:32 +0200 Subject: [PATCH 5/6] Update tests according to request --- playground.fsx | 4 +- .../CodeGeneration.Tests.fs | 9 +- .../References/ReferenceSourceFile.fs | 207 +++++++++++++++++- 3 files changed, 203 insertions(+), 17 deletions(-) diff --git a/playground.fsx b/playground.fsx index 76fa227..7e82c69 100644 --- a/playground.fsx +++ b/playground.fsx @@ -27,7 +27,9 @@ let actual = |> String.concat "\n" |> String.replace "\r" "" -OBO.NET.OboOntology.toFile @"C:\Repos\CSBiology\OBO.NET\tests\OBO.NET.CodeGeneration.Tests\References\ReferenceOboFile.obo" InvestigationMetadata.ontology +// OBO.NET.OboOntology.toFile @"C:\Repos\CSBiology\OBO.NET\tests\OBO.NET.CodeGeneration.Tests\References\ReferenceOboFile.obo" InvestigationMetadata.ontology + +CodeGeneration.toFile "InvestigationMetadata" InvestigationMetadata.ontology @"C:\Repos\CSBiology\OBO.NET\tests\OBO.NET.CodeGeneration.Tests\References\ReferenceSourceFile2.fs" // DEPRECATED diff --git a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs index de499fc..d89c25f 100644 --- a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs +++ b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs @@ -6,12 +6,14 @@ open OBO.NET.CodeGeneration open FSharpAux open ARCTokenization.StructuralOntology open ARCTokenization.Terms +open System.IO open type System.Environment module CodeGenerationTests = - let refObo = OboOntology.fromFile false (System.IO.Path.Combine(__SOURCE_DIRECTORY__, "References/ReferenceOboFile.obo")) + let refObo = OboOntology.fromFile false (Path.Combine(__SOURCE_DIRECTORY__, "References/ReferenceOboFile.obo")) + let refSF = File.ReadAllText (Path.Combine(__SOURCE_DIRECTORY__, "References/ReferenceSourceFile.fs")) let toUnderscoredNameTest = testList "toUnderscoredName" [ @@ -40,13 +42,10 @@ module CodeGenerationTests = let toSourceCodeTest = testList "toSourceCode" [ testCase "returns correct source code" <| fun _ -> - let expected = - $"namespace ARCTokenization.StructuralOntology{NewLine}{NewLine} open ControlledVocabulary{NewLine}{NewLine} module Investigation ={NewLine}{NewLine} let Investigation_Metadata = CvTerm.create(\"INVMSO:00000001\", \"Investigation Metadata\", \"INVMSO\"){NewLine}{NewLine} let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create(\"INVMSO:00000002\", \"ONTOLOGY SOURCE REFERENCE\", \"INVMSO\"){NewLine}{NewLine} let Term_Source_Name = CvTerm.create(\"INVMSO:00000003\", \"Term Source Name\", \"INVMSO\")" - |> String.replace "\r" "" + let expected = String.replace "\r" "" refSF let actual = CodeGeneration.toSourceCode "Investigation" refObo |> String.splitS NewLine - |> Array.take 11 |> String.concat "\n" |> String.replace "\r" "" Expect.equal actual expected "Source code is not correct" diff --git a/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs b/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs index 9195ed5..b93d7bd 100644 --- a/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs +++ b/tests/OBO.NET.CodeGeneration.Tests/References/ReferenceSourceFile.fs @@ -1,11 +1,196 @@ -namespace ARCTokenization.StructuralOntology - - open ControlledVocabulary - - module Investigation = - - let Investigation_Metadata = CvTerm.create("INVMSO:00000001", "Investigation Metadata", "INVMSO") - - let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create("INVMSO:00000002", "ONTOLOGY SOURCE REFERENCE", "INVMSO") - - let Term_Source_Name = CvTerm.create("INVMSO:00000003", "Term Source Name", "INVMSO") \ No newline at end of file +namespace ARCTokenization.StructuralOntology + + open ControlledVocabulary + + module Investigation = + + let Investigation_Metadata = CvTerm.create("INVMSO:00000001", "Investigation Metadata", "INVMSO") + + let ONTOLOGY_SOURCE_REFERENCE = CvTerm.create("INVMSO:00000002", "ONTOLOGY SOURCE REFERENCE", "INVMSO") + + let Term_Source_Name = CvTerm.create("INVMSO:00000003", "Term Source Name", "INVMSO") + + let Term_Source_File = CvTerm.create("INVMSO:00000004", "Term Source File", "INVMSO") + + let Term_Source_Version = CvTerm.create("INVMSO:00000005", "Term Source Version", "INVMSO") + + let Term_Source_Description = CvTerm.create("INVMSO:00000006", "Term Source Description", "INVMSO") + + let INVESTIGATION = CvTerm.create("INVMSO:00000007", "INVESTIGATION", "INVMSO") + + let Investigation_Identifier = CvTerm.create("INVMSO:00000008", "Investigation Identifier", "INVMSO") + + let Investigation_Title = CvTerm.create("INVMSO:00000009", "Investigation Title", "INVMSO") + + let Investigation_Description = CvTerm.create("INVMSO:00000010", "Investigation Description", "INVMSO") + + let Investigation_Submission_Date = CvTerm.create("INVMSO:00000011", "Investigation Submission Date", "INVMSO") + + let Investigation_Public_Release_Date = CvTerm.create("INVMSO:00000012", "Investigation Public Release Date", "INVMSO") + + let INVESTIGATION_PUBLICATIONS = CvTerm.create("INVMSO:00000013", "INVESTIGATION PUBLICATIONS", "INVMSO") + + let Investigation_Publication_PubMed_ID = CvTerm.create("INVMSO:00000014", "Investigation Publication PubMed ID", "INVMSO") + + let Investigation_Publication_DOI = CvTerm.create("INVMSO:00000015", "Investigation Publication DOI", "INVMSO") + + let Investigation_Publication_Author_List = CvTerm.create("INVMSO:00000016", "Investigation Publication Author List", "INVMSO") + + let Investigation_Publication_Title = CvTerm.create("INVMSO:00000017", "Investigation Publication Title", "INVMSO") + + let Investigation_Publication_Status = CvTerm.create("INVMSO:00000018", "Investigation Publication Status", "INVMSO") + + let Investigation_Publication_Status_Term_Accession_Number = CvTerm.create("INVMSO:00000019", "Investigation Publication Status Term Accession Number", "INVMSO") + + let Investigation_Publication_Status_Term_Source_REF = CvTerm.create("INVMSO:00000020", "Investigation Publication Status Term Source REF", "INVMSO") + + let INVESTIGATION_CONTACTS = CvTerm.create("INVMSO:00000021", "INVESTIGATION CONTACTS", "INVMSO") + + let Investigation_Person_Last_Name = CvTerm.create("INVMSO:00000022", "Investigation Person Last Name", "INVMSO") + + let Investigation_Person_First_Name = CvTerm.create("INVMSO:00000023", "Investigation Person First Name", "INVMSO") + + let Investigation_Person_Mid_Initials = CvTerm.create("INVMSO:00000024", "Investigation Person Mid Initials", "INVMSO") + + let Investigation_Person_Email = CvTerm.create("INVMSO:00000025", "Investigation Person Email", "INVMSO") + + let Investigation_Person_Phone = CvTerm.create("INVMSO:00000026", "Investigation Person Phone", "INVMSO") + + let Investigation_Person_Fax = CvTerm.create("INVMSO:00000027", "Investigation Person Fax", "INVMSO") + + let Investigation_Person_Address = CvTerm.create("INVMSO:00000028", "Investigation Person Address", "INVMSO") + + let Investigation_Person_Affiliation = CvTerm.create("INVMSO:00000029", "Investigation Person Affiliation", "INVMSO") + + let Investigation_Person_Roles = CvTerm.create("INVMSO:00000030", "Investigation Person Roles", "INVMSO") + + let Investigation_Person_Roles_Term_Accession_Number = CvTerm.create("INVMSO:00000031", "Investigation Person Roles Term Accession Number", "INVMSO") + + let Investigation_Person_Roles_Term_Source_REF = CvTerm.create("INVMSO:00000032", "Investigation Person Roles Term Source REF", "INVMSO") + + let ``Comment[]`` = CvTerm.create("INVMSO:00000093", "Comment[]", "INVMSO") + + let ``Comment[Investigation_Person_ORCID]`` = CvTerm.create("INVMSO:00000094", "Comment[Investigation Person ORCID]", "INVMSO") + + let ``Comment[ORCID]`` = CvTerm.create("INVMSO:00000095", "Comment[ORCID]", "INVMSO") + + let STUDY = CvTerm.create("INVMSO:00000033", "STUDY", "INVMSO") + + let Study_Identifier = CvTerm.create("INVMSO:00000034", "Study Identifier", "INVMSO") + + let Study_Title = CvTerm.create("INVMSO:00000035", "Study Title", "INVMSO") + + let Study_Description = CvTerm.create("INVMSO:00000036", "Study Description", "INVMSO") + + let Study_Submission_Date = CvTerm.create("INVMSO:00000037", "Study Submission Date", "INVMSO") + + let Study_Public_Release_Date = CvTerm.create("INVMSO:00000038", "Study Public Release Date", "INVMSO") + + let Study_File_Name = CvTerm.create("INVMSO:00000039", "Study File Name", "INVMSO") + + let STUDY_DESIGN_DESCRIPTORS = CvTerm.create("INVMSO:00000040", "STUDY DESIGN DESCRIPTORS", "INVMSO") + + let Study_Design_Type = CvTerm.create("INVMSO:00000041", "Study Design Type", "INVMSO") + + let Study_Design_Type_Term_Accession_Number = CvTerm.create("INVMSO:00000042", "Study Design Type Term Accession Number", "INVMSO") + + let Study_Design_Type_Term_Source_REF = CvTerm.create("INVMSO:00000043", "Study Design Type Term Source REF", "INVMSO") + + let STUDY_PUBLICATIONS = CvTerm.create("INVMSO:00000044", "STUDY PUBLICATIONS", "INVMSO") + + let Study_Publication_PubMed_ID = CvTerm.create("INVMSO:00000045", "Study Publication PubMed ID", "INVMSO") + + let Study_Publication_DOI = CvTerm.create("INVMSO:00000046", "Study Publication DOI", "INVMSO") + + let Study_Publication_Author_List = CvTerm.create("INVMSO:00000047", "Study Publication Author List", "INVMSO") + + let Study_Publication_Title = CvTerm.create("INVMSO:00000048", "Study Publication Title", "INVMSO") + + let Study_Publication_Status = CvTerm.create("INVMSO:00000049", "Study Publication Status", "INVMSO") + + let Study_Publication_Status_Term_Accession_Number = CvTerm.create("INVMSO:00000050", "Study Publication Status Term Accession Number", "INVMSO") + + let Study_Publication_Status_Term_Source_REF = CvTerm.create("INVMSO:00000051", "Study Publication Status Term Source REF", "INVMSO") + + let STUDY_FACTORS = CvTerm.create("INVMSO:00000052", "STUDY FACTORS", "INVMSO") + + let Study_Factor_Name = CvTerm.create("INVMSO:00000053", "Study Factor Name", "INVMSO") + + let Study_Factor_Type = CvTerm.create("INVMSO:00000054", "Study Factor Type", "INVMSO") + + let Study_Factor_Type_Term_Accession_Number = CvTerm.create("INVMSO:00000055", "Study Factor Type Term Accession Number", "INVMSO") + + let Study_Factor_Type_Term_Source_REF = CvTerm.create("INVMSO:00000056", "Study Factor Type Term Source REF", "INVMSO") + + let STUDY_ASSAYS = CvTerm.create("INVMSO:00000057", "STUDY ASSAYS", "INVMSO") + + let Study_Assay_Measurement_Type = CvTerm.create("INVMSO:00000058", "Study Assay Measurement Type", "INVMSO") + + let Study_Assay_Measurement_Type_Term_Accession_Number = CvTerm.create("INVMSO:00000059", "Study Assay Measurement Type Term Accession Number", "INVMSO") + + let Study_Assay_Measurement_Type_Term_Source_REF = CvTerm.create("INVMSO:00000060", "Study Assay Measurement Type Term Source REF", "INVMSO") + + let Study_Assay_Technology_Type = CvTerm.create("INVMSO:00000061", "Study Assay Technology Type", "INVMSO") + + let Study_Assay_Technology_Type_Term_Accession_Number = CvTerm.create("INVMSO:00000062", "Study Assay Technology Type Term Accession Number", "INVMSO") + + let Study_Assay_Technology_Type_Term_Source_REF = CvTerm.create("INVMSO:00000063", "Study Assay Technology Type Term Source REF", "INVMSO") + + let Study_Assay_Technology_Platform = CvTerm.create("INVMSO:00000064", "Study Assay Technology Platform", "INVMSO") + + let Study_Assay_File_Name = CvTerm.create("INVMSO:00000065", "Study Assay File Name", "INVMSO") + + let STUDY_PROTOCOLS = CvTerm.create("INVMSO:00000066", "STUDY PROTOCOLS", "INVMSO") + + let Study_Protocol_Name = CvTerm.create("INVMSO:00000067", "Study Protocol Name", "INVMSO") + + let Study_Protocol_Type = CvTerm.create("INVMSO:00000068", "Study Protocol Type", "INVMSO") + + let Study_Protocol_Type_Term_Accession_Number = CvTerm.create("INVMSO:00000069", "Study Protocol Type Term Accession Number", "INVMSO") + + let Study_Protocol_Type_Term_Source_REF = CvTerm.create("INVMSO:00000070", "Study Protocol Type Term Source REF", "INVMSO") + + let Study_Protocol_Description = CvTerm.create("INVMSO:00000071", "Study Protocol Description", "INVMSO") + + let Study_Protocol_URI = CvTerm.create("INVMSO:00000072", "Study Protocol URI", "INVMSO") + + let Study_Protocol_Version = CvTerm.create("INVMSO:00000073", "Study Protocol Version", "INVMSO") + + let Study_Protocol_Parameters_Name = CvTerm.create("INVMSO:00000074", "Study Protocol Parameters Name", "INVMSO") + + let Study_Protocol_Parameters_Term_Accession_Number = CvTerm.create("INVMSO:00000075", "Study Protocol Parameters Term Accession Number", "INVMSO") + + let Study_Protocol_Parameters_Term_Source_REF = CvTerm.create("INVMSO:00000076", "Study Protocol Parameters Term Source REF", "INVMSO") + + let Study_Protocol_Components_Name = CvTerm.create("INVMSO:00000077", "Study Protocol Components Name", "INVMSO") + + let Study_Protocol_Components_Type = CvTerm.create("INVMSO:00000078", "Study Protocol Components Type", "INVMSO") + + let Study_Protocol_Components_Type_Term_Accession_Number = CvTerm.create("INVMSO:00000079", "Study Protocol Components Type Term Accession Number", "INVMSO") + + let Study_Protocol_Components_Type_Term_Source_REF = CvTerm.create("INVMSO:00000080", "Study Protocol Components Type Term Source REF", "INVMSO") + + let STUDY_CONTACTS = CvTerm.create("INVMSO:00000081", "STUDY CONTACTS", "INVMSO") + + let Study_Person_Last_Name = CvTerm.create("INVMSO:00000082", "Study Person Last Name", "INVMSO") + + let Study_Person_First_Name = CvTerm.create("INVMSO:00000083", "Study Person First Name", "INVMSO") + + let Study_Person_Mid_Initials = CvTerm.create("INVMSO:00000084", "Study Person Mid Initials", "INVMSO") + + let Study_Person_Email = CvTerm.create("INVMSO:00000085", "Study Person Email", "INVMSO") + + let Study_Person_Phone = CvTerm.create("INVMSO:00000086", "Study Person Phone", "INVMSO") + + let Study_Person_Fax = CvTerm.create("INVMSO:00000087", "Study Person Fax", "INVMSO") + + let Study_Person_Address = CvTerm.create("INVMSO:00000088", "Study Person Address", "INVMSO") + + let Study_Person_Affiliation = CvTerm.create("INVMSO:00000089", "Study Person Affiliation", "INVMSO") + + let Study_Person_Roles = CvTerm.create("INVMSO:00000090", "Study Person Roles", "INVMSO") + + let Study_Person_Roles_Term_Accession_Number = CvTerm.create("INVMSO:00000091", "Study Person Roles Term Accession Number", "INVMSO") + + let Study_Person_Roles_Term_Source_REF = CvTerm.create("INVMSO:00000092", "Study Person Roles Term Source REF", "INVMSO") + From e81e2ba583997eb22844bd73f3a4e5d390037c0b Mon Sep 17 00:00:00 2001 From: Oliver Maus Date: Tue, 14 May 2024 17:04:34 +0200 Subject: [PATCH 6/6] Use `ReplaceLineEndingsMethod()` instead of own functions --- .../OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs index d89c25f..67c7696 100644 --- a/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs +++ b/tests/OBO.NET.CodeGeneration.Tests/CodeGeneration.Tests.fs @@ -42,12 +42,8 @@ module CodeGenerationTests = let toSourceCodeTest = testList "toSourceCode" [ testCase "returns correct source code" <| fun _ -> - let expected = String.replace "\r" "" refSF - let actual = - CodeGeneration.toSourceCode "Investigation" refObo - |> String.splitS NewLine - |> String.concat "\n" - |> String.replace "\r" "" + let expected = refSF.ReplaceLineEndings() + let actual = (CodeGeneration.toSourceCode "Investigation" refObo).ReplaceLineEndings() Expect.equal actual expected "Source code is not correct" ]