class_docstr: Submits jobs to SGE, can check on their status, and kill jobs.
  
  Uses ``drmaa`` Python library. Due to the way SGE works it cannot
  distinguish between a failed and a completed job.
  
  Args:
      submit_options (str): command line options such as queue ``-q``, or
          ``-P`` for project, all written in one string.
      environment (str): the path to a file that contains environment
          variables; will be sourced before job is run.
      output_dir (str): path to directory in which ``stdout`` and ``stderr``
          will be written to. If not specified this will use the same as
          defined for the study.
class_docstr_tok: ["Submits","jobs","to","SGE",",","can","check","on","their","status",",","and","kill","jobs",".","Uses","``","drmaa","``","Python","library",".","Due","to","the","way","SGE","works","it","can","not","distinguish","between","a","failed","and","a","completed","job",".","Args",":","submit_options","(","str",")",":","command","line","options","such","as","queue","``","-q","``",",","or","``","-P","``","for","project",",","all","written","in","one","string",".","environment","(","str",")",":","the","path","to","a","file","that","contains","environment","variables",";","will","be","sourced","before","job","is","run",".","output_dir","(","str",")",":","path","to","directory","in","which","``","stdout","``","and","``","stderr","``","will","be","written","to",".","If","not","specified","this","will","use","the","same","as","defined","for","the","study","."]
code: def submit_job(self, command, env={}, job_name=""):
      # Create temp directory.
      outdir = os.path.join(self.output_dir, "jobs")
      if not os.path.isdir(outdir):
          os.mkdir(outdir)
  
      job_name = job_name or str(self.count)
      sgeoutfile = os.path.join(outdir, "{}.out".format(job_name))
      try:
          os.remove(sgeoutfile)
      except OSError:
          pass
  
      # Create bash script that sources environment and runs python script.
      job_script = "#$ -S /bin/bash\n"
      if self.environment:
          job_script += "source %s\n" % self.environment
      job_script += 'echo "Running from" ${HOSTNAME}\n'
      for var_name, var_value in env.items():
          job_script += "export {}={}\n".format(var_name, var_value)
      job_script += " ".join(command)  # 'python file.py args...'
  
      # Submit command to SGE.
      # Note: submitting job using drmaa didn't work because we weren't able
      # to specify options.
      submit_command = (
          "qsub -S /bin/bash -wd {} -j y -o {} -e {} {}".format(
              os.getcwd(), sgeoutfile, sgeoutfile, self.submit_options
          )
      )
      assert " -cwd" not in submit_command
  
      # Submit using subprocess so we can get SGE process ID.
      job_id = self._submit_job(submit_command, job_script)
  
      logger.info("\t{}: job submitted".format(job_id))
      self.count += 1
  
      return job_id
  
imports: import subprocess
  import re
  import sys
  import os
  import logging
label_desc: Use image node_id 2 for calling the SGEScheduler obj's underlying member method code with example usage: obj.submit_job(command, env, job_name) and returns: job_id