本文整理汇总了Python中Bio.Application.generic_run方法的典型用法代码示例。如果您正苦于以下问题:Python Application.generic_run方法的具体用法?Python Application.generic_run怎么用?Python Application.generic_run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.Application
的用法示例。
在下文中一共展示了Application.generic_run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_Prank_simple_with_NEXUS_output
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Prank_simple_with_NEXUS_output(self):
"""Simple round-trip through app with infile, output in NEXUS
output.?.??? files written to cwd - no way to redirect
"""
records = list(SeqIO.parse(open(self.infile1),"fasta"))
#Try using keyword argument,
cmdline = PrankCommandline(prank_exe, d=self.infile1, noxml=True)
#Try using a property,
cmdline.d = self.infile1
cmdline.f = 17 # NEXUS format
cmdline.set_parameter("notree", True)
self.assertEqual(str(cmdline), prank_exe + \
" -d=Fasta/fa01 -f=17 -noxml -notree")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(result.return_code, 0)
self.assert_("Total time" in stdout.read())
self.assertEqual(stderr.read(), "")
self.assertEqual(str(result._cl), str(cmdline))
out_handle = open("output.2.nex", "r")
align = AlignIO.read(out_handle, "nexus")
out_handle.close()
for old, new in zip(records, align) :
#Prank automatically reduces name to 9 chars
self.assertEqual(old.id[:9], new.id)
#infile1 has alignment gaps in it
self.assertEqual(str(new.seq).replace("-",""),
str(old.seq).replace("-",""))
示例2: conversion
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def conversion(self, prank_number, prank_ext, format) :
"""Get PRANK to do a conversion, and check it with SeqIO."""
filename = "%s.%s" % (self.output, prank_ext)
if os.path.isfile(filename) :
os.remove(filename)
cmdline = PrankCommandline(prank_exe, d=self.input,
convert=True, f=prank_number,
o='"%s"' % self.output)
self.assertEqual(str(cmdline), prank_exe \
+ ' -d=%s' % self.input \
+ ' -o="%s"' % self.output \
+ ' -f=%i' % prank_number \
+ ' -convert')
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(result.return_code, 0)
message = stdout.read().strip()
self.assert_(("PRANK: converting '%s' to '%s'" % (self.input, filename)) \
in message, message)
self.assertEqual(stderr.read(), "")
self.assertEqual(str(result._cl), str(cmdline))
self.assert_(os.path.isfile(filename))
old = AlignIO.read(open(self.input), "fasta")
#Hack...
if format=="phylip" :
for record in old :
record.id = record.id[:10]
new = AlignIO.read(open(filename), format)
assert len(old) == len(new)
for old_r, new_r in zip(old, new) :
self.assertEqual(old_r.id, new_r.id)
self.assertEqual(str(old_r.seq), str(new_r.seq))
os.remove(filename)
示例3: test_Mafft_with_complex_command_line
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Mafft_with_complex_command_line(self):
"""Round-trip with complex command line."""
cmdline = MafftCommandline(mafft_exe)
cmdline.set_parameter("input", self.infile1)
cmdline.set_parameter("--localpair", True)
cmdline.set_parameter("--weighti", 4.2)
cmdline.set_parameter("retree", 5)
cmdline.set_parameter("maxiterate", 200)
cmdline.set_parameter("--nofft", True)
cmdline.set_parameter("op", 2.04)
cmdline.set_parameter("--ep", 0.51)
cmdline.set_parameter("--lop", 0.233)
cmdline.set_parameter("lep", 0.2)
cmdline.set_parameter("--reorder", True)
cmdline.set_parameter("--treeout", True)
cmdline.set_parameter("nuc", True)
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(result.return_code, 0)
self.assert_(stdout.read().startswith(">gi|1348912|gb|G26680|G26680"))
self.assert_("$#=0" not in stderr.read())
self.assertEqual(str(result._cl), mafft_exe \
+ " --localpair --weighti 4.2 --retree 5 " \
+ "--maxiterate 200 --nofft --op 2.04 --ep 0.51" \
+ " --lop 0.233 --lep 0.2 --reorder --treeout" \
+ " --nuc Fasta/f002")
示例4: test_Mafft_with_Clustalw_output
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Mafft_with_Clustalw_output(self):
"""Simple round-trip through app with clustal output"""
cmdline = MafftCommandline(mafft_exe)
#Use some properties:
cmdline.input = self.infile1
cmdline.clustalout = True
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
stdin, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(stdin.return_code, 0)
self.assert_(stdout.read().startswith("CLUSTAL format alignment by MAFFT"))
self.assert_("$#=0" not in stderr.read())
self.assertEqual(str(stdin._cl), mafft_exe \
+ " --clustalout Fasta/f002")
示例5: test_Prank_simple
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Prank_simple(self):
"""Simple round-trip through app with infile.
output.?.??? files written to cwd - no way to redirect
"""
cmdline = PrankCommandline(prank_exe)
cmdline.set_parameter("d", self.infile1)
self.assertEqual(str(cmdline), prank_exe + " -d=Fasta/fa01")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(result.return_code, 0)
self.assert_("Total time" in stdout.read())
self.assertEqual(stderr.read(), "")
self.assertEqual(str(result._cl), str(cmdline))
示例6: test_Dialign_simple
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Dialign_simple(self):
"""Simple round-trip through app with infile.
"""
#Test using keyword arguments:
cmdline = DialignCommandline(dialign_exe, input=self.infile1)
self.assertEqual(str(cmdline), dialign_exe + " Fasta/f002")
result, stdout, stderr = Application.generic_run(cmdline)
#If there is a problem, the output can be very helpful to see,
#so check this before looking at the return code:
self.assertEqual(stderr.read(), "")
self.assertEqual(stdout.read(), "")
self.assertEqual(result.return_code, 0)
self.assert_(os.path.exists(self.outfile1))
self.assertEqual(str(result._cl), str(cmdline))
示例7: test_Mafft_with_options
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Mafft_with_options(self):
"""Simple round-trip through app with infile and options.
Result passed to stdout.
"""
cmdline = MafftCommandline(mafft_exe)
cmdline.set_parameter("input", self.infile1)
cmdline.set_parameter("maxiterate", 100)
cmdline.set_parameter("--localpair", True)
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(result.return_code, 0)
self.assert_(stdout.read().startswith(">gi|1348912|gb|G26680|G26680"))
self.assert_("$#=0" not in stderr.read())
self.assertEqual(str(result._cl), mafft_exe \
+ " --localpair --maxiterate 100 Fasta/f002")
示例8: test_Mafft_simple
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Mafft_simple(self):
"""Simple round-trip through app with infile.
Result passed to stdout.
"""
#Use a keyword argument at init,
cmdline = MafftCommandline(mafft_exe, input=self.infile1)
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, stdout, stderr = Application.generic_run(cmdline)
stderr_string = stderr.read()
self.assertEqual(result.return_code, 0)
self.assert_(stdout.read().startswith(">gi|1348912|gb|G26680|G26680"))
self.assert_("STEP 2 / 2 d" in stderr_string)
self.assert_("$#=0" not in stderr_string)
self.assertEqual(str(result._cl), mafft_exe \
+ " Fasta/f002")
示例9: test_Dialign_simple_with_options
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Dialign_simple_with_options(self):
"""Simple round-trip through app with infile and options
"""
cmdline = DialignCommandline(dialign_exe)
cmdline.set_parameter("input", self.infile1)
cmdline.set_parameter("-max_link", True)
cmdline.set_parameter("stars", 4)
self.assertEqual(str(cmdline), dialign_exe + \
" -max_link -stars 4 Fasta/f002")
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(stderr.read(), "")
self.assertEqual(stdout.read(), "")
self.assertEqual(result.return_code, 0)
self.assert_(os.path.exists(self.outfile1))
self.assertEqual(str(result._cl), str(cmdline))
示例10: test_Dialign_simple_with_MSF_output
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Dialign_simple_with_MSF_output(self):
"""Simple round-trip through app with infile, output MSF
"""
cmdline = DialignCommandline(dialign_exe)
#Test with properties
cmdline.input = self.infile1
cmdline.msf = True
self.assertEqual(str(cmdline), dialign_exe + " -msf Fasta/f002")
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(stdout.read(), "")
self.assertEqual(stderr.read(), "")
self.assertEqual(result.return_code, 0)
self.assert_(os.path.exists(self.outfile1))
self.assert_(os.path.exists(self.outfile2))
self.assertEqual(str(result._cl), str(cmdline))
示例11: test_TCoffee_1
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_TCoffee_1(self):
"""Round-trip through app and read clustal alignment from file
"""
cmdline = TCoffeeCommandline(t_coffee_exe, infile=self.infile1)
self.assertEqual(str(cmdline), t_coffee_exe + " -infile Fasta/fa01")
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEquals(result.return_code, 0)
self.assertEquals(str(result._cl), t_coffee_exe + " -infile Fasta/fa01")
self.assert_(stderr.read().strip().startswith("PROGRAM: T-COFFEE"))
align = AlignIO.read(open(self.outfile1), "clustal")
records = list(SeqIO.parse(open(self.infile1),"fasta"))
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).replace("-",""))
示例12: test_Mafft_with_Clustalw_output
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Mafft_with_Clustalw_output(self):
"""Simple round-trip through app with clustal output"""
cmdline = MafftCommandline(mafft_exe)
#Use some properties:
cmdline.input = self.infile1
cmdline.clustalout = True
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(result.return_code, 0)
output = stdout.read()
#e.g. "CLUSTAL format alignment by MAFFT ..."
#or "CLUSTAL (-like) formatted alignment by MAFFT FFT-NS-2 (v6.240)"
self.assert_(output.startswith("CLUSTAL"), output)
self.assert_("$#=0" not in stderr.read())
self.assertEqual(str(result._cl), mafft_exe \
+ " --clustalout Fasta/f002")
示例13: test_Probcons_alignment_fasta
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Probcons_alignment_fasta(self):
"""Round-trip through app and read fasta alignment from stdout
"""
cmdline = ProbconsCommandline(probcons_exe, input=self.infile1)
self.assertEqual(str(cmdline), probcons_exe + " Fasta/fa01")
self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
stdin, stdout, stderr = Application.generic_run(cmdline)
self.assertEquals(stdin.return_code, 0)
self.assertEqual(str(cmdline), str(stdin._cl))
self.assert_(stderr.read().startswith("\nPROBCONS"))
align = AlignIO.read(StringIO(stdout.read()), "fasta")
records = list(SeqIO.parse(open(self.infile1),"fasta"))
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).replace("-",""))
示例14: test_Probcons_complex_commandline
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_Probcons_complex_commandline(self):
"""Round-trip through app with complex command line and output file
"""
cmdline = ProbconsCommandline(probcons_exe, pre=1)
cmdline.set_parameter("input", "Fasta/fa01")
cmdline.consistency = 4
cmdline.set_parameter("--iterative-refinement", 222)
cmdline.set_parameter("a", True)
cmdline.annot = self.annotation_outfile
self.assertEqual(str(cmdline), probcons_exe +
" -c 4 -ir 222 -pre 1 -annot Fasta/probcons_annot.out "
"-a Fasta/fa01")
stdin, stdout, stderr = Application.generic_run(cmdline)
self.assertEqual(str(cmdline), str(stdin._cl))
self.assertEquals(stdin.return_code, 0)
self.assert_(stderr.read().startswith("\nPROBCONS"))
self.assert_(stdout.read().startswith(">AK1H_ECOLI/1-378"))
示例15: test_TCoffee_2
# 需要导入模块: from Bio import Application [as 别名]
# 或者: from Bio.Application import generic_run [as 别名]
def test_TCoffee_2(self):
"""Round-trip through app and read pir alignment from file
"""
cmdline = TCoffeeCommandline(t_coffee_exe, quiet=True)
cmdline.infile = self.infile1
cmdline.outfile = self.outfile3
cmdline.output = "pir_aln"
self.assertEqual(str(cmdline), t_coffee_exe + " -output pir_aln "
"-infile Fasta/fa01 -outfile Fasta/tc_out.pir -quiet")
result, stdout, stderr = Application.generic_run(cmdline)
self.assertEquals(result.return_code, 0)
self.assertEquals(stderr.read(), "")
align = AlignIO.read(open(self.outfile3), "pir")
records = list(SeqIO.parse(open(self.infile1),"fasta"))
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).replace("-",""))