Exemple #1
0
def _world_from_cwl(fnargs, work_dir):
    """Reconstitute a bcbio world data object from flattened CWL-compatible inputs.

    Converts the flat CWL representation into a nested bcbio world dictionary.

    Handles single sample inputs (returning a single world object) and multi-sample
    runs (returning a list of individual samples to get processed together).
    """
    parallel = None
    output_cwl_keys = None
    runtime = {}
    out = []
    data = {}
    passed_keys = []
    for fnarg in fnargs:
        key, val = fnarg.split("=")
        # extra values pulling in nested indexes
        if key == "ignore":
            continue
        if key == "sentinel-parallel":
            parallel = val
            continue
        if key == "sentinel-runtime":
            runtime = json.loads(val)
            continue
        if key == "sentinel-outputs":
            output_cwl_keys = json.loads(val)
            continue
        # starting a new record -- duplicated key
        if key in passed_keys:
            data["dirs"] = {"work": work_dir}
            data["cwl_keys"] = passed_keys
            data["output_cwl_keys"] = output_cwl_keys
            data = _add_resources(data, runtime)
            data = run_info.normalize_world(data)
            out.append(data)
            data = {}
            passed_keys = []
        passed_keys.append(key)
        key = key.split("__")
        if val.startswith(("{", "[")):
            val = json.loads(val)
        elif val.find(";;") >= 0:
            val = val.split(";;")
        data = _update_nested(key, val, data)
    if data:
        data["dirs"] = {"work": work_dir}
        data["cwl_keys"] = passed_keys
        data["output_cwl_keys"] = output_cwl_keys
        data = _add_resources(data, runtime)
        data = run_info.normalize_world(data)
        out.append(data)
    if parallel in ["single-parallel", "single-merge", "multi-parallel", "multi-combined", "multi-batch",
                    "batch-split", "batch-parallel", "batch-merge", "batch-single"]:
        out = [out]
    else:
        assert len(out) == 1, "%s\n%s" % (pprint.pformat(out), pprint.pformat(fnargs))
    return out, parallel
Exemple #2
0
def _world_from_cwl(fnargs, work_dir):
    """Reconstitute a bcbio world data object from flattened CWL-compatible inputs.

    Converts the flat CWL representation into a nested bcbio world dictionary.

    Handles single sample inputs (returning a single world object) and multi-sample
    runs (returning a list of individual samples to get processed together).
    """
    parallel = None
    runtime = {}
    out = []
    data = {}
    passed_keys = []
    for fnarg in fnargs:
        key, val = fnarg.split("=")
        # extra values pulling in nested indexes
        if key == "ignore":
            continue
        if key == "sentinel-parallel":
            parallel = val
            continue
        if key == "sentinel-runtime":
            runtime = json.loads(val)
            continue
        # starting a new record -- duplicated key
        if key in passed_keys:
            data["dirs"] = {"work": work_dir}
            data["cwl_keys"] = passed_keys
            data = _add_resources(data, runtime)
            data = run_info.normalize_world(data)
            out.append(data)
            data = {}
            passed_keys = []
        passed_keys.append(key)
        key = key.split("__")
        if val.startswith(("{", "[")):
            val = json.loads(val)
        elif val.find(";;") >= 0:
            val = val.split(";;")
        data = _update_nested(key, val, data)
    if data:
        data["dirs"] = {"work": work_dir}
        data["cwl_keys"] = passed_keys
        data = _add_resources(data, runtime)
        data = run_info.normalize_world(data)
        out.append(data)
    if parallel in ["single-parallel", "single-merge", "multi-parallel", "multi-combined", "multi-batch",
                    "batch-split", "batch-parallel", "batch-merge", "batch-single"]:
        out = [out]
    else:
        assert len(out) == 1, "%s\n%s" % (pprint.pformat(out), pprint.pformat(fnargs))
    return out, parallel
