Пример #1
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(self.infile1, "fasta"))
     # Try using keyword argument,
     cmdline = PrankCommandline(prank_exe, d=self.infile1)
     # Try using a property,
     cmdline.d = self.infile1
     cmdline.f = 17  # NEXUS format
     cmdline.set_parameter("dots", True)
     self.assertEqual(str(cmdline), _escape_filename(prank_exe) + " -d=Fasta/fa01 -f=17 -dots")
     self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
     stdout, stderr = cmdline()
     self.assertTrue("Total time" in stdout)
     self.assertEqual(stderr, "")
     try:
         if os.path.isfile("output.best.nex"):
             # Prank v.130820 and perhaps earlier use ".best.*" output names
             nex_fname = "output.best.nex"
         elif os.path.isfile("output.2.nex"):
             # Older Prank versions use ".2.*" output names
             nex_fname = "output.2.nex"
         else:
             raise RuntimeError("Can't find PRANK's NEXUS output (*.nex)")
         align = AlignIO.read(nex_fname, "nexus")
         for old, new in zip(records, align):
             # Old versions of Prank reduced name to 9 chars
             self.assertTrue(old.id == new.id or old.id[:9] == new.id)
             # infile1 has alignment gaps in it
             self.assertEqual(str(new.seq).replace("-", ""), str(old.seq).replace("-", ""))
     except NexusError:
         # See bug 3119,
         # Bio.Nexus can't parse output from prank v100701 (1 July 2010)
         pass
Пример #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 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(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),
         _escape_filename(prank_exe) +
         " -d=Fasta/fa01 -f=17 -noxml -notree")
     self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
     stdout, stderr = cmdline()
     self.assertTrue("Total time" in stdout)
     self.assertEqual(stderr, "")
     try:
         align = AlignIO.read("output.2.nex", "nexus")
         for old, new in zip(records, align):
             #Old versions of Prank reduced name to 9 chars
             self.assertTrue(old.id == new.id or old.id[:9] == new.id)
             #infile1 has alignment gaps in it
             self.assertEqual(
                 str(new.seq).replace("-", ""),
                 str(old.seq).replace("-", ""))
     except NexusError:
         #See bug 3119,
         #Bio.Nexus can't parse output from prank v100701 (1 July 2010)
         pass
Пример #4
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("-", ""))
Пример #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))
     child = subprocess.Popen(
         str(cmdline), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=(sys.platform != "win32")
     )
     return_code = child.wait()
     self.assertEqual(return_code, 0)
     self.assert_("Total time" in child.stdout.read())
     self.assertEqual(child.stderr.read(), "")
     align = AlignIO.read(open("output.2.nex"), "nexus")
     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("-", ""))
     del child
Пример #6
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(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), _escape_filename(prank_exe) +
                      " -d=Fasta/fa01 -f=17 -noxml -notree")
     self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
     stdout, stderr = cmdline()
     self.assertTrue("Total time" in stdout)
     self.assertEqual(stderr, "")
     try:
         align = AlignIO.read("output.2.nex", "nexus")
         for old, new in zip(records, align):
             #Old versions of Prank reduced name to 9 chars
             self.assertTrue(old.id == new.id or old.id[:9] == new.id)
             #infile1 has alignment gaps in it
             self.assertEqual(str(new.seq).replace("-", ""),
                              str(old.seq).replace("-", ""))
     except NexusError:
         #See bug 3119,
         #Bio.Nexus can't parse output from prank v100701 (1 July 2010)
         pass
Пример #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), _escape_filename(prank_exe) + " -d=Fasta/fa01")
     self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
     output, error = cmdline()
     self.assertEqual(error, "")
     self.assertTrue("Total time" in output)
Пример #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))
     output, error = cmdline()
     self.assertEqual(error, "")
     self.assertTrue("Total time" in output)
Пример #9
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))
Пример #10
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))
Пример #11
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))
     child = subprocess.Popen(
         str(cmdline), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=(sys.platform != "win32")
     )
     return_code = child.wait()
     self.assertEqual(return_code, 0)
     self.assert_("Total time" in child.stdout.read())
     self.assertEqual(child.stderr.read(), "")
     del child
Пример #12
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(self.infile1, "fasta"))
        # Try using keyword argument,
        cmdline = PrankCommandline(prank_exe, d=self.infile1)
        # Try using a property,
        cmdline.d = self.infile1
        cmdline.f = 17  # NEXUS format
        cmdline.set_parameter("dots", True)
        self.assertEqual(
            str(cmdline),
            _escape_filename(prank_exe) + " -d=Fasta/fa01 -f=17 -dots")
        self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
        stdout, stderr = cmdline()
        self.assertIn("Total time", stdout)
        self.assertEqual(stderr, "")
        try:
            if os.path.isfile("output.best.nex"):
                # Prank v.130820 and perhaps earlier use ".best.*" output names
                nex_fname = "output.best.nex"
            elif os.path.isfile("output.2.nex"):
                # Older Prank versions use ".2.*" output names
                nex_fname = "output.2.nex"
            else:
                raise RuntimeError("Can't find PRANK's NEXUS output (*.nex)")
            align = AlignIO.read(nex_fname, "nexus")
            for old, new in zip(records, align):
                # Old versions of Prank reduced name to 9 chars
                self.assertTrue(old.id == new.id or old.id[:9] == new.id)
                # infile1 has alignment gaps in it
                self.assertEqual(
                    str(new.seq).replace("-", ""),
                    str(old.seq).replace("-", ""))
        except NexusError:
            # See bug 3119,
            # Bio.Nexus can't parse output from prank v100701 (1 July 2010)
            pass
Пример #13
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))
     child = subprocess.Popen(str(cmdline),
                              stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE,
                              universal_newlines=True,
                              shell=(sys.platform!="win32"))
     return_code = child.wait()
     self.assertEqual(return_code, 0)
     self.assertTrue("Total time" in child.stdout.read())
     self.assertEqual(child.stderr.read(), "")
     try:
         align = AlignIO.read(open("output.2.nex"), "nexus")
         for old, new in zip(records, align):
             #Old versions of Prank reduced name to 9 chars
             self.assertTrue(old.id==new.id or old.id[:9]==new.id)
             #infile1 has alignment gaps in it
             self.assertEqual(str(new.seq).replace("-",""),
                              str(old.seq).replace("-",""))
     except NexusError:
         #See bug 3119,
         #Bio.Nexus can't parse output from prank v100701 (1 July 2010)
         pass
     del child
Пример #14
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("-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), _escape_filename(prank_exe) +
                      " -d=Fasta/fa01" +
                      " -dots -gaprate=0.321 -gapext=0.6 -kappa=3" +
                      " -once -skipins -realbranches")
     self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
     stdout, stderr = cmdline()
     self.assertTrue("Total time" in stdout, stdout)
Пример #15
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("-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), _escape_filename(prank_exe) +
                      " -d=Fasta/fa01" +
                      " -dots -gaprate=0.321 -gapext=0.6 -kappa=3" +
                      " -once -skipins -realbranches")
     self.assertEqual(str(eval(repr(cmdline))), str(cmdline))
     stdout, stderr = cmdline()
     self.assertTrue("Total time" in stdout, stdout)
Пример #16
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))
Пример #17
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))
     child = subprocess.Popen(
         str(cmdline), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=(sys.platform != "win32")
     )
     return_code = child.wait()
     self.assertEqual(return_code, 0)
     self.assert_("Total time" in child.stdout.read())
     self.assertEqual(child.stderr.read(), "")
     del child
Пример #18
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))