Exemplo n.º 1
0
    def test_RunExtProg_check(self):

        prog1 = runExtProg("./program1", pdir=self.data_dir, check_OS=True)
        self.assertEqual(prog1.program_name, "./program1_" + TestRunExtProg.platform)

        prog1 = runExtProg("./muscle3.8.31_i86linux64", pdir=self.data_dir, check_OS=True)
        self.assertEqual(prog1.program_name, "./muscle3.8.31_i86linux64")

        with self.assertRaises(TypeError):
            runExtProg("./muscle3.8.31_i86linux64", check_OS=True)
Exemplo n.º 2
0
    def __init__(self, pdir, wdir, infile, outfile=None, check_exist=True):
        """
        Constructor
        """
        super(RunGlimmer, self).__init__(pdir, wdir, infile, check_exist)
        self.all_exts = ALL_EXTS
#         self.parameter_check(pdir, wdir, infile, outfile, check_exist, ".glimmer")
        self.outfile = self.check_outfile_filename(outfile, ".glimmer")

        self.glimmer = runExtProg(GLIMMER, pdir=self.pdir, length=2, check_OS=True)
        self.extract = runExtProg(EXTRACT, pdir=self.pdir, length=2, check_OS=True)
        self.init_prog()
Exemplo n.º 3
0
    def __init__(self, pdir, wdir, infile, no_iter=DEFAULT_XGENOVO_NO_ITER, thresh=DEFAULT_XGENOVO_THRESH,
                 outfile=None, check_exist=True):
        """
        Constructor
        """
        super(RunXGenovo, self).__init__(pdir, wdir, infile, check_exist)
        self.all_exts = ALL_EXTS

        self.outfile = self.check_outfile_filename(outfile, ".xgenovo")
#         self.parameter_check(self.pdir, self.wdir, infile, outfile, check_exist, ".genovo")

        self.assemble = runExtProg(ASSEMBLE, pdir=self.pdir, length=2, check_OS=True)
        self.finalize = runExtProg(FINALIZE, pdir=self.pdir, length=3, check_OS=True)

        self.init_prog(no_iter, thresh)
Exemplo n.º 4
0
 def test_RunExtProg_run_command(self):
     prog1 = runExtProg("ls")
     prog1.add_switch("-l")
     prog1.run()
     self.out = prog1.output
     self.assertTrue(self.out.find("main.py"))
     self.assertTrue(self.out.find("test_run_ext_prog.py"))
Exemplo n.º 5
0
 def __init__(self, model_file, no_reads, taxon_infile, pdir, wdir, filename=None, check_exist=True):
     """
     Constructor
     """
 # FIXME: allow 454 or Sanger model; put on -c switch.
     self.all_exts = ALL_EXTS
     self.parameter_check(pdir, wdir, model_file, taxon_infile, filename, check_exist)
     self.metasim = runExtProg(METASIM, pdir=self.pdir, length=5, check_OS=True)
     self.metasim.set_param_at("cmd", 1)
     self.init_prog(no_reads)
Exemplo n.º 6
0
    def test_RunExtProg_set_switch(self):
        prog1 = runExtProg("ls")
        self.assertEqual(prog1.get_all_switches(), [])

        prog1.set_switch("-l")
        self.assertEqual(prog1.get_all_switches(), ["-l"])

        prog1.set_switch("-s")
        self.assertEqual(prog1.get_all_switches(), ["-s"])

        prog1.set_switch(["-111", "-222"])
        self.assertEqual(prog1.get_all_switches(), ["-111", "-222"])
Exemplo n.º 7
0
    def test_RunExtProg_update_switch(self):
        prog1 = runExtProg("ls")

        prog1.add_switch(["-a", "1", "--b", "2"])
        self.assertEqual(prog1.get_all_switches(), ["-a", "1", "--b", "2"])
        prog1.update_switch("-a", "3")
        self.assertEqual(prog1.get_all_switches(), ["-a", "3", "--b", "2"])
        prog1.update_switch("-c", "4")
        self.assertEqual(prog1.get_all_switches(), ["-a", "3", "--b", "2", "-c", "4"])
        prog1.update_switch("-b", "5")
        self.assertEqual(prog1.get_all_switches(), ["-a", "3", "--b", "2", "-c", "4", "-b", "5"])
        prog1.update_switch("-C", "6")
        self.assertEqual(prog1.get_all_switches(), ["-a", "3", "--b", "2", "-c", "4", "-b", "5", "-C", "6"])
        prog1.update_switch("--b", "7")
        self.assertEqual(prog1.get_all_switches(), ["-a", "3", "--b", "7", "-c", "4", "-b", "5", "-C", "6"])