Exemple #3
0
def _world_from_cwl(fnargs, work_dir):
    """Reconstitute a bcbio world data object from flattened CWL-compatible inputs.

    Converts the flat CWL representation into a nested bcbio world dictionary.

    Handles single sample inputs (returning a single world object) and multi-sample
    runs (returning a list of individual samples to get processed together).
    """
    multisample = False
    out = []
    data = {}
    passed_keys = []
    for fnarg in fnargs:
        key, val = fnarg.split("=")
        # extra values pulling in nested indexes
        if key == "ignore":
            continue
        if key == "sentinel":
            if val == "multisample":
                multisample = True
            else:
                raise ValueError("Unexpected sentinel %s" % fnarg)
            continue
        # starting a new record -- duplicated key
        if key in passed_keys:
            data["dirs"] = {"work": work_dir}
            # XXX Determine cores and other resources from CWL
            data["config"]["resources"] = {}
            data = run_info.normalize_world(data)
            out.append(data)
            data = {}
            passed_keys = []
        passed_keys.append(key)
        key = key.split("__")
        if val.startswith(("{", "[")):
            val = json.loads(val)
        elif val.find(";;") >= 0:
            val = val.split(";;")
        data = _update_nested(key, val, data)
    if data:
        data["dirs"] = {"work": work_dir}
        # XXX Determine cores and other resources from CWL
        data["config"]["resources"] = {}
        data = run_info.normalize_world(data)
        out.append(data)
    if multisample:
        out = [out]
    else:
        assert len(out) == 1, "%s\n%s" % (pprint.pformat(out), pprint.pformat(fnargs))
    return out, multisample
Exemple #4
0
def _finalize_cwl_in(data, work_dir, passed_keys, output_cwl_keys, runtime):
    """Finalize data object with inputs from CWL.
    """
    data["dirs"] = {"work": work_dir}
    if not tz.get_in(["config", "algorithm"], data):
        if "config" not in data:
            data["config"] = {}
        data["config"]["algorithm"] = {}
    if "rgnames" not in data and "description" in data:
        data["rgnames"] = {"sample": data["description"]}
    data["cwl_keys"] = passed_keys
    data["output_cwl_keys"] = output_cwl_keys
    data = _add_resources(data, runtime)
    data = run_info.normalize_world(data)
    return data
Exemple #5
0
def _finalize_cwl_in(data, work_dir, passed_keys, output_cwl_keys, runtime):
    """Finalize data object with inputs from CWL.
    """
    data["dirs"] = {"work": work_dir}
    if not tz.get_in(["config", "algorithm"], data):
        if "config" not in data:
            data["config"] = {}
        data["config"]["algorithm"] = {}
    if "rgnames" not in data and "description" in data:
        data["rgnames"] = {"sample": data["description"]}
    data["cwl_keys"] = passed_keys
    data["output_cwl_keys"] = output_cwl_keys
    data = _add_resources(data, runtime)
    data = run_info.normalize_world(data)
    return data
Exemple #6
0
def _world_from_cwl(fnargs, work_dir):
    """Reconstitute a bcbio world data object from flattened CWL-compatible inputs.

    Converts the flat CWL representation into a nested bcbio world dictionary.
    """
    data = {}
    for fnarg in fnargs:
        key, val = fnarg.split("=")
        key = key.split("__")
        if val.startswith(("{", "[")):
            val = json.loads(val)
        data = tz.update_in(data, key, lambda x: val)
    data["dirs"] = {"work": work_dir}
    # XXX Determine cores and other resources from CWL
    data["config"]["resources"] = {}
    data = run_info.normalize_world(data)
    return [data]
Exemple #7
0
def _world_from_cwl(fnargs, work_dir):
    """Reconstitute a bcbio world data object from flattened CWL-compatible inputs.

    Converts the flat CWL representation into a nested bcbio world dictionary.
    """
    data = {}
    for fnarg in fnargs:
        key, val = fnarg.split("=")
        key = key.split("__")
        if val.startswith(("{", "[")):
            val = json.loads(val)
        data = tz.update_in(data, key, lambda x: val)
    data["dirs"] = {"work": work_dir}
    # XXX Determine cores and other resources from CWL
    data["config"]["resources"] = {}
    data = run_info.normalize_world(data)
    return [data]