2

I want to do multiple sequence alignment by using MUSCLE algorithm .

from Bio.Align.Applications import MuscleCommandline
muscle_exe = r"C:\Program file\muscle3.8.31_i86win32.exe"
in_file = r"non_aligned.fasta"
out_file = r"aligned.fasta"
muscle_cline = MuscleCommandline(muscle_exe, input=in_file, out=out_file)
print(muscle_cline)
stdout, stderr = muscle_cline()

But, I want to use it in a different way as the following:

nsequences = len(sequences)

for i in range(nsequences):
  for j in range(i+1, nsequences):
    aln = alignment_function(sequences[i], sequences[j])
   print (sequences[i], sequences[j], aln)

where sequences are the sequences contained in the file non_aligned.fasta, and nsequences is the number of sequences. So, I want to align two sequences by MUSCLE , each time like I mentioned in the above code and print every two sequences. alignment_function(sequences[i], sequences[j]) is a function, which does the alignment of two sequences by MUSCLE. How can I do this ? This should then output something like:

seq1 seq2 aln12
seq1 seq3 aln13
seq2 seq3 aln23
Sharif Mamun
  • 3,508
  • 5
  • 32
  • 51
user3216969
  • 169
  • 1
  • 1
  • 12
  • help me!!!!!!!!!!!!! – user3216969 Jan 09 '15 at 20:48
  • 1
    It's not clear to me what your problem actually is. You are simply trying to get a group of pairwise sequences. Running through nested loops should do this (although it's not necessary to count through them, you can pull them directly with "for sequence in sequences). Is you problem trying to get muscle to align sequences in memory rather than from file? – iayork Jan 10 '15 at 19:16
  • I want to get the all the pairwise alignment – user3216969 Jan 10 '15 at 19:21
  • If you're trying to get in-memory sequences to be handled by MUSCLE, use the StringIO module. You may find this answer useful: http://stackoverflow.com/questions/19641101/muscle-alignment-in-python – iayork Jan 10 '15 at 20:40
  • no, I'm trying to to get all pairwise alignment from MUSCLE – user3216969 Jan 10 '15 at 21:09

1 Answers1

0

At first try just one alignment from command line like below:

import os
os.system("muscle -profile -in1 seq1.aln -in2 seq2.aln -out combinedAlignment.fasta -maxmb 15000")

Where, seq1.aln is your first sequence, seq2,aln is your second sequence and the output is combinedAlignment.fasta, maxmb is optional but always better to use.

Sharif Mamun
  • 3,508
  • 5
  • 32
  • 51