2
$\begingroup$

In a project we're doing (in python), we want to create a distance matrix for a phylogenetic tree with multiple, different length sequences. However, what we've seen so far (AlignIO in biopython, etc.) requires the sequences' length to be equal. Is there any pythonic way to get the matrix with sequences of different length? Or any other indirect way that would get us to the same result?

$\endgroup$
  • $\begingroup$ How do you define the distance? (Sorry, cannot post comments -- moderators, please help) $\endgroup$ – user9413 Sep 20 '14 at 17:09
  • $\begingroup$ Without seeing your code it's kind of hard to help. This question is much more suited for Stack Overflow, please ask it over there and tag it [python] and [biopython]. $\endgroup$ – MattDMo Sep 21 '14 at 3:04
  • $\begingroup$ Use a metric that is a function of the sequence but not the sequence itself; something like GC content. Or use end-to-end alignment such as Needleman-Wunsch algorithm $\endgroup$ – WYSIWYG Sep 21 '14 at 6:03
  • 1
    $\begingroup$ I am not a python user but it seems to me AlignIO is (similar to the bioperl counterpart) for reading/writing an already existing alignment (hence the requirement of equal sequence lengths). You could align the sequences with an external tool (like e.g. MAFFT) and then read the alignment in python with the AlignIO interface. $\endgroup$ – ddiez Sep 21 '14 at 12:49
2
$\begingroup$

There are two possibilities:

  1. Do not use the sequences per se but a scalar metric of sequence similarity for distance values
  2. Introduce gaps in the alignment. You can also do an end to end gapped alignment such as the Needleman-Wunsch and use the alignment scores for the distance matrix.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.