-
Notifications
You must be signed in to change notification settings - Fork 2
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
Code generation #56
Closed
Closed
Code generation #56
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
11aecd7
Add code generation script for testing & trying purposes
omaus 52aca72
Add code generation functions (WIP)
omaus 719144d
Update function descriptions
omaus ade2f21
Fix errors, add pipeline function
omaus 8c49196
Add unit tests for new code generation functions
omaus acc94c0
Merge branch 'main' into feature-codeGeneration-#55
omaus 610ded6
Try adjust tests for Unix OS
omaus e63c9fa
Try adjust tests for Unix OS, 2nd attempt
omaus f820d7e
(WIP) Add `buildSourceFiles` TaskInfo
omaus b54dce7
Finish `buildSourceFiles` TaskInfo
omaus 2fe08ad
Add functions to check for special characters
omaus b74dba5
Update functions due to new term bindings
omaus ae61785
Build OBO files and source files
omaus 5006731
Update value-binding accessions in unit tests
omaus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,106 +1,107 @@ | ||
 | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2EB71559-9BE4-4E02-9763-9092876D1E4A}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{CE1B84FD-33DE-48E4-A97A-A4BDC34E08F0}" | ||
ProjectSection(SolutionItems) = preProject | ||
.gitignore = .gitignore | ||
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml | ||
build.cmd = build.cmd | ||
build.sh = build.sh | ||
global.json = global.json | ||
LICENSE = LICENSE | ||
package.json = package.json | ||
playground.fsx = playground.fsx | ||
.github\workflows\publish-docs.yml = .github\workflows\publish-docs.yml | ||
README.md = README.md | ||
RELEASE_NOTES.md = RELEASE_NOTES.md | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{67DA0DCC-75F4-4F30-91C3-309A48B13D49}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ControlledVocabulary", "src\ControlledVocabulary\ControlledVocabulary.fsproj", "{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ControlledVocabulary.Tests", "tests\ControlledVocabulary.Tests\ControlledVocabulary.Tests.fsproj", "{2CBEE59D-07E4-460E-8B97-9267965D3F46}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{3DB2A5F4-23F6-4A06-9AE5-CEAC0707735B}" | ||
ProjectSection(SolutionItems) = preProject | ||
build.cmd = build.cmd | ||
build.sh = build.sh | ||
global.json = global.json | ||
EndProjectSection | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Build", "build\Build.fsproj", "{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCTokenization", "src\ARCTokenization\ARCTokenization.fsproj", "{24D99DC2-DF18-45A3-B444-B60351F131DB}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCTokenization.Tests", "tests\ARCTokenization.Tests\ARCTokenization.Tests.fsproj", "{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{551D4715-5ECD-4CAB-8A4A-41E246F4A7B5}" | ||
ProjectSection(SolutionItems) = preProject | ||
docs\index.ipynb = docs\index.ipynb | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ARCTokenization", "ARCTokenization", "{699C5B9A-EA4B-4D25-B05D-16CA14320CFB}" | ||
ProjectSection(SolutionItems) = preProject | ||
docs\ARCTokenization\Introduction.ipynb = docs\ARCTokenization\Introduction.ipynb | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ControlledVocabulary", "ControlledVocabulary", "{524F5156-C079-4AEF-822E-F01DAE6874AA}" | ||
ProjectSection(SolutionItems) = preProject | ||
docs\ControlledVocabulary\CvParam.ipynb = docs\ControlledVocabulary\CvParam.ipynb | ||
docs\ControlledVocabulary\Introduction.ipynb = docs\ControlledVocabulary\Introduction.ipynb | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{4805A6D8-8D85-48F5-8902-57CECF872AE6}" | ||
ProjectSection(SolutionItems) = preProject | ||
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml | ||
.github\workflows\publish-docs.yml = .github\workflows\publish-docs.yml | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49} | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46} = {2EB71559-9BE4-4E02-9763-9092876D1E4A} | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB} = {3DB2A5F4-23F6-4A06-9AE5-CEAC0707735B} | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49} | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3} = {2EB71559-9BE4-4E02-9763-9092876D1E4A} | ||
{699C5B9A-EA4B-4D25-B05D-16CA14320CFB} = {551D4715-5ECD-4CAB-8A4A-41E246F4A7B5} | ||
{524F5156-C079-4AEF-822E-F01DAE6874AA} = {551D4715-5ECD-4CAB-8A4A-41E246F4A7B5} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {933E3470-7D09-4F22-A056-2407458B9600} | ||
EndGlobalSection | ||
EndGlobal | ||
 | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{2EB71559-9BE4-4E02-9763-9092876D1E4A}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{CE1B84FD-33DE-48E4-A97A-A4BDC34E08F0}" | ||
