To generate aligned protein sequence truncate to the same length, I use blastp in biopython for MSA. I have multiple queries and one subject sequence. However, the alignment never returns the same length.

How can I align all sequences altogether, thus resulting in a set of sequences of the same length?

  • $\begingroup$ Please consider accepting/upvoting the answers below. $\endgroup$
    – M__
    Commented Sep 12, 2023 at 23:20

2 Answers 2


@Matteo Ferla wrote in the comments,

It sounds like you'd want a MSA of the whole set and not a set of pairwise ones. If global MSA is what you actually want, try ebi.ac.uk/Tools/msa/muscle. Then to trim the ends before phylogeny there are dozens of tools.

The reason is because Blast aligns locally, i.e. a window, while a global alignment is the whole entirety of the sequence


BLAST isn't appropriate for multiple sequence alignment. BLAST generates pairwise alignments. Furthermore, the aligning regions shown in a BLAST report only include subsets of the hit sequences.

To create multiple sequence alignment of hits you want to:

  • run blast
  • extract the hit sequences
  • perform multiple-sequence-alignment (e.g., using MAFFT)

Extracting hit sequences can be done using the command-line. Check the docs for blastdbcmd.

If you prefer a point-and-click interface, you can also do this using my lab's SequenceServer BLAST software by simply selecting the hits that you want to retain, and in the Download section, clicking "FASTA of selected hits". Or if you want all of them, click "FASTA of all hits".

Download hits from BLAST report

  • 2
    $\begingroup$ Please add a statement stating that your lab created this software that you're posting about on multiple threads. $\endgroup$
    – Ram RS
    Commented Dec 20, 2021 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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