예제 #1
0
 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)
예제 #2
0
 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("-",""))
예제 #3
0
 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)
예제 #4
0
 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")
예제 #5
0
 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("-", ""))
예제 #6
0
 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")
예제 #7
0
 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))
예제 #8
0
 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))
예제 #9
0
 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))
예제 #10
0
 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))
예제 #11
0
 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))
예제 #12
0
 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))
예제 #13
0
 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("-",""))
예제 #14
0
 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))
예제 #15
0
 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))
예제 #16
0
 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("-",""))
예제 #17
0
 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")
예제 #18
0
 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")
예제 #19
0
 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")
예제 #20
0
 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("-",""))
예제 #21
0
 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"))
예제 #22
0
 def test_Dialign_complex_command_line(self):
     """Round-trip through app with complex command line."""
     cmdline = DialignCommandline(dialign_exe)
     cmdline.set_parameter("input", self.infile1)
     cmdline.set_parameter("-nt", True)
     cmdline.set_parameter("-thr", 4)
     cmdline.set_parameter("stars", 9)
     cmdline.set_parameter("-ow", True)
     cmdline.set_parameter("mask", True)
     cmdline.set_parameter("-cs", True)
     self.assertEqual(str(cmdline), dialign_exe + \
                      " -cs -mask -nt -ow -stars 9 -thr 4 Fasta/f002")
     result, stdout, stderr = Application.generic_run(cmdline)
     self.assertEqual(stderr.read(), "")
     self.assertEqual(result.return_code, 0)
     self.assert_(os.path.exists(self.outfile1))
     self.assert_(stdout.read().startswith(" e_len = 633"))
     self.assertEqual(str(result._cl), str(cmdline))
예제 #23
0
 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("-",""))
예제 #24
0
 def test_Dialign_complex_command_line(self):
     """Round-trip through app with complex command line."""
     cmdline = DialignCommandline(dialign_exe)
     cmdline.set_parameter("input", self.infile1)
     cmdline.set_parameter("-nt", True)
     cmdline.set_parameter("-thr", 4)
     cmdline.set_parameter("stars", 9)
     cmdline.set_parameter("-ow", True)
     cmdline.set_parameter("mask", True)
     cmdline.set_parameter("-cs", True)
     self.assertEqual(str(cmdline), dialign_exe + \
                      " -cs -mask -nt -ow -stars 9 -thr 4 Fasta/f002")
     result, stdout, stderr = Application.generic_run(cmdline)
     self.assertEqual(stderr.read(), "")
     self.assertEqual(result.return_code, 0)
     self.assert_(os.path.exists(self.outfile1))
     self.assert_(stdout.read().startswith(" e_len = 633"))
     self.assertEqual(str(result._cl), str(cmdline))
예제 #25
0
 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")
     result, stdout, stderr = Application.generic_run(cmdline)
     self.assertEqual(str(cmdline), str(result._cl))
     self.assertEquals(result.return_code, 0)
     self.assert_(stderr.read().startswith("\nPROBCONS"))
     self.assert_(stdout.read().startswith(">AK1H_ECOLI/1-378"))
예제 #26
0
 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("-",""))
