Run dcm2niix on input file
326250
def convert(input, output):
    '''
    
    '''
    dirname = os.path.dirname(output)
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    basename = os.path.basename(output)
    basename = re.sub('.nii(.gz)?', '', basename)
    dcm2niix = commons.which('dcm2niix')
    cmd = [
        'dcm2niix',
        '-s', 'y',
        '-b', 'y',
        '-z', 'y',
        '-f', basename,
        '-o', dirname,
        input
    ]
    logger.debug(cmd)
    sp.check_output(cmd)
640538
def cl_input(cls, filename, unpack=True, anonpipe=True):
        
        command, prog = cls._download_cl(filename)
        if prog == "awscli":
            command.append("-")

        command = " ".join(command)
        if filename.endswith(".gz") and unpack:
            command = "%(command)s | gunzip -c" % {"command": command}
        elif filename.endswith(".bz2") and unpack:
            command = "%(command)s | bunzip2 -c" % {"command": command}
        if anonpipe:
            command = "<(%(command)s)" % {"command": command}

        return command
370485
def main(argv=None):
    """"""
    global Verbose
    global EncodeUtf8
    global csvOutput
    if argv is None:
        argv = sys.argv

    if (len(argv) < 3 and not (('-h' in argv) or ('--help' in argv))):
        log.exception('Bad args')
        raise TikaException('Bad args')
    try:
        opts, argv = getopt.getopt(argv[1:], 'hi:s:o:p:v:e:c',
          ['help', 'install=', 'server=', 'output=', 'port=', 'verbose', 'encode', 'csv'])
    except getopt.GetoptError as opt_error:
        msg, bad_opt = opt_error
        log.exception("%s error: Bad option: %s, %s" % (argv[0], bad_opt, msg))
        raise TikaException("%s error: Bad option: %s, %s" % (argv[0], bad_opt, msg))

    tikaServerJar = TikaServerJar
    serverHost = ServerHost
    outDir = '.'
    port = Port
    for opt, val in opts:
        if opt   in ('-h', '--help'):    echo2(USAGE); sys.exit()
        elif opt in ('--install'):       tikaServerJar = val
        elif opt in ('--server'):        serverHost = val
        elif opt in ('-o', '--output'):  outDir = val
        elif opt in ('--port'):          port = val
        elif opt in ('-v', '--verbose'): Verbose = 1
        elif opt in ('-e', '--encode'): EncodeUtf8 = 1
        elif opt in ('-c', '--csv'): csvOutput = 1
        else:
            raise TikaException(USAGE)

    cmd = argv[0]
    option = argv[1]
    try:
        paths = argv[2:]
    except:
        paths = None
    return runCommand(cmd, option, paths, port, outDir, serverHost=serverHost, tikaServerJar=tikaServerJar, verbose=Verbose, encode=EncodeUtf8)
406918
function UI (input, output) {
  this.rl = readline.createInterface({
    input: input || ttys.stdin,
    output: output || ttys.stdout
  })
  
  // Delegated events bind.
  this.onLine = (function onLine () {
    _events.line.apply(this, arguments)
  }).bind(this)
  
  this.onKeypress = (function onKeypress () {
    if (this.rl) {
      _events.keypress.apply(this, arguments)
    }
  }).bind(this)
  
  this.forceClose = this.forceClose.bind(this)
  
  this.rl.addListener('line', this.onLine)
  this.rl.input.addListener('keypress', this.onKeypress)
  
  this.rl.on('SIGINT', this.forceClose)
  process.on('exit', this.forceClose)
}
13692
def run(configobj=None):
    
    acscte(configobj['input'],
           exec_path=configobj['exec_path'],
           time_stamps=configobj['time_stamps'],
           verbose=configobj['verbose'],
           quiet=configobj['quiet'],
           single_core=configobj['single_core']
           )
649985
def run(self):
        '''
        
        '''
        qry = os.path.abspath(self.qry)
        ref = os.path.abspath(self.ref)
        outfile = os.path.abspath(self.outfile)
        tmpdir = tempfile.mkdtemp(prefix='tmp.run_nucmer.', dir=os.getcwd())
        original_dir = os.getcwd()
        os.chdir(tmpdir)
        script = 'run_nucmer.sh'
        self._write_script(script, ref, qry, outfile)
        syscall.run('bash ' + script, verbose=self.verbose)
        os.chdir(original_dir)
        shutil.rmtree(tmpdir)
1354632
def run(bam_file, sample, out_dir):
    """"""
    out = {}
    # if "rchipqc" in dd.get_tools_on(sample):
    #    out = chipqc(bam_file, sample, out_dir)

    peaks = sample.get("peaks_files", {}).get("main")
    if peaks:
        out.update(_reads_in_peaks(bam_file, peaks, sample))
    return out
61807
def handle_input(self, ncode, wparam, lparam):
        """"""
        value = WIN_KEYBOARD_CODES[wparam]
        scan_code = lparam.contents.scan_code
        vk_code = lparam.contents.vk_code
        self.update_timeval()

        events = []
        # Add key event
        scan_key, key_event = self.emulate_press(
            vk_code, scan_code, value, self.timeval)
        events.append(scan_key)
        events.append(key_event)

        # End with a sync marker
        events.append(self.sync_marker(self.timeval))

        # We are done
        self.write_to_pipe(events)

        return ctypes.windll.user32.CallNextHookEx(
            self.hooked, ncode, wparam, lparam)
