Ejemplo n.º 1
0
 def run_job(self, job):
     if not job.jar() or not os.path.exists(os.path.join(self.path,job.jar())):
         logger.error("Can't find jar: {0}, full path {1}".format(job.jar(),
                                                                  os.path.abspath(job.jar())))
         raise Exception("job jar does not exist")
     arglist = [JAVA] + job.java_opt() + ['-jar', os.path.join(self.path, job.jar())]
     if job.main():
         arglist.append(self._get_main(job))
     if job.opts():
         arglist += job.opts()
     (tmp_files, job_args) = DefaultShellJobRunner._fix_paths(job)
     arglist += job_args
     cmd = ' '.join(arglist)        
     logger.info("\nJob runner '{0}';\n\trunning command '{1}'".format(self.__class__, cmd))
     (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)
     if returncode == 0:
         logger.info("Shell job completed")
         for a, b in tmp_files:
             logger.info("renaming {0} to {1}".format(a.path, b.path))
             # TODO : this should be relpath?
             a.move(os.path.join(os.curdir, b.path))
             # Some GATK programs generate bai or idx files on the fly...
             if os.path.exists(a.path + ".bai"):
                 logger.info("Saw {} file".format(a.path + ".bai"))
                 os.rename(a.path + ".bai", b.path.replace(".bam", ".bai"))
             if os.path.exists(a.path + ".idx"):
                 logger.info("Saw {} file".format(a.path + ".idx"))
                 os.rename(a.path + ".idx", b.path + ".idx")
     else:
         raise Exception("Job '{}' failed: \n{}".format(cmd, " ".join([stderr])))
Ejemplo n.º 2
0
 def run_job(self, job):
     if not job.exe():# or not os.path.exists(job.exe()):
         logger.error("Can't find executable: {0}, full path {1}".format(job.exe(),
                                                                         os.path.abspath(job.exe())))
         raise Exception("executable does not exist")
     arglist = [job.exe()]
     if job.main():
         arglist.append(self._get_main(job))
     if job.opts():
         arglist += job.opts()
     # Need to call self.__class__ since fix_paths overridden in
     # DefaultGzShellJobRunner
     (tmp_files, job_args) = self.__class__._fix_paths(job)
     
     arglist += job_args
     cmd = ' '.join(arglist)
     logger.info("\nJob runner '{0}';\n\trunning command '{1}'\n".format(self.__class__, cmd))
     (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)
     if returncode == 0:
         logger.info("Shell job completed")
         for a, b in tmp_files:
             logger.info("renaming {0} to {1}".format(a.path, b.path))
             # This is weird; using the example in luigi
             # (a.move(b)) doesn't work, and using just b.path
             # fails unless it contains a directory (e.g. './file'
             # works, 'file' doesn't)
             a.move(os.path.join(os.curdir, b.path))
     else:
         raise Exception("Job '{}' failed: \n{}".format(' '.join(arglist), " ".join([stderr])))
Ejemplo n.º 3
0
    def run_job(self, job):
        (arglist, tmp_files) = self._make_arglist(job)
        (tmpdir, outdir) = tmp_files[0]
        os.makedirs(os.path.join(os.curdir, tmpdir.path))
        # Need to send output to temporary *directory*, not file
        cmd = ' '.join(arglist)        
        logger.info("Job runner '{0}'; running command '{1}'".format(self.__class__, cmd))
        (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)

        if returncode == 0:
            logger.info("Shell job completed")
            for a, b in tmp_files:
                logger.info("renaming {0} to {1}".format(a.path, b.path))
                a.move(os.path.join(os.curdir, b.path))
        else:
            raise Exception("Job '{}' failed: \n{}".format(cmd.replace("= ", "="), " ".join([stderr])))
Ejemplo n.º 4
0
 def run_job(self, job):
     (arglist, tmp_files) = self._make_arglist(job)
     if job.pipe:
         return (arglist, tmp_files)
     cmd = ' '.join(arglist)
     logger.info("\nJob runner '{0}';\n\trunning command '{1}'\n".format(self.__class__, cmd))
     (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)
     if returncode == 0:
         logger.info("Shell job completed")
         for a, b in tmp_files:
             logger.info("renaming {0} to {1}".format(a.path, b.path))
             # This is weird; using the example in luigi
             # (a.move(b)) doesn't work, and using just b.path
             # fails unless it contains a directory (e.g. './file'
             # works, 'file' doesn't)
             a.move(os.path.join(os.curdir, b.path))
     else:
         raise Exception("Job '{}' failed: \n{}".format(' '.join(arglist), " ".join([stderr])))
