[Biopython] pairwise local align subsequence
Markus Piotrowski
Markus.Piotrowski at ruhr-uni-bochum.de
Thu Apr 27 06:41:26 UTC 2017
Am 27.04.2017 um 04:11 schrieb 李团:
> I use pairwise localds to align two sequences, and want to get aligned
> subsequences, but the result returns fully aligned sequences. How can
> I get only aligned subsequences?
>
>
Not directly from pairwise2, but you can extract the relevant data from
the alignment result.
The alignment results is a list of all alignments with the same maximum
score with the following structure:
[(aligned_seq1, aligned_seq2, score, start_of_alignment,
end_of_alignment), (....)]
Unfortunately, also for local alignments, pairwise2 will always return
the full sequences, even if the beginning and/or end has not been used
for the alignment. But you can use start_of_alignment, end_of_alignment
to shorten your sequence like:
>>> aligned_seq1, aligned_seq2, score, start, end = your_alignment[0]
>>> seq1_aligned_part = aligned_seq1[start:end]
>>> seq2_aligned_part = aligned_seq2[start:end]
Markus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20170427/ab75fdaf/attachment.html>
More information about the Biopython
mailing list