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.
Changes in this PR
The hardcoded codon table objects are no longer generated at buildtime (which makes them global variables prone to being changed by an unexpected process) but initialised as part of their constructor;
NewTranslationTable
. This ensures that the package examples and tests run in proper isolation (and that no consumer gets surprised when they modify a table's weights and find that they've also updated a separate, unrelated table).This PR also makes the codonTable.Copy() function less naive, which was originally created to avoid this "global variable" problem but was too naive. Ideally we would not need to make deep copies; but it is used in
CompromiseCodonTable
andAddCodonTable
Why are you making these changes?
Some examples in the codon package gave different results depending if they were run on their own or if they were run as part of the whole test suite, specifically
ExampleTranslationTable_UpdateWeights
// go test -run=ExampleTranslationTable_UpdateWeights ./synthesis/codon -count=1
// go test ./... -count=1
This was due to the fact that the generated codon tables were global variables, so the tests which ran before
ExampleTranslationTable_UpdateWeights
modified the (pseudorandom) sequence we got out when runningtable.Optimize
. If you ran the test by itself it behaved as if you were running it in isolation (which was presumably intended) The expected output was therefore incorrect.The change makes it so the tables are no longer global variables, so
ExampleTranslationTable_UpdateWeights
now gives the same output if it runs as part of the whole test suit or on its ownAre any changes breaking? (IMPORTANT)
No
Pre-merge checklist
All of these must be satisfied before this PR is considered
ready for merging. Mergeable PRs will be prioritized for review.
primers/primers_test.go
for what this might look like.CHANGELOG.md
in the[Unreleased]
section.