Hey guys,
i'm trying to use the Biopython PairwiseAligner as such:
from Bio import Align
aligner = Align.PairwiseAligner()
my_target = "ACTTGATCTTTCGT"
my_query = "CTTGATCT"
aligner.gap_score = -1
aligner.match = 1
aligner.mismatch = -1
aligner.query_end_gap_score = 0
alignments = aligner.align(my_target, my_query)
alignment = alignments[0]
print(alignment.aligned)
This should give me a representation of where the alignments occured relative to the other sequence:
Use the aligned property to find the start and end indices of subsequences in the target and query sequence that were aligned to each other. Generally, if the alignment between target (t) and query (q) consists of N chunks, you get two tuples of length N: (((t_start1, t_end1), (t_start2, t_end2), ..., (t_startN, t_endN)), ((q_start1, q_end1), (q_start2, q_end2), ..., (q_startN, q_endN))) In the current example, ‘alignment.aligned‘ returns two tuples of length 2:
>>> alignment.aligned (((0, 2), (4, 5)), ((0, 2), (2, 3)))
However I'm getting this error:
AttributeError: 'PairwiseAlignment' object has no attribute 'aligned'
Can someone please explain where I'm going wrong?
To the best of my assessment, this may just be some deprecated functionality that has been missed in the docs.
Could you post what python and biopython versions you're using, and I'll try to draw this thread to the attention of the biopython devs.
Not deprecated(?):
From the cookbook (16 July 2019) applied on your code:
https://biopython.org/DIST/docs/tutorial/Tutorial.html
That doesn't appear to address the issue of the
.aligned
attribute being missing?I can emulate the problem on Biopython 1.73, and the online cookbook does indeed seem to suggest this functionality still exists, in section 6.5.2.7 Alignment object:
https://biopython.org/DIST/docs/tutorial/Tutorial.html#htoc88
Update:
Biopython devs on twitter asked for it to be placed as a github issue. You can follow its progress here: https://github.com/biopython/biopython/issues/2294
EDIT, resolved and closed.