Ejemplo n.º 5
0
    def run_job(self, job):
        (arglist, tmp_files) = self._make_arglist(job)
        (tmpdir, outdir) = tmp_files[0]
        os.makedirs(os.path.join(os.curdir, tmpdir.path))
        # Need to send output to temporary *directory*, not file
        cmd = ' '.join(arglist)
        logger.info("Job runner '{0}'; running command '{1}'".format(
            self.__class__, cmd))
        (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)

        if returncode == 0:
            logger.info("Shell job completed")
            for a, b in tmp_files:
                logger.info("renaming {0} to {1}".format(a.path, b.path))
                a.move(os.path.join(os.curdir, b.path))
        else:
            raise Exception("Job '{}' failed: \n{}".format(
                cmd.replace("= ", "="), " ".join([stderr])))
Ejemplo n.º 6
0
 def run_job(self, job):
     (arglist, tmp_files) = self._make_arglist(job)
     if job.pipe:
         return (arglist, tmp_files)
     cmd = ' '.join(arglist)
     logger.info("\nJob runner '{0}';\n\trunning command '{1}'\n".format(
         self.__class__, cmd))
     (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)
     if returncode == 0:
         logger.info("Shell job completed")
         for a, b in tmp_files:
             logger.info("renaming {0} to {1}".format(a.path, b.path))
             # This is weird; using the example in luigi
             # (a.move(b)) doesn't work, and using just b.path
             # fails unless it contains a directory (e.g. './file'
             # works, 'file' doesn't)
             a.move(os.path.join(os.curdir, b.path))
     else:
         raise Exception("Job '{}' failed: \n{}".format(
             ' '.join(arglist), " ".join([stderr])))
Ejemplo n.º 7
0
 def run_job(self, job):
     (arglist, tmp_files) = self._make_arglist(job)
     cmd = ' '.join(arglist)        
     logger.info("\nJob runner '{0}';\n\trunning command '{1}'".format(self.__class__, cmd))
     (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)
     if returncode == 0:
         logger.info("Shell job completed")
         for a, b in tmp_files:
             logger.info("renaming {0} to {1}".format(a.path, b.path))
             # TODO : this should be relpath?
             a.move(os.path.join(os.curdir, b.path))
             # Some GATK programs generate bai or idx files on the fly...
             if os.path.exists(a.path + ".bai"):
                 logger.info("Saw {} file".format(a.path + ".bai"))
                 os.rename(a.path + ".bai", b.path.replace(".bam", ".bai"))
             if os.path.exists(a.path + ".idx"):
                 logger.info("Saw {} file".format(a.path + ".idx"))
                 os.rename(a.path + ".idx", b.path + ".idx")
     else:
         raise Exception("Job '{}' failed: \n{}".format(cmd, " ".join([stderr])))
Ejemplo n.º 8
0
 def run_job(self, job):
     (arglist, tmp_files) = self._make_arglist(job)
     cmd = ' '.join(arglist)
     logger.info("\nJob runner '{0}';\n\trunning command '{1}'".format(
         self.__class__, cmd))
     (stdout, stderr, returncode) = shell.exec_cmd(cmd, shell=True)
     if returncode == 0:
         logger.info("Shell job completed")
         for a, b in tmp_files:
             logger.info("renaming {0} to {1}".format(a.path, b.path))
             # TODO : this should be relpath?
             a.move(os.path.join(os.curdir, b.path))
             # Some GATK programs generate bai or idx files on the fly...
             if os.path.exists(a.path + ".bai"):
                 logger.info("Saw {} file".format(a.path + ".bai"))
                 os.rename(a.path + ".bai", b.path.replace(".bam", ".bai"))
             if os.path.exists(a.path + ".idx"):
                 logger.info("Saw {} file".format(a.path + ".idx"))
                 os.rename(a.path + ".idx", b.path + ".idx")
     else:
         raise Exception("Job '{}' failed: \n{}".format(
             cmd, " ".join([stderr])))
Ejemplo n.º 9
0
    def run_job(self, job):
        if not job.jar() or not os.path.exists(os.path.join(self.path,job.jar())):
            logger.error("Can't find jar: {0}, full path {1}".format(job.jar(),
                                                                     os.path.abspath(job.jar())))
            raise Exception("job jar does not exist")
        arglist = [JAVA] + job.java_opt() + ['-jar', os.path.join(self.path, job.jar())]
        if job.main():
            arglist.append(job.main())
        if job.opts():
            arglist += job.opts()
        (tmp_files, job_args) = DefaultShellJobRunner._fix_paths(job)

        arglist += job_args
        cmd = ' '.join(arglist)        
        logger.info("\nJob runner '{0}';\n\trunning command '{1}'".format(self.__class__, cmd.replace("= ", "=")))
        (stdout, stderr, returncode) = shell.exec_cmd(cmd.replace("= ", "="), shell=True)

        if returncode == 0:
            logger.info("Shell job completed")
            for a, b in tmp_files:
                logger.info("renaming {0} to {1}".format(a.path, b.path))
                a.move(os.path.join(os.curdir, b.path))
        else:
            raise Exception("Job '{}' failed: \n{}".format(cmd.replace("= ", "="), " ".join([stderr])))