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

Code generation #32

Merged
merged 6 commits into from
May 14, 2024
Merged

Code generation #32

merged 6 commits into from
May 14, 2024

Conversation

omaus
Copy link
Member

@omaus omaus commented Apr 30, 2024

This PR

@omaus omaus requested review from kMutagene and removed request for kMutagene April 30, 2024 14:54

/// 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_])")
Copy link
Member

Choose a reason for hiding this comment

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

seems like there is a possible escape sequence here, better prefix the string with an '@'

open OBO.NET
open OBO.NET.CodeGeneration
open FSharpAux
open ARCTokenization.StructuralOntology
Copy link
Member

Choose a reason for hiding this comment

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

i would not use these ontologies but static files in this repo as references for tests

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\")"
Copy link
Member

Choose a reason for hiding this comment

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

here, i would also just parse a fully correct fsharp source file as reference, and check wether the full output is correct.

@omaus omaus requested a review from kMutagene May 7, 2024 12:01
@omaus
Copy link
Member Author

omaus commented May 7, 2024

@kMutagene I added the requested changes. Ready for re-review. 😃

@kMutagene kMutagene marked this pull request as ready for review May 7, 2024 12:53
@@ -0,0 +1,11 @@
namespace ARCTokenization.StructuralOntology
Copy link
Member

Choose a reason for hiding this comment

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

Why are you not testing the whole ontology? this is just 3 terms, while your reference obo file contains a lot more.

@omaus
Copy link
Member Author

omaus commented May 14, 2024

@kMutagene I updated according to your requested changes. Ready for re-review. 😊

testCase "returns correct source code" <| fun _ ->
let expected = String.replace "\r" "" refSF
let actual =
CodeGeneration.toSourceCode "Investigation" refObo
Copy link
Member

Choose a reason for hiding this comment

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

There is a ReplaceLineEndings method on strings, this seems like a convoluted way of doing just that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh lol, didn't know about that! 👍🏻😄

@omaus
Copy link
Member Author

omaus commented May 14, 2024

@kMutagene Re-review-ready. 👍🏻

testList "toSourceCode" [
testCase "returns correct source code" <| fun _ ->
let expected = refSF.ReplaceLineEndings()
let actual = (CodeGeneration.toSourceCode "Investigation" refObo).ReplaceLineEndings()
Copy link
Member

Choose a reason for hiding this comment

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

nitpick, but i think the top-level module should be called INVMSO, just as the ontology itself. Once #33 is implemented, this can even be extracted from the header tags i guess. However, no need to change this

@kMutagene
Copy link
Member

🥳

@kMutagene kMutagene merged commit b4c655a into main May 14, 2024
2 checks passed
@kMutagene
Copy link
Member

@omaus do not forget to release the package 🚀

@omaus omaus deleted the feature-CodeGenerator-#31 branch May 14, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] F# code generation from OBO files
2 participants