Exemplo n.º 8
0
    def test_RunExtProg_toggle_switch(self):
        prog1 = runExtProg("ls")
        prog1.add_switch(["-a", "1"])
        prog1.toggle_switch("-t")
        self.assertEqual(prog1.get_all_switches(), ["-a", "1", "-t"])

        prog1.toggle_switch("-t")
        self.assertEqual(prog1.get_all_switches(), ["-a", "1"])

        prog1.toggle_switch("-t", 0)
        self.assertEqual(prog1.get_all_switches(), ["-a", "1"])

        prog1.toggle_switch("-t", 1)
        self.assertEqual(prog1.get_all_switches(), ["-a", "1", "-t"])

        prog1.toggle_switch("-t", 1)
        self.assertEqual(prog1.get_all_switches(), ["-a", "1", "-t"])

        prog1.toggle_switch("-t", 0)
        self.assertEqual(prog1.get_all_switches(), ["-a", "1"])
Exemplo n.º 9
0
    def test_RunExtProg_run_program(self):

        self.filename = "tempAlignmentOutput.fasta"
        if os.path.isfile(self.data_dir + self.filename):
            os.remove(self.data_dir + self.filename)

        self.assertFalse(os.listdir(self.data_dir).count(self.filename))

        prog2 = runExtProg("./muscle3.8.31_i86linux64", pdir=self.data_dir)
        self._switch = "-in testAlignmentInput.fasta -out".split()
        self._switch.append(self.filename)

        prog2.add_switch(self._switch)
        prog2.run()
        self.out = prog2.errors  # not sure why output capture by stderr, but it works
        self.assertTrue(os.listdir(self.data_dir).count(self.filename))
        self.assertTrue(self.out.find("MUSCLE v3.8.31"))
        self.assertTrue(self.out.find("testAlignmentInput 2 seqs"))

        # clean up
        os.remove(self.data_dir + self.filename)
Exemplo n.º 10
0
    def test_RunExtProg_append_reset_switch(self):
        prog1 = runExtProg("ls")
        self.assertEqual(prog1.get_all_switches(), [])

        prog1.add_switch("-l")
        self.assertEqual(prog1.get_all_switches(), ["-l"])

        prog1.add_switch("-s")
        self.assertEqual(prog1.get_all_switches(), ["-l", "-s"])

        prog1.add_switch(["-1", "-2"])
        self.assertEqual(prog1.get_all_switches(), ["-l", "-s", "-1", "-2"])

        prog1.add_switch(["-x"])
        self.assertEqual(prog1.get_all_switches(), ["-l", "-s", "-1", "-2", "-x"])

        prog1.reset_switch()
        self.assertEqual(prog1.get_all_switches(), [])

        prog1.add_switch(["-a", "-b"])
        self.assertEqual(prog1.get_all_switches(), ["-a", "-b"])
Exemplo n.º 11
0
    def __init__(self, pdir, wdir, infile, comparison='-allPairs',
                 cv=DEFAULT_CV, exp=DEFAULT_EXP, clumps=DEFAULT_CLUMPS,
                 jobID=None,
                 csv_files=None,
                 check_exist=True,
                 overwrite=False):
        """
        Constructor
        """
        super(RunMINE, self).__init__(pdir, wdir, infile, check_exist)

        self.all_exts = ALL_EXTS

        if jobID is None:
            self.jobID = "MineOutput"
        else:
            self.jobID = jobID

        self.overwrite = overwrite
#         self.parameter_check(pdir, wdir, infile, infile, False, "")

#         if not self.infile.endswith(".csv"):
#             self.infile = self.infile + ".csv"
#         self.outfile = self.infile + "," + self.jobID
        self.outfile = self.check_outfile_filename(self.infile, ".mine.csv")
        # print self.infile, self.outfile, self.pdir
#         print self.check_outfiles_with_filetag_exist(self.outfile) //FIXME: anothre hack

        self.mine = runExtProg(MINE, pdir=self.pdir, length=6 + offset, check_OS=True)
        self.mine.set_param_at("-jar", 1)
        self.mine.set_param_at("MINE.jar", 2)
        self.init_prog(comparison, cv, exp, clumps)

        self.csv_files = csv_files
        if self.csv_files is None:
            print "TODO?"
Exemplo n.º 12
0
    def __init__(self, infile, pdir, blast_db, wdir=None, outfile=None, check_exist=True, e_value='1e-15', blast_thread=1):
        """

        :param infile: The input sequence to blast
        :param pdir: program dir
        :param wdir: working dir?
        :param outfile: output file to write csv summary
        :param check_exist: check if files exist
        :param e_value: threshhold to provide to blast
        :param blast_db: the local NCBI formatted blast databae
        :return: an initialized RunBlast
        """
        super(RunBlast, self).__init__(pdir, wdir, infile)
        self.all_exts = ALL_EXTS
        self.e_value = e_value
        self.blast_db = blast_db
        self.blast_thread = blast_thread

        self.outfile = self.check_outfile_filename(outfile, ".blast.csv")
        self.intermediate_file = infile + INT_FILE_EXT
        # print "BLAST Setting", self.blast_db, self.infile, self.outfile, self.pdir
        self.blastx = runExtProg(BLASTX, pdir=self.pdir, length=14, check_OS=True)
        # step 2 is a python script.
        self.init_prog()