Repository navigation
Conversation
Hoeze
force-pushed
the
feat/transforms-cleanup
branch
from
October 17, 2026 14:08
96d9607 to
93c1b72
Compare
Hoeze
force-pushed
the
feat/transforms-cleanup
branch
from
October 17, 2026 16:22
93c1b72 to
8d04490
Compare
translate takes transl_table and transl_except only as keyword arguments. A codon that is not in the genetic code raises a ValueError that names it, instead of a KeyError. The lookup stays case-sensitive, as in the encoders, so a lowercase codon raises this ValueError too. If the genetic code has the uppercase form of the codon, the message hints at seq.upper() and at FastaStringExtractor, which uppercases by default. Arguments of the wrong type raise a TypeError. TRANSLATION_TABLE is a read-only MappingProxyType, so changing it can no longer change the result of translate. The private table of the vertebrate mitochondrial code is read-only too. A length that is not a multiple of 3 still raises a ValueError, unless transl_except covers the partial last codon. BREAKING CHANGE: pass transl_table and transl_except as keyword arguments, e.g. translate(seq, transl_table=2). Unknown codons, also lowercase ones, raise a ValueError instead of a KeyError. TRANSLATION_TABLE is read-only: copy it with dict(TRANSLATION_TABLE) to change it.
Compose, DummyAxis, SwapAxes and ResizeInterval come from the YAML configs of the Kipoi dataloaders. Without kipoi these four classes are thin wrappers: Compose is a for loop, DummyAxis and SwapAxes call np.expand_dims and np.swapaxes, and ResizeInterval calls Interval.resize with stored arguments. The module kipoiseq2.transforms.transforms and its API page go with them. MIGRATING.md gives a one-line replacement for each class. The bullet for OneHot no longer mentions Compose. It names the method Encoder.one_hot as the callable instead. BREAKING CHANGE: Compose, DummyAxis, SwapAxes and ResizeInterval are removed. Use np.expand_dims, np.swapaxes, interval.resize(width, anchor=anchor), or a function that calls the steps in order.
Without the transform classes, the package kipoiseq2.transforms only held the module functional. Its functions and constants are in the module kipoiseq2.transforms now, e.g. from kipoiseq2.transforms import translate. kipoiseq2.transforms.functional is gone, without an alias. The API reference has one page for kipoiseq2.transforms, and the tests of the module are in tests/test_0_transforms.py. BREAKING CHANGE: import the functions and constants of kipoiseq2.transforms.functional from kipoiseq2.transforms, e.g. from kipoiseq2.transforms import translate.
Hoeze
force-pushed
the
feat/transforms-cleanup
branch
from
October 17, 2026 17:19
8d04490 to
e249795
Compare
This branch has not been deployed
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.
tl;dr:
translatetakes its options only as keyword arguments and raises a ValueError that names unknown codons, also lowercase ones.TRANSLATION_TABLEis read-only. The transform classes are removed, and the functions ofkipoiseq2.transforms.functionalmove to the modulekipoiseq2.transforms.translate(seq, *, transl_table=1, transl_except=None)takestransl_tableandtransl_exceptonly as keyword arguments. A codon that is not in the genetic code, e.g.ATN, raises a ValueError that names it, instead of a KeyError. The lookup stays case-sensitive, as inEncoderandTokenizer, so a lowercase codon raises this ValueError too. If the genetic code has the uppercase form of the codon, the message hints atseq.upper()and atFastaStringExtractor, which uppercases by default.translatebuilds this message with the helper ofkipoiseq2.encodersthatEncoderandTokenizeruse for unknown letters.translateraises a TypeError for arguments of the wrong type: aseqthat is not a str, atransl_tablethat is not an int, atransl_exceptthat is not a mapping, and positions or amino acids of the wrong type intransl_except. Before, a position that was not an int raised a ValueError, and a list astransl_exceptraised an AttributeError.A length that is not a multiple of 3 still raises a ValueError, unless
transl_exceptcovers the partial last codon, e.g. a mitochondrial stop that poly(A) completes.TRANSLATION_TABLEis a read-onlyMappingProxyType. Before, it was a dict, andtranslateused this same dict for the genetic codes 1 and 11, so changing it changed the result oftranslate. The private table of genetic code 2 is read-only too. The attribute docstring ofTRANSLATION_TABLEhides its 64 codons on the API page.Compose,DummyAxis,SwapAxesandResizeIntervalare removed. They come from the YAML configs of the Kipoi dataloaders. Without kipoi these four classes are thin wrappers:Composeis a for loop,DummyAxisandSwapAxescallnp.expand_dimsandnp.swapaxes, andResizeIntervalcallsInterval.resizewith stored arguments. MIGRATING.md gives a one-line replacement for each class, e.g.ResizeInterval(width, anchor)(interval)becomesinterval.resize(width, anchor=anchor). For the 0.1 behavior of the anchors "start" and "end", passuse_strand=False, as forresize_interval. Where a callable is needed,Encoder(...).one_hotreplacesOneHot(...), as an earlier PR of the stack describes.The functions and constants of
kipoiseq2.transforms.functionalare in the modulekipoiseq2.transformsnow, e.g.from kipoiseq2.transforms import translate. The packagekipoiseq2.transformsand its modulefunctionalare gone without an alias, soimport kipoiseq2.transforms.functionalraises a ModuleNotFoundError. MIGRATING.md, the docstrings andkipoiseq2.extractors.vcf_sequse the new path. The API reference merges the pages "Functional transforms" and "Class-based transforms" into one page "Transforms", next to the page "Encoders". The tests move fromtests/test_0_transforms_functional.pytotests/test_0_transforms.py.MIGRATING.md lists the changes at the end of "Breaking changes in 0.2".
BREAKING CHANGE: pass
transl_tableandtransl_excepttotranslateas keyword arguments, e.g.translate(seq, transl_table=2).translateraises a ValueError instead of a KeyError for codons that are not in the genetic code, also for lowercase codons.TRANSLATION_TABLEis read-only: usedict(TRANSLATION_TABLE)for a table that you can change.Compose,DummyAxis,SwapAxesandResizeIntervalare removed: usenp.expand_dims,np.swapaxes,interval.resize(width, anchor=anchor)or a function that calls the steps in order. As forresize_interval, passuse_strand=Falsetointerval.resizefor the 0.1 behavior of the anchors "start" and "end". Import the functions and constants ofkipoiseq2.transforms.functionalfromkipoiseq2.transforms, e.g.from kipoiseq2.transforms import translate.feat(transforms)!: remove the transform classes
feat(transforms)!: move transforms.functional into kipoiseq2.transforms