159807
def _post_run_hook(self, runtime):
        '''  '''

        assert len(self.inputs.mask_files) == 1, \
            "ACompCorRPT only supports a single input mask. " \
            "A list %s was found." % self.inputs.mask_files
        self._anat_file = self.inputs.realigned_file
        self._mask_file = self.inputs.mask_files[0]
        self._seg_files = self.inputs.mask_files
        self._masked = False

        NIWORKFLOWS_LOG.info('Generating report for aCompCor. file "%s", mask "%s"',
                             self.inputs.realigned_file, self._mask_file)

        return super(ACompCorRPT, self)._post_run_hook(runtime)
58639
def runctx(cmd, globals, locals, filename=None, threads=True, verbose=False):
    """"""
    _run(threads, verbose, 'runctx', filename, cmd, globals, locals)
658846
def run_interactive(
        source_x, source_o, timeout=None, memlimit=None, cgroup=None,
        cgroup_path=None):
    

    msg = msgpack.packb([source_x, source_o])
    run_lua = os.path.join(os.path.dirname(__file__), 'run.lua')
    server = [os.getenv("LUA", "lua"), run_lua, '--server']
    args = dict(bufsize=0xffff, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

    if timeout is not None:
        server = ['timeout', '%.3f' % timeout] + server

    with limit_ram(memlimit, cgroup, cgroup_path) as cg:
        if cg is not None:
            server = ['cgexec', '-g', cg] + server

        with subprocess.Popen(server, **args) as f:
            send_payload(f.stdin, msg)
            xo, stop = 'o', False
            while not stop:
                msg = get_payload(f.stdout)
                if msg == b'':
                    xo = flip(xo)  # because bad thing happened during next exec
                    f.wait()  # it has to shutdown properly first
                    if f.returncode == 124:
                        yield xo, ('error', "timeout"), ""
                    else:
                        errmsg = "probably OOM (%d)" % f.returncode
                        yield xo, ('error', errmsg), ""
                    stop = True
                else:
                    [xo, moveresult, log] = msgpack.unpackb(msg)
                    xo, log = xo.decode('utf8'), log.decode('utf8')
                    if moveresult[0] == b'error':
                        yield xo, ('error', moveresult[1].decode('utf8')), ""
                        stop = True
                    elif moveresult[0] == b'state_coords':
                        state = moveresult[1][0].decode('utf8')
                        coords = moveresult[1][1]
                        if state == 'draw' or state == 'x' or state == 'o':
                            stop = True
                        yield xo, ['state_coords', [state, coords]], ""
811338
def run(self, cmd):
        """"""
        import __main__
        dict = __main__.__dict__
        return self.runctx(cmd, dict, dict)
1312848
def run(ctx, commandline):
    """"""
    file = ctx.obj['FILE']
    dotenv_as_dict = dotenv_values(file)
    if not commandline:
        click.echo('No command given.')
        exit(1)
    ret = run_command(commandline, dotenv_as_dict)
    exit(ret)
244559
def _init_from_file(self, filename):
        """"""
        if not filename.endswith("detx"):
            raise NotImplementedError('Only the detx format is supported.')
        self._open_file(filename)
        self._extract_comments()
        self._parse_header()
        self._parse_doms()
        self._det_file.close()
645017
def main(ctx, **kwargs):
    
    in_format = kwargs.pop('in_format')
    out_format = kwargs.pop('out_format') or kwargs.pop('out_flag')
    no_flip = kwargs.pop('no_flip')
    clean = kwargs.pop('clean')
    long_form = kwargs.pop('long')
    input_file = kwargs.pop('input')
    output_file = kwargs.pop('output')

    if not in_format:
        if input_file.name.endswith(".json"):
            in_format = "json"
        elif input_file.name.endswith(".yaml") or input_file.name.endswith(".yml"):
            in_format = "yaml"

    if input_file.name == "<stdin>" and sys.stdin.isatty():
        click.echo(ctx.get_help())
        ctx.exit()

    try:
        output_file.write(flip(
            input_file.read(),
            in_format=in_format,
            out_format=out_format,
            clean_up=clean,
            no_flip=no_flip,
            long_form=long_form
        ))
    except Exception as e:
        raise click.ClickException("{}".format(e))
1206495
def run_command(self, input_file, output_dir=None):
        
        base_name = os.path.basename(input_file)
        name, suffix = base_name.split('.', 1)
        output_file = '{}{}.tif'.format(name, self.split_pattern)
        if output_dir:
            output_file = os.path.join(output_dir, output_file)
        return ['bfconvert', input_file, output_file]
837432
function readInput(cb, filename) {

    function readFile() {
      fs.readFile(filename, 'utf8', function (err, text) {
        if (err) {
          console.error("[ERROR] couldn't read from '" + filename + "':");
          console.error(err.message);
          return;
        }

        cb(err, text);
      });
    }

    function readStdin() {
      var text = ''
        , stdin = process.stdin
        ;

      stdin.resume();

      stdin.on('data', function (chunk) {
        text += chunk;
      });

      stdin.on('end', function () {
        cb(null, text);
      });
    }

    if (filename) {
      readFile();
    }
    else {
      readStdin();
    }

  }