Move annotation start/end out of writers#89
Merged
LeoFeatherstone merged 4 commits intomainfrom May 30, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR centralizes the annotation delimiters by moving the [ and ] wrappers out of the individual writer functions and into the newickRecurse function.
- In
newickRecurse, annotation output is now wrapped with[and] beastAnnotationandnhxAnnotationno longer emit their own brackets
Comments suppressed due to low confidence (1)
src/io/writers/newick.ts:60
- [nitpick] After refactoring the annotation delimiters, add tests for nodes with and without annotations to verify that empty annotations do not produce
[]and that valid annotations remain correctly formatted.
if (node.branchLength !== undefined) {
There was a problem hiding this comment.
Pull Request Overview
This PR moves the handling of annotation start/end markers out of individual annotation writers so that the writers no longer embed brackets and thereby break the spec.
- The newickRecurse function now extracts the annotation string and conditionally wraps it with brackets.
- The beastAnnotation and nhxAnnotation functions no longer prepend/append brackets, thus centralizing annotation formatting.
Comments suppressed due to low confidence (3)
src/io/writers/newick.ts:58
- Confirm that wrapping the annotation output with '[' and ']' in newickRecurse aligns with the intended specification, now that the writers only return the raw annotation content.
res += `[${annotation}]`;
src/io/writers/newick.ts:83
- Ensure documentation is updated to reflect that beastAnnotation no longer appends its own bracket wrappers, and now only returns the core annotation content for external wrapping.
res += '&';
src/io/writers/newick.ts:120
- Update documentation/comments for nhxAnnotation to indicate that it no longer handles its own closing bracket, and that the external caller is now responsible for adding the proper annotation delimiters.
res += '&&NHX:';
LeoFeatherstone
approved these changes
May 30, 2025
Contributor
LeoFeatherstone
left a comment
There was a problem hiding this comment.
Thanks @Wytamma this is a vastly better solution!
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I've moved the annotation start [ and end ] out of the writers so the writers won't break the newick spec.