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

[Help Request] Migrating from pairwise2 -> PairwiseAligner #4711

Open
jday1 opened this issue Apr 26, 2024 · 0 comments
Open

[Help Request] Migrating from pairwise2 -> PairwiseAligner #4711

jday1 opened this issue Apr 26, 2024 · 0 comments
Assignees

Comments

@jday1
Copy link

jday1 commented Apr 26, 2024

Setup

I am reporting a problem with Biopython version, Python version, and operating
system as follows:

import sys; print(sys.version)
import platform; print(platform.python_implementation()); print(platform.platform())
import Bio; print(Bio.__version__)

1.82

I am trying to migrate from align.localds to PairwiseAligner and require assistance as I am not sure how to replicate the behaviour I need. I have attached a code snippet with a test illustrating the localds's output. Could someone please show me how to replicate this with the PairwiseAligner.

In particular, how do I get an output which includes the - character and what is the equivalent of penalize_end_gaps.

from Bio import pairwise2
from Bio.Align import substitution_matrices, PairwiseAligner


SUBSTITUTION_MATRIX = substitution_matrices.load("BLOSUM62")


def using_pairwise_aligner(seq1, seq2, matrix, gap_open, gap_extend, penalize_end_gaps) -> tuple[str, str]:
    aligner = PairwiseAligner()
    
    # How do I replicate the result?
    pass


def test_align_format_sequences():
    
    input_seq1, input_seq2 = "GCVLDGNYQIW", "GCLIQGRFDILF"

    expected_seq1, expected_seq2 = "GCVLDGNYQIW-", "GCLIQGRFDILF"
    
    # Old method
    alignment = pairwise2.align.localds(input_seq1, input_seq2, SUBSTITUTION_MATRIX, -10.0, -0.5, penalize_end_gaps=(False, False))[0]
    actual_seq1, actual_seq2 = alignment.seqA, alignment.seqB

    assert (actual_seq1, actual_seq2) == (expected_seq1, expected_seq2)


    # New method
    actual_seq1, actual_seq2 = using_pairwise_aligner(input_seq1, input_seq2, SUBSTITUTION_MATRIX, -10.0, -0.5, penalize_end_gaps=(False, False)) 
    assert (actual_seq1, actual_seq2) == (expected_seq1, expected_seq2)
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