<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">Am 27.04.2017 um 04:11 schrieb 李团:<br>
</div>
<blockquote
cite="mid:CABSkg=2dyDZ4YV=1metm9+TnyoZxFkHqq1eLGF2YdhO2kbA_Jg@mail.gmail.com"
type="cite">
<div dir="auto">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? </div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
</blockquote>
<br>
Not directly from pairwise2, but you can extract the relevant data
from the alignment result.<br>
<br>
The alignment results is a list of all alignments with the same
maximum score with the following structure:<br>
<br>
[(aligned_seq1, aligned_seq2, score, start_of_alignment,
end_of_alignment), (....)]<br>
<br>
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:<br>
<br>
>>> aligned_seq1, aligned_seq2, score, start, end =
your_alignment[0]<br>
>>> seq1_aligned_part = aligned_seq1[start:end]<br>
>>> seq2_aligned_part = aligned_seq2[start:end]<br>
<br>
Markus<br>
</body>
</html>