ProjectSection(SolutionItems) = preProject | ||
.gitignore = .gitignore | ||
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml | ||
build.cmd = build.cmd | ||
build.sh = build.sh | ||
global.json = global.json | ||
codeGenTestScript.fsx = codeGenTestScript.fsx | ||
LICENSE = LICENSE | ||
package.json = package.json | ||
playground.fsx = playground.fsx | ||
.github\workflows\publish-docs.yml = .github\workflows\publish-docs.yml | ||
README.md = README.md | ||
RELEASE_NOTES.md = RELEASE_NOTES.md | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{67DA0DCC-75F4-4F30-91C3-309A48B13D49}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ControlledVocabulary", "src\ControlledVocabulary\ControlledVocabulary.fsproj", "{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ControlledVocabulary.Tests", "tests\ControlledVocabulary.Tests\ControlledVocabulary.Tests.fsproj", "{2CBEE59D-07E4-460E-8B97-9267965D3F46}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{3DB2A5F4-23F6-4A06-9AE5-CEAC0707735B}" | ||
ProjectSection(SolutionItems) = preProject | ||
build.cmd = build.cmd | ||
build.sh = build.sh | ||
global.json = global.json | ||
EndProjectSection | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Build", "build\Build.fsproj", "{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCTokenization", "src\ARCTokenization\ARCTokenization.fsproj", "{24D99DC2-DF18-45A3-B444-B60351F131DB}" | ||
EndProject | ||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ARCTokenization.Tests", "tests\ARCTokenization.Tests\ARCTokenization.Tests.fsproj", "{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{551D4715-5ECD-4CAB-8A4A-41E246F4A7B5}" | ||
ProjectSection(SolutionItems) = preProject | ||
docs\index.ipynb = docs\index.ipynb | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ARCTokenization", "ARCTokenization", "{699C5B9A-EA4B-4D25-B05D-16CA14320CFB}" | ||
ProjectSection(SolutionItems) = preProject | ||
docs\ARCTokenization\Introduction.ipynb = docs\ARCTokenization\Introduction.ipynb | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ControlledVocabulary", "ControlledVocabulary", "{524F5156-C079-4AEF-822E-F01DAE6874AA}" | ||
ProjectSection(SolutionItems) = preProject | ||
docs\ControlledVocabulary\CvParam.ipynb = docs\ControlledVocabulary\CvParam.ipynb | ||
docs\ControlledVocabulary\Introduction.ipynb = docs\ControlledVocabulary\Introduction.ipynb | ||
EndProjectSection | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".ci", ".ci", "{4805A6D8-8D85-48F5-8902-57CECF872AE6}" | ||
ProjectSection(SolutionItems) = preProject | ||
.github\workflows\build-and-test.yml = .github\workflows\build-and-test.yml | ||
.github\workflows\publish-docs.yml = .github\workflows\publish-docs.yml | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{F8E5EFC0-C74B-4C3C-BC22-7A5286A31DF6} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49} | ||
{2CBEE59D-07E4-460E-8B97-9267965D3F46} = {2EB71559-9BE4-4E02-9763-9092876D1E4A} | ||
{ED24D0E3-BA79-4F6D-9A30-D05FF4EBAFDB} = {3DB2A5F4-23F6-4A06-9AE5-CEAC0707735B} | ||
{24D99DC2-DF18-45A3-B444-B60351F131DB} = {67DA0DCC-75F4-4F30-91C3-309A48B13D49} | ||
{30177EF1-3980-4FFE-9B49-90B75DCEBDA3} = {2EB71559-9BE4-4E02-9763-9092876D1E4A} | ||
{699C5B9A-EA4B-4D25-B05D-16CA14320CFB} = {551D4715-5ECD-4CAB-8A4A-41E246F4A7B5} | ||
{524F5156-C079-4AEF-822E-F01DAE6874AA} = {551D4715-5ECD-4CAB-8A4A-41E246F4A7B5} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {933E3470-7D09-4F22-A056-2407458B9600} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#I "src/ControlledVocabulary/bin/Debug/netstandard2.0" | ||
#I "src/ControlledVocabulary/bin/Release/netstandard2.0" | ||
#r "ControlledVocabulary.dll" | ||
#I "src/ARCTokenization/bin/Debug/netstandard2.0" | ||
#I "src/ARCTokenization/bin/Release/netstandard2.0" | ||
#r "ARCTokenization.dll" | ||
|
||
#r "nuget: OBO.NET" | ||
#r "nuget: FSharpAux" | ||
|
||
|
||
open ControlledVocabulary | ||
open ARCTokenization | ||
open OBO.NET | ||
open FSharpAux | ||
|
||
|
||
[<Literal>] | ||
let baseString = """module INVSMO = | ||
|
||
""" | ||
|
||
let onto = OboOntology.fromFile false @"C:\Repos\nfdi4plants\ARCTokenization\src\ARCTokenization\structural_ontologies\investigation_metadata_structural_ontology.obo" | ||
|
||
let toUnderscoredName (term : OboTerm) = | ||
term.Name | ||
|> String.replace " " "_" | ||
|
||
let toTermSourceRef (term : OboTerm) = | ||
term.Id | ||
|> String.takeWhile ((<>) ':') | ||
|
||
let toCodeString (term : OboTerm) = | ||
$" let {toUnderscoredName term} = CvTerm.create(\"{term.Id}\", \"{term.Name}\", \"{toTermSourceRef term}\"){System.Environment.NewLine}{System.Environment.NewLine}" | ||
|
||
toCodeString onto.Terms.Head | ||
|
||
let toSourceCode (onto : OboOntology) = | ||
let concattedSingleValues = String.init onto.Terms.Length (fun i -> $"{toCodeString onto.Terms[i]}") | ||
$"{baseString}{concattedSingleValues}" | ||
|
||
toSourceCode onto | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#r "nuget: FSharpAux" | ||
//#r "nuget: FsOboParser" | ||
#r "nuget: OBO.NET" | ||
#r "nuget: FsSpreadsheet.ExcelIO, 4.1.0" | ||
|
||
|
@@ -11,7 +12,9 @@ | |
|
||
open FsSpreadsheet | ||
open FsSpreadsheet.ExcelIO | ||
//open FsOboParser | ||
open OBO.NET | ||
//open FsSpreadsheet.DSL | ||
open ControlledVocabulary | ||
open type ControlledVocabulary.ParamBase | ||
open ARCTokenization | ||
|
@@ -47,6 +50,12 @@ let its = Investigation.parseMetadataSheetsFromTokens() afts | |
|
||
|
||
|
||
|
||
let ot = List.head Terms.InvestigationMetadata.ontology.Terms | ||
|
||
ARCTokenization.StructuralOntology.CodeGeneration.toCodeString ot | ||
CodeGeneration.toSourceCode "Investigation" Terms.InvestigationMetadata.ontology | ||
|
||
System.IO.Directory.GetCurrentDirectory() | ||
let fakePath = CvParam(cvTerm = AFSO.``File Path``, v = System.IO.Directory.GetCurrentDirectory() + "/tests/ARCTokenization.Tests/Fixtures/correct/investigation_simple.xlsx") | ||
|
||
|
@@ -124,7 +133,7 @@ let expectedTermValuesSimple = | |
[""] | ||
[""] | ||
[""] | ||
[""; "Maus"; "Keider"; "müller"; "oih"] | ||
[""; "Maus"; "Keider"; "müller"; "oih"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you seriously need to fix your encoding problems 😆 |
||
[""; "Oliver"; "andreas"] | ||
[""; "L. I."; "C."] | ||
[""; "[email protected]"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/ARCTokenization/structural_ontologies/CodeGeneration.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
namespace ARCTokenization.StructuralOntology | ||
|
||
open ControlledVocabulary | ||
open OBO.NET | ||
open FSharpAux | ||
open type System.Environment | ||
|
||
|
||
/// Functions to generate F# source code from OBO files. | ||
module CodeGeneration = | ||
|
||
[<Literal>] | ||
let baseString = """namespace ARCTokenization.StructuralOntology | ||
|
||
open ControlledVocabulary | ||
|
||
module <name> = | ||
|
||
""" | ||
|
||
/// Takes an OboTerm and returns its name but with all spaces replaced by underscores. | ||
let toUnderscoredName (term : OboTerm) = | ||
term.Name | ||
|> String.replace " " "_" | ||
|
||
/// 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 {toUnderscoredName term} = 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 "<name>" 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please stop committing test scripts to repos. Pls refactor anything relevant to actual unit tests or do not commit it at all.