code: def submit_safe_jobs(root_dir, jobs, sgeargs=None):
      
      # Loop over each job, constructing SGE command-line based on job settings
      for job in jobs:
          job.out = os.path.join(root_dir, "stdout")
          job.err = os.path.join(root_dir, "stderr")
  
          # Add the job name, current working directory, and SGE stdout/stderr
          # directories to the SGE command line
          args = " -N %s " % (job.name)
          args += " -cwd "
          args += " -o %s -e %s " % (job.out, job.err)
  
          # If a queue is specified, add this to the SGE command line
          # LP: This has an undeclared variable, not sure why - delete?
          #if job.queue is not None and job.queue in local_queues:
          #    args += local_queues[job.queue]
  
          # If the job is actually a JobGroup, add the task numbering argument
          if isinstance(job, JobGroup):
              args += "-t 1:%d " % (job.tasks)
  
          # If there are dependencies for this job, hold the job until they are
          # complete
          if len(job.dependencies) > 0:
              args += "-hold_jid "
              for dep in job.dependencies:
                  args += dep.name + ","
              args = args[:-1]
  
          # Build the qsub SGE commandline (passing local environment)
          qsubcmd = ("%s -V %s %s" %
                     (pyani_config.QSUB_DEFAULT, args, job.scriptpath))
          if sgeargs is not None:
              qsubcmd = "%s %s" % (qsubcmd, sgeargs)
          os.system(qsubcmd)               # Run the command
          job.submitted = True
docs: Submit the passed list of jobs to the Grid Engine server, using the
      passed directory as the root for scheduler output.
  
      - root_dir      Path to output directory
      - jobs          Iterable of Job objects