I have 200 or so fasta files that I need to align in a program called muscle, it
ID: 3865604 • Letter: I
Question
I have 200 or so fasta files that I need to align in a program called muscle, it needs to out put them in to a new directroy called outMuscle. I keep getting an infintie loop and no real work done. The muscle commands are muscle -in <file> -out <file> simple as that it is getting it to iterate and putting it in a new directory in PYTHON
import os
#this needs to be in the same folder as the individual fastas
#create a foldear called outMuscled but dont run this one in that folder
os.system("cd outMuscled")
DIR = os.getcwd()
os.system("cd ..")
i = 1
while i < 139:
name = "clust" + str(i) + ".fasta"
name2 = "Cluster" + str(i) + ".fasta"
output = os.path.join(DIR, name2)
os.system("muscle -in " + name + " -out " + name2)
Explanation / Answer
I have analyzed your code and can see you are not incrementing the variable i because of which it is going into infinite loop as the variable 'i' is always 1 and will never reach 139 to break the loop. Do this after os.system statement "i += 1", your code should work fine. Modified code for your reference.
Please check and let me know if you face any issues. I will revert back within 24 hours.
Unix Terminal> cat muscle.py
import os
#this needs to be in the same folder as the individual fastas
#create a foldear called outMuscled but dont run this one in that folder
os.system("cd outMuscled")
DIR = os.getcwd()
os.system("cd ..")
i = 1
while i < 139:
name = "clust" + str(i) + ".fasta"
name2 = "Cluster" + str(i) + ".fasta"
output = os.path.join(DIR, name2)
os.system("muscle -in " + name + " -out " + name2)
i += 1
Unix Terminal>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.