You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Loosen restriction of FormattedSeq._table in Restriction module #4940
forcinb"ABCDGHKMNRSTVWY": # Only allow IUPAC letters
table[c] =c# map uppercase to uppercase
table[c-upper_to_lower] =c# map lowercase to uppercase
returnbytes(table)
However, even if only IUPAC characters are allowed, degenerate base codes are not interpreted as such (e.g. N is not treated as "any of ACGT" but as an N, character, so the below snippet returns an empty list without matches.
Given this, I think it would be safe to remove this restriction and allow all letters. Below some use-cases where this would allow better usage of biopython. Will submit a PR on this.
Impact on generic use-case
This is a bit problematic for a biopython general use-case if people are using dU bases in DNA. This is done for USER cloning.
Impact on pydna
In addition, in pydna we are thinking to use non-DNA characters to represent single-strand DNA bits in sequences. For instance, the below DNA molecule
GATCGUAAAC
CAUTUGCTAG
PEXIGULAOCQFZJ
can be represented as a single string PEXIGULAOCQFZJ where PEXI represents ACGT on top strand only, and QFZJ represents CTAG on bottom strand only.
The problem is that these cannot be used for restriction using the search method of restriction enzymes because they have non-allowed characters.
This module is without a dedicated maintainer and while there have been a few efforts to rewrite it (avoiding the current structure with a class per enzyme), that is unlikely to happen soon.
I'm unclear how relaxing this check would help, given ambiguous based as not interpreted as such anyway - nor would your RNA extensions be understood.
@peterjc@manulera We have a use case in Pydna where we expanded the alphabet to deal with uracil as used in USER-cloning for example.
The problem is not so much getting a result for non-standard bases, I think that part is fine the way it is currently.
The problem is that the Bio.Restriction module cast all sequences as FormattedSeq where there is a check that will not allow initiating a FormattedSeq with anything else than what is in the matching dict defined in line 98 in the Bio.Restriction module.
I think this check is not needed. IMHO, removing it would comply with the idea of the responsible user.
That said, I think there are other options that would work as well. For example, the hard coded _table variable could be made a default argument of FormattedSeq.__init__.
As it is, restricting allowed characters to IUPAC ABCDGHKMNRSTVWY is arbitrary, since they are interpreted as the characters themselves and not as degenerate nucleotides.
Therefore, removing this restriction and allowing other letters should not produce unintended behaviour.
We have important use-cases where we want to pass sequences that have extra characters to the .search method on enzymes. Removing this constraint would enable that use-case
It is reassuring to have multiple voices in support when I feel out of my depth on an area of Biopython - so #4941 approved in principle, just a suggestion on the code comment following the dicussion here.
Reacted by Björn Johansson and Manuel Lera-Ramirez
Also @peterjc I am relatively familiar with the Restriction module by now. I don't have time for a full re-write (although I would love it to happen), but if you have some issues about the module feel free to tag me and I can try to help answering questions or fixing bugs if there are any.
Activity
manulera commentedon Feb 18, 2025
cc: @BjornFJohansson @dgruano @hiyama341
closes biopython#4940
peterjc commentedon Feb 18, 2025
This module is without a dedicated maintainer and while there have been a few efforts to rewrite it (avoiding the current structure with a class per enzyme), that is unlikely to happen soon.
I'm unclear how relaxing this check would help, given ambiguous based as not interpreted as such anyway - nor would your RNA extensions be understood.
BjornFJohansson commentedon Feb 19, 2025
@peterjc @manulera We have a use case in Pydna where we expanded the alphabet to deal with uracil as used in USER-cloning for example.
The problem is not so much getting a result for non-standard bases, I think that part is fine the way it is currently.
The problem is that the Bio.Restriction module cast all sequences as FormattedSeq where there is a check that will not allow initiating a FormattedSeq with anything else than what is in the matching dict defined in line 98 in the Bio.Restriction module.
I think this check is not needed. IMHO, removing it would comply with the idea of the responsible user.
That said, I think there are other options that would work as well. For example, the hard coded _table variable could be made a default argument of
FormattedSeq.__init__.manulera commentedon Feb 19, 2025
Hi @peterjc I think the TLDR is:
ABCDGHKMNRSTVWYis arbitrary, since they are interpreted as the characters themselves and not as degenerate nucleotides..searchmethod on enzymes. Removing this constraint would enable that use-casepeterjc commentedon Feb 19, 2025
It is reassuring to have multiple voices in support when I feel out of my depth on an area of Biopython - so #4941 approved in principle, just a suggestion on the code comment following the dicussion here.
BjornFJohansson commentedon Feb 19, 2025
Thank you @peterjc and @manulera. This will remove some unnecessary code in Pydna.
manulera commentedon Feb 19, 2025
Also @peterjc I am relatively familiar with the Restriction module by now. I don't have time for a full re-write (although I would love it to happen), but if you have some issues about the module feel free to tag me and I can try to help answering questions or fixing bugs if there are any.
peterjc commentedon Feb 19, 2025
Thank you @manulera - I'll try to remember that next time something is reported, or if we see renewed interest in a rewrite of the digest code.
peterjc commentedon Feb 19, 2025
Merged - thank you both!
closes biopython#4940