예제 #27
0
 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))
     result, stdout, stderr = Application.generic_run(cmdline)
     self.assertEquals(result.return_code, 0)
     self.assertEqual(str(cmdline), str(result._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("-", ""))
예제 #28
0
 def test_Probcons_alignment_clustalw(self):
     """Round-trip through app and read clustalw alignment from stdout
     """
     cmdline = ProbconsCommandline(probcons_exe)
     cmdline.set_parameter("input", "Fasta/fa01")
     cmdline.clustalw = True
     self.assertEqual(str(cmdline), probcons_exe + " -clustalw Fasta/fa01")
     self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
     result, stdout, stderr = Application.generic_run(cmdline)
     self.assertEquals(result.return_code, 0)
     self.assertEqual(str(cmdline), str(result._cl))
     self.assert_(stderr.read().strip().startswith("PROBCONS"))
     #self.assert_(stdout.read().strip().startswith("PROBCONS"))
     align = AlignIO.read(StringIO(stdout.read()), "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("-",""))
예제 #29
0
 def test_TCoffee_3(self):
     """Round-trip through app and read clustalw alignment from file
     """
     cmdline = TCoffeeCommandline(t_coffee_exe, gapopen=-2)
     cmdline.infile = self.infile1
     cmdline.outfile = self.outfile4
     cmdline.set_parameter("output", "clustalw_aln")
     cmdline.outorder = "input"
     cmdline.set_parameter("gapext", -5)
     cmdline.type = "protein"
     self.assertEqual(str(cmdline), t_coffee_exe + " -output clustalw_aln "
                      "-infile Fasta/fa01 -outfile Fasta/tc_out.phy "
                      "-outorder input -gapopen -2 -gapext -5")
     result, stdout, stderr = Application.generic_run(cmdline)
     self.assertEquals(result.return_code, 0)
     self.assert_(stderr.read().strip().startswith("PROGRAM: T-COFFEE"))
     align = AlignIO.read(open(self.outfile4), "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("-",""))
예제 #30
0
 def test_TCoffee_3(self):
     """Round-trip through app and read clustalw alignment from file
     """
     cmdline = TCoffeeCommandline(t_coffee_exe, gapopen=-2)
     cmdline.infile = self.infile1
     cmdline.outfile = self.outfile4
     cmdline.set_parameter("output", "clustalw_aln")
     cmdline.outorder = "input"
     cmdline.set_parameter("gapext", -5)
     cmdline.type = "protein"
     self.assertEqual(str(cmdline), t_coffee_exe + " -output clustalw_aln "
                      "-infile Fasta/fa01 -outfile Fasta/tc_out.phy "
                      "-outorder input -gapopen -2 -gapext -5")
     result, stdout, stderr = Application.generic_run(cmdline)
     self.assertEquals(result.return_code, 0)
     self.assert_(stderr.read().strip().startswith("PROGRAM: T-COFFEE"))
     align = AlignIO.read(open(self.outfile4), "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("-",""))
예제 #31
0
 def test_Prank_complex_command_line(self):
     """Round-trip with complex command line."""
     cmdline = PrankCommandline(prank_exe)
     cmdline.set_parameter("d", self.infile1)
     cmdline.set_parameter("-noxml", True)
     cmdline.set_parameter("notree", True)
     cmdline.set_parameter("-gaprate", 0.321)
     cmdline.set_parameter("gapext", 0.6)
     cmdline.set_parameter("-dots", 1) #i.e. True
     #Try using a property:
     cmdline.kappa = 3
     cmdline.skipins = True
     cmdline.set_parameter("-once", True)
     cmdline.realbranches = True
     self.assertEqual(str(cmdline), prank_exe + " -d=Fasta/fa01 -noxml" + \
                      " -notree -dots -gaprate=0.321 -gapext=0.6 -kappa=3" + \
                      " -once -skipins -realbranches")
     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))
예제 #32
0
 def test_Prank_complex_command_line(self):
     """Round-trip with complex command line."""
     cmdline = PrankCommandline(prank_exe)
     cmdline.set_parameter("d", self.infile1)
     cmdline.set_parameter("-noxml", True)
     cmdline.set_parameter("notree", True)
     cmdline.set_parameter("-gaprate", 0.321)
     cmdline.set_parameter("gapext", 0.6)
     cmdline.set_parameter("-dots", 1)  #i.e. True
     #Try using a property:
     cmdline.kappa = 3
     cmdline.skipins = True
     cmdline.set_parameter("-once", True)
     cmdline.realbranches = True
     self.assertEqual(str(cmdline), prank_exe + " -d=Fasta/fa01 -noxml" + \
                      " -notree -dots -gaprate=0.321 -gapext=0.6 -kappa=3" + \
                      " -once -skipins -realbranches")
     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))
예제 #33
0
		"Display percent identity and similarity"),
		_Option(["-nosimilarity"], ["input"], None, 0,
		"Do not display percent identity and similarity"),
		_Option(["-aformat"], ["input"], None, 0,
		"Display output in a different specified output format")] 

class PepstatsCommandline(Application.AbstractCommandline):
	def __init__(self, cmd = "pepstats"):
		Application.AbstractCommandline.__init__(self)
		self.program_name = cmd
		self.parameters = \
		[_Option(["-sequence"], ["input", "file"], None, 1,
		"First sequence to align"), 
		_Option(["-outfile"], ["output", "file"], None, 1,
		"Output file for the Statistics"),
		_Option(["-aadata"], ["input", "file"], None, 0,
		"Matrix file")]

w = WaterCommandline()
w.set_parameter("-asequence", "/home/sjcockell/P07830.fasta")
w.set_parameter("-bsequence", "/home/sjcockell/P07830.fasta")
w.set_parameter("-gapopen", "10.0")
w.set_parameter("-gapextend", "1.0")
w.set_parameter("-outfile", "out.txt")
Application.generic_run(w)
p = PepstatsCommandline()
p.set_parameter("-sequence", "/home/sjcockell/P07830.fasta")
p.set_parameter("-outfile", "stats.txt")
Application.generic_run(p)

예제 #34
0
 def run(self):
     return Application.generic_run(self)