Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BiopythonDeprecationWarning in Bio.pairwise2 #4671

Open
shi-scala opened this issue Mar 18, 2024 · 2 comments
Open

BiopythonDeprecationWarning in Bio.pairwise2 #4671

shi-scala opened this issue Mar 18, 2024 · 2 comments

Comments

@shi-scala
Copy link

Hi,

I've been trying to resolve this deprecation by using the Bio.Align.PairwiseAligner module but have not been able to do so.
We use a python function to determine the alignment score in order to align tuples of sequence and secondary structure:
As an example:
SeqA = [('F', 'E'), ('T', 'E'), ...]
SeqB = [('F', 'E'), ('T', 'E'), ...]

How can I use a custom python function to determine the score between such tuples using Bio.Align.PairwiseAligner?

Thank you

@mdehoon
Copy link
Contributor

mdehoon commented Mar 18, 2024

How can I use a custom python function to determine the score between such tuples using Bio.Align.PairwiseAligner?

If you can write the sequences as

SeqA = ["FE", "TE", ...]
SeqB = ["FE", "TE", ...]

then define your alphabet as

>>> alphabet = ("EE", "FE", "TE", ...)

Create a substitution matrix and fill it

>>> from Bio.Align import substitution_matrices
>>> a = substitution_matrices.Array(alphabet, dims=2)
>>> for key1 in alphabet:
...     for key2 in alphabet:
...        a[key1+key2] = yourfunction(key1, key2)

Create the aligner and set its substitution matrix to the substitution matrix you just created:

>>> from Bio.Align import PairwiseAligner
>>> aligner = PairwiseAligner()
>>> aligner.substitution_matrix = a

and align:

>>> alignments = aligner.align(["EE", "EF", "FF"], ["EE", "FF"])
>>> alignment = next(alignments)
>>> print(alignment)
EE EF FF
|| -- ||
EE -- FF

@shi-scala
Copy link
Author

That's a really cool implementation.
Thank you, I'll give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants