docs: def run(cmd, output_fpath=None, input_fpath=None, checks=None, stdout_to_outputfile=True,
          stdout_tx=True, reuse=False, env_vars=None):
      """Run the provided command, logging details and checking for errors.
      """
      if output_fpath and reuse:
          if verify_file(output_fpath, silent=True):
              info(output_fpath + ' exists, reusing')
              return output_fpath
          if not output_fpath.endswith('.gz') and verify_file(output_fpath + '.gz', silent=True):
              info(output_fpath + '.gz exists, reusing')
              return output_fpath
  
      env = os.environ.copy()
      if env_vars:
          for k, v in env_vars.items():
              if v is None:
                  if k in env:
                      del env[k]
              else:
                  env[k] = v
  
      if checks is None:
          checks = [file_nonempty_check]
  
      def _try_run(_cmd, _output_fpath, _input_fpath):
          try:
              info(' '.join(str(x) for x in _cmd) if not isinstance(_cmd, six.string_types) else _cmd)
              _do_run(_cmd, checks, env, _output_fpath, _input_fpath)
          except:
              raise
  
      if output_fpath:
          if isfile(output_fpath):
              os.remove(output_fpath)
      if output_fpath:
          if stdout_tx:
              with file_transaction(None, output_fpath) as tx_out_file:
                  if stdout_to_outputfile:
                      cmd += ' > ' + tx_out_file
                  else:
                      cmd += '\n'
                      cmd = cmd.replace(' ' + output_fpath + ' ', ' ' + tx_out_file + ' ') \
                               .replace(' "' + output_fpath + '" ', ' ' + tx_out_file + '" ') \
                               .replace(' \'' + output_fpath + '\' ', ' ' + tx_out_file + '\' ') \
                               .replace(' ' + output_fpath + '\n', ' ' + tx_out_file) \
                               .replace(' "' + output_fpath + '"\n', ' ' + tx_out_file + '"') \
                               .replace(' \'' + output_fpath + '\'\n', ' ' + tx_out_file + '\'') \
                               .replace('\n', '')
                  _try_run(cmd, tx_out_file, input_fpath)
          else:
              _try_run(cmd, output_fpath, input_fpath)
  
      else:
          _try_run(cmd, None, input_fpath)