def _start_processing(dname, sample_file, config):
    """Initiate processing: on a remote server or locally on a cluster.
    """
    to_remote = _remap_dirname(dname, os.path.join(utils.get_in(config, ("process", "dir")),
                                                   os.path.basename(dname)))
    args = {"work_dir": to_remote(os.path.join(dname, "analysis")),
            "run_config": to_remote(sample_file),
            "fc_dir": to_remote(dname)}
    # call a remote server
    if utils.get_in(config, ("process", "server")):
        print("%s/run?args=%s" % (utils.get_in(config, ("process", "server")), json.dumps(args)))
        requests.get(url="%s/run" % utils.get_in(config, ("process", "server")),
                     params={"args": json.dumps(args)})
    # submit to a cluster scheduler
    elif "submit_cmd" in config["process"] and "bcbio_batch" in config["process"]:
        with utils.chdir(utils.safe_makedir(args["work_dir"])):
            batch_script = "submit_bcbio.sh"
            with open(batch_script, "w") as out_handle:
                out_handle.write(config["process"]["bcbio_batch"].format(fcdir=args["fc_dir"],
                                                                         run_config=args["run_config"]))
            submit_cmd = utils.get_in(config, ("process", "submit_cmd"))
            subprocess.check_call(submit_cmd.format(batch_script=batch_script), shell=True)
    else:
        raise ValueError("Unexpected processing approach: %s" % config["process"])
def _start_processing ( dname , sample_file , config ) : to_remote = _remap_dirname ( dname , os . path . join ( utils . get_in ( config , ( "process" , "dir" ) ) , os . path . basename ( dname ) ) ) args = { "work_dir" : to_remote ( os . path . join ( dname , "analysis" ) ) , "run_config" : to_remote ( sample_file ) , "fc_dir" : to_remote ( dname ) } if utils . get_in ( config , ( "process" , "server" ) ) : print ( "%s/run?args=%s" % ( utils . get_in ( config , ( "process" , "server" ) ) , json . dumps ( args ) ) ) requests . get ( url = "%s/run" % utils . get_in ( config , ( "process" , "server" ) ) , params = { "args" : json . dumps ( args ) } ) elif "submit_cmd" in config [ "process" ] and "bcbio_batch" in config [ "process" ] : with utils . chdir ( utils . safe_makedir ( args [ "work_dir" ] ) ) : batch_script = "submit_bcbio.sh" with open ( batch_script , "w" ) as out_handle : out_handle . write ( config [ "process" ] [ "bcbio_batch" ] . format ( fcdir = args [ "fc_dir" ] , run_config = args [ "run_config" ] ) ) submit_cmd = utils . get_in ( config , ( "process" , "submit_cmd" ) ) subprocess . check_call ( submit_cmd . format ( batch_script = batch_script ) , shell = True ) else : raise ValueError ( "Unexpected processing approach: %s" % config [ "process" ] )
Initiate processing: on a remote server or locally on a cluster.