本文整理汇总了Python中Bio.Align.Applications.MuscleCommandline类的典型用法代码示例。如果您正苦于以下问题:Python MuscleCommandline类的具体用法?Python MuscleCommandline怎么用?Python MuscleCommandline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MuscleCommandline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_simple_clustal_strict
def test_simple_clustal_strict(self):
"""Simple muscle call using strict Clustal output"""
input_file = "Fasta/f002"
self.assertTrue(os.path.isfile(input_file))
records = list(SeqIO.parse(input_file,"fasta"))
records.sort(key = lambda rec: rec.id)
#Prepare the command...
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("in", input_file)
#Use clustal output (with a CLUSTAL header)
cmdline.set_parameter("clwstrict", True) # Default None treated as False!
self.assertEqual(str(cmdline).rstrip(), _escape_filename(muscle_exe) +
" -in Fasta/f002 -clwstrict")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
child = subprocess.Popen(str(cmdline),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
shell=(sys.platform!="win32"))
#Didn't use -quiet so there should be progress reports on stderr,
align = AlignIO.read(child.stdout, "clustal")
align.sort()
self.assertTrue(child.stderr.read().strip().startswith("MUSCLE"))
self.assertEqual(len(records),len(align))
for old, new in zip(records, align):
self.assertEqual(old.id, new.id)
self.assertEqual(str(new.seq).replace("-",""), str(old.seq))
return_code = child.wait()
self.assertEqual(return_code, 0)
child.stdout.close()
child.stderr.close()
del child
示例2: muscleProcess
def muscleProcess (threadID, filebase, outbase, treebase):
fasta = filebase % threadID
output = outbase % threadID
treeFile = treebase % threadID
print( "Building NJ tree from %s" % fasta )
run_muscle = MuscleCommandline( cmd=muscle, input=fasta, out=output )
run_muscle.tree1 = treeFile
run_muscle.cluster1 = "neighborjoining"
run_muscle.maxiters = 1
thisVarHidesTheOutput = run_muscle()
示例3: quickAlign
def quickAlign( refseq, testseq, maxiters=None, diags=None, gapopen=None ):
#sanity check
refseq = re.sub( "-", "", str(refseq) )
testseq = re.sub( "-", "", str(testseq) )
handle = StringIO()
handle.write( ">ref\n%s\n>test\n%s\n"%(refseq,testseq) )
data = handle.getvalue()
muscle_cline = MuscleCommandline(cmd=muscle, quiet=True)
if maxiters is not None: muscle_cline.maxiters = maxiters
if diags is not None: muscle_cline.diags = diag
if gapopen is not None: muscle_cline.gapopen = gapopen
stdout, stderr = muscle_cline(stdin=data)
aligned = dict()
for p in SeqIO.parse(StringIO(stdout), "fasta"):
aligned[ p.id ] = str(p.seq)
return aligned
示例4: allign_fasta
def allign_fasta(filename = "filename",
extension_in = ".fasta",
extension_out = ".aln"):
"""
This function requires MUSCLE from http://www.drive5.com/muscle. The
main objective - read FASTA file with multiple records, find similar
sequences, save alingment of similar sequences to "filename.aln".
@param filename: FASTA file, which should be alligned.
@param extension_in: FASTA file type end, could be .fa or similar.
@param extension_out: Alignment file type: ".aln".
"""
from Bio.Align.Applications import MuscleCommandline
if filename == None:
return False;
if not os.path.exists(filename + extension_in):
return False;
cline = MuscleCommandline(input=filename + extension_in, out=filename + extension_out);
os.system(cline.__str__());
return True;
示例5: test_Muscle_profile_simple
def test_Muscle_profile_simple(self):
"""Simple round-trip through app doing a profile alignment"""
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("out", self.outfile3)
cmdline.set_parameter("profile", True)
cmdline.set_parameter("in1", self.infile2)
cmdline.set_parameter("in2", self.infile3)
self.assertEqual(str(cmdline), _escape_filename(muscle_exe) +
" -out Fasta/temp_align_out3.fa" +
" -profile -in1 Fasta/fa01 -in2 Fasta/f001")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
output, error = cmdline()
self.assertEqual(output, "")
self.assertTrue("ERROR" not in error)
self.assertTrue(error.strip().startswith("MUSCLE"), output)
示例6: test_Muscle_profile_simple
def test_Muscle_profile_simple(self):
"""Simple round-trip through app doing a profile alignment."""
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("out", self.outfile3)
cmdline.set_parameter("profile", True)
cmdline.set_parameter("in1", self.infile2)
cmdline.set_parameter("in2", self.infile3)
self.assertEqual(str(cmdline), muscle_exe + \
" -out Fasta/temp_align_out3.fa" + \
" -profile -in1 Fasta/fa01 -in2 Fasta/f001")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
stdin, stdout, stderr = generic_run(cmdline)
self.assertEqual(stdin.return_code, 0)
self.assertEqual(stdout.read(), "")
self.assert_("ERROR" not in stderr.read())
self.assertEqual(str(stdin._cl), str(cmdline))
示例7: test_Muscle_with_options
def test_Muscle_with_options(self):
"""Round-trip through app with a switch and valued option"""
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("input", self.infile1) # "input" is alias for "in"
cmdline.set_parameter("out", self.outfile2)
#Use property:
cmdline.objscore = "sp"
cmdline.noanchors = True
self.assertEqual(str(cmdline), _escape_filename(muscle_exe) +
" -in Fasta/f002" +
" -out Fasta/temp_align_out2.fa" +
" -objscore sp -noanchors")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
output, error = cmdline()
self.assertEqual(output, "")
self.assertTrue("ERROR" not in error)
self.assertTrue(error.strip().startswith("MUSCLE"), output)
示例8: test_Muscle_with_options
def test_Muscle_with_options(self):
"""Round-trip through app with a switch and valued option."""
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("input", self.infile1) #"input" is alias for "in"
cmdline.set_parameter("out", self.outfile2)
#Use property:
cmdline.objscore = "sp"
cmdline.noanchors = True
self.assertEqual(str(cmdline), muscle_exe +\
" -in Fasta/f002" + \
" -out Fasta/temp_align_out2.fa" + \
" -objscore sp -noanchors")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
stdin, stdout, stderr = generic_run(cmdline)
self.assertEqual(stdin.return_code, 0)
self.assertEqual(stdout.read(), "")
self.assert_("ERROR" not in stderr.read())
self.assertEqual(str(stdin._cl), str(cmdline))
示例9: test_Muscle_profile_simple
def test_Muscle_profile_simple(self):
"""Simple round-trip through app doing a profile alignment"""
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("out", self.outfile3)
cmdline.set_parameter("profile", True)
cmdline.set_parameter("in1", self.infile2)
cmdline.set_parameter("in2", self.infile3)
self.assertEqual(str(cmdline), muscle_exe + \
" -out Fasta/temp_align_out3.fa" + \
" -profile -in1 Fasta/fa01 -in2 Fasta/f001")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
child = subprocess.Popen(str(cmdline),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=(sys.platform!="win32"))
output, error = child.communicate()
self.assertEqual(child.returncode, 0)
self.assertEqual(output, "")
self.assert_("ERROR" not in error)
del child
示例10: test_Muscle_with_options
def test_Muscle_with_options(self):
"""Round-trip through app with a switch and valued option"""
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("input", self.infile1) #"input" is alias for "in"
cmdline.set_parameter("out", self.outfile2)
#Use property:
cmdline.objscore = "sp"
cmdline.noanchors = True
self.assertEqual(str(cmdline), muscle_exe +\
" -in Fasta/f002" + \
" -out Fasta/temp_align_out2.fa" + \
" -objscore sp -noanchors")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
child = subprocess.Popen(str(cmdline),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=(sys.platform!="win32"))
output, error = child.communicate()
self.assertEqual(child.returncode, 0)
self.assertEqual(output, "")
self.assert_("ERROR" not in error)
del child
示例11: test_simple_clustal_strict
def test_simple_clustal_strict(self):
"""Simple muscle call using strict Clustal output."""
input_file = "Fasta/f002"
self.assert_(os.path.isfile(input_file))
records = list(SeqIO.parse(open(input_file),"fasta"))
#Prepare the command...
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("in", input_file)
#Preserve input record order (makes checking output easier)
cmdline.set_parameter("stable", True) #Default None treated as False!
#Use clustal output (with a CLUSTAL header)
cmdline.set_parameter("clwstrict", True) #Default None treated as False!
self.assertEqual(str(cmdline).rstrip(), muscle_exe + \
" -in Fasta/f002 -clwstrict -stable")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, out_handle, err_handle = generic_run(cmdline)
align = AlignIO.read(out_handle, "clustal")
self.assertEqual(len(records),len(align))
for old, new in zip(records, align):
self.assertEqual(old.id, new.id)
self.assertEqual(str(new.seq).replace("-",""), str(old.seq))
#Didn't use -quiet so there should be progress reports on stderr,
self.assert_(err_handle.read().strip().startswith("MUSCLE"))
示例12: test_long
def test_long(self) :
"""Simple muscle call using long file."""
#Create a large input file by converting some of another example file
temp_large_fasta_file = "temp_cw_prot.fasta"
handle = open(temp_large_fasta_file, "w")
records = list(SeqIO.parse(open("NBRF/Cw_prot.pir", "rU"), "pir"))[:40]
SeqIO.write(records, handle, "fasta")
handle.close()
#Prepare the command...
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("in", temp_large_fasta_file)
#Preserve input record order
cmdline.set_parameter("stable", True) #Default None treated as False!
#Use fast options
cmdline.set_parameter("maxiters", 1)
cmdline.set_parameter("diags", True) #Default None treated as False!
#Use clustal output
cmdline.set_parameter("clwstrict", True) #Default None treated as False!
#Shoudn't need this, but just to make sure it is accepted
cmdline.set_parameter("maxhours", 0.1)
#No progress reports to stderr
cmdline.set_parameter("quiet", True) #Default None treated as False!
#TODO - Fix the trailing space!
self.assertEqual(str(cmdline).rstrip(), muscle_exe + \
" -in temp_cw_prot.fasta -diags -maxhours 0.1" + \
" -maxiters 1 -clwstrict -stable -quiet")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, out_handle, err_handle = generic_run(cmdline)
align = AlignIO.read(out_handle, "clustal")
self.assertEqual(len(records), len(align))
for old, new in zip(records, align) :
self.assertEqual(old.id, new.id)
self.assertEqual(str(new.seq).replace("-",""), str(old.seq))
os.remove(temp_large_fasta_file)
#See if quiet worked:
self.assertEqual("", err_handle.read().strip())
示例13: test_long
def test_long(self):
"""Simple muscle call using long file"""
#Create a large input file by converting some of another example file
temp_large_fasta_file = "temp_cw_prot.fasta"
records = list(SeqIO.parse("NBRF/Cw_prot.pir", "pir"))[:40]
SeqIO.write(records, temp_large_fasta_file, "fasta")
#Prepare the command...
cmdline = MuscleCommandline(muscle_exe)
cmdline.set_parameter("in", temp_large_fasta_file)
#Use fast options
cmdline.set_parameter("maxiters", 1)
cmdline.set_parameter("diags", True) # Default None treated as False!
#Use clustal output
cmdline.set_parameter("clwstrict", True) # Default None treated as False!
#Shoudn't need this, but just to make sure it is accepted
cmdline.set_parameter("maxhours", 0.1)
#No progress reports to stderr
cmdline.set_parameter("quiet", True) # Default None treated as False!
self.assertEqual(str(cmdline).rstrip(), _escape_filename(muscle_exe) +
" -in temp_cw_prot.fasta -diags -maxhours 0.1" +
" -maxiters 1 -clwstrict -quiet")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
child = subprocess.Popen(str(cmdline),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
shell=(sys.platform!="win32"))
align = AlignIO.read(child.stdout, "clustal")
align.sort()
records.sort(key = lambda rec: rec.id)
self.assertEqual(len(records), len(align))
for old, new in zip(records, align):
self.assertEqual(old.id, new.id)
self.assertEqual(str(new.seq).replace("-",""), str(old.seq))
#See if quiet worked:
self.assertEqual("", child.stderr.read().strip())
return_code = child.wait()
self.assertEqual(return_code, 0)
child.stdout.close()
child.stderr.close()
del child
os.remove(temp_large_fasta_file)
示例14: GetExec
def GetExec(self, optList, frame):
# Respond to the "muscle" command.
self.frame = frame
plugin_exe = r"C:/Program Files (x86)/py27/Lib/site-packages/Muscle.exe"
self.outfile=r".\plugins\muscle.txt"
self.outtype="fasta"
cline = MuscleCommandline(plugin_exe,out=self.outfile)
if '1ProfileCheck' in self.frame.paramBoxes:
if self.frame.paramBoxes['1ProfileCheck'].GetValue():
cline.profile = True
cline.in1 = r"C:\Users\francis\Documents\Monguis\BioGui\plugins\my_seq.fasta"
cline.in2 = r"C:\Users\francis\Documents\Monguis\BioGui\plugins\my_seq.fasta"
else:
cline.input = r"C:\Users\francis\Documents\Monguis\BioGui\plugins\my_seq.fasta"
if '1DiagCheck' in self.frame.paramBoxes:
if self.frame.paramBoxes['1DiagCheck'].GetValue():
cline.diags=True
if "DiagLenSpin" in self.frame.paramBoxes:
cline.diaglength=int(self.frame.paramBoxes["DiagLenSpin"])
if "DiagMargSpin" in self.frame.paramBoxes:
cline.diaglength=int(self.frame.paramBoxes["DiagMargSpin"])
if "DiagBreakSpin" in self.frame.paramBoxes:
cline.diaglength=int(self.frame.paramBoxes["DiagBreakSpin"])
elif "GapPenSpin" in self.frame.paramBoxes:
cline.gapopen=float(self.frame.paramBoxes["GapPenSpin"].GetValue())
else:
cline.input=r"C:\Users\francis\Documents\Monguis\BioGui\plugins\my_seq.fasta"
if self.frame.abet=="AA":
cline.seqtype="protein"
elif self.frame.abet=="DNA" or self.frame.abet=="RNA":
cline.seqtype="nucleo"
else:
cline.seqtype="auto"
if self.frame.options:
cline.objscore=str(self.boxList[9].GetValue())
cline.weight1=str(self.boxList[13].GetValue())
cline.weight2=str(self.boxList[15].GetValue())
cline.anchorspacing=int(self.boxList[17].GetValue())
cline.center=float(self.boxList[19].GetValue())
cline.hydro=int(self.boxList[21].GetValue())
cline.hydrofactor=float(self.boxList[23].GetValue())
cline.maxhours=float(self.boxList[25].GetValue())
cline.maxiters=int(self.boxList[27].GetValue())
cline.maxtrees=int(self.boxList[29].GetValue())
cline.minbestcolscore=float(self.boxList[31].GetValue())
cline.minsmoothscore=float(self.boxList[33].GetValue())
cline.smoothscoreceil=float(self.boxList[35].GetValue())
cline.smoothwindow=int(self.boxList[37].GetValue())
cline.sueff=float(self.boxList[39].GetValue())
return str(cline)
示例15: run
def run(self):
run_muscle = MuscleCommandline( input=self.fasta, out=self.output )
run_muscle.tree1 = self.tree
run_muscle.cluster1 = "neighborjoining"
run_muscle.maxiters = 1
thisVarHidesTheOutput = run_muscle()