BjornFJohansson / pydna

Clone with Python! Data structures for double stranded DNA & simulation of homologous recombination, Gibson assembly, cut & paste cloning.
Other
166 stars 45 forks source link

shift_location: allow shifting ignoring length of the sequence #281

Closed manulera closed 1 month ago

manulera commented 1 month ago

As of now shitf_location in pydna.utils took three arguments (original_location, shift, lim).

lim is the length of the sequence and it's used to "wrap" the location. This is intended for circular sequences. However, in certain cases, you may want to just move the feature. A use-case for this is [this example] https://github.com/BjornFJohansson/pydna/blob/e87d85a4be47d43a504a4bf75dd61cb536a8e0e3/src/pydna/amplify.py#L354-L356 where you want to shift by the same amount a list of features when you are doing a sequence transformation.

The new behaviour will be that if you pass None as lim, it will shift the sequence and will never wrap it. The way it's implemented is that if lim is None then the function turns lim into essentially infinity (you cannot use the math.inf because it's not an integer, so instead I use sys.maxsize which is the maximum integer possible).

Will implement a test for this as well.

BjornFJohansson commented 1 month ago

This seems a good addition imho.