This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Python multiple sequence alignment

I'm trying to find a fast implementation of a multiple sequence alignment algorithm that I can use from Python. The requirements aren't big. I'll only be aligning a handful (like a dozen) 300bp reads which should be very similar to each other (they come from the same molecule).

But I have to do that about 2 million times, so I'd like to avoid using an external command like in BioPython. I think the overhead of writing a file to disk, creating a process, its disk I/O, and reading the results file might be significant when done for only a dozen reads each time?

tl;dr: Is there something like a ClustalW, MUSCLE, etc package for Python, written in C?

alignment

You can use these alignment programs in perl. Think about that if language doesn't matter.

2 answers

That's a lot of MSAs! Are you sure you need true alignments for each of these? You may be able to get what you need without needing to do that. Perhaps mapping would be sufficient?

I'm assuming you want to keep everything in Python as opposed to writing intermediate files, right? I'm not aware of anything that handles such a task internally (but I'd be interested in hearing about it if you do find one). Biostrings, in R, does have the ability to perform alignments, as does DECIPHER and some other libraries. Check this out to start.

If you really need to do that many and you've confirmed that I/O is an issue, perhaps you are better off looking at different hardware alternatives. I've run more complicated tasks that included writing big results and log files hundreds of thousands of times using a distributed cluster without issue.

That's an interesting question about whether it needs to be an MSA. I don't think it can be mapping, since the point is to be reference-free. Basically, I want to build a consensus out of each group of a handful of reads (it's duplex sequencing), independent of a reference.

I guess you may use bwa or bowtie instead.

Log in to answer this question.