import sys from bcbio import install, workflow from bcbio.illumina import machine from bcbio.distributed import runfn from bcbio.pipeline.main import run_main, parse_cl_args from bcbio.server import main as server_main from bcbio.provenance import programs import pdb def main(**kwargs): run_main(**kwargs) if __name__ == "__main__": kwargs = parse_cl_args(sys.argv[1:]) if "upgrade" in kwargs and kwargs["upgrade"]: install.upgrade_bcbio(kwargs["args"]) elif "server" in kwargs and kwargs["server"]: server_main.start(kwargs["args"]) elif "runfn" in kwargs and kwargs["runfn"]: runfn.process(kwargs["args"]) elif "version" in kwargs and kwargs["version"]: programs.write_versions({"work": kwargs["args"].workdir}) elif "sequencer" in kwargs and kwargs["sequencer"]: machine.check_and_postprocess(kwargs["args"]) else: if kwargs.get("workflow"): setup_info = workflow.setup(kwargs["workflow"], kwargs.pop("inputs")) if setup_info is None: # no automated run after setup sys.exit(0)
for xs in run_info["details"]: for x in xs: names.append(x.get("name", (x["lane"], x["barcode_id"]))) return len(set(names)) def _upgrade_bcbio(method): """Perform upgrade of bcbio to latest release, or from GitHub development version. """ url = "https://raw.github.com/chapmanb/bcbio-nextgen/master/requirements.txt" git_repo = "git://github.com/chapmanb/bcbio-nextgen.git" pip_bin = os.path.join(os.path.dirname(sys.executable), "pip") if method in ["stable", "system"]: sudo_cmd = [] if method == "stable" else ["sudo"] subprocess.check_call(sudo_cmd + [pip_bin, "install", "--upgrade", "distribute"]) subprocess.check_call(sudo_cmd + [pip_bin, "install", "-r", url]) else: subprocess.check_call([pip_bin, "install", "--upgrade", "git+%s#egg=bcbio-nextgen" % git_repo]) if __name__ == "__main__": config_file, kwargs = parse_cl_args(sys.argv[1:]) kwargs["config_file"] = config_file if kwargs["upgrade"] and config_file is None: _upgrade_bcbio(kwargs["upgrade"]) else: if kwargs["workflow"]: workdir, new_kwargs = workflow.setup(kwargs["workflow"], kwargs["inputs"]) os.chdir(workdir) kwargs.update(new_kwargs) main(**kwargs)
numcores = 1 else: numcores = _needed_workers( get_run_info(fc_dir, config, run_info_yaml)[-1]) return paralleltype, int(numcores) def _needed_workers(run_info): """Determine workers needed to run multiplex flowcells in parallel. """ names = [] for xs in run_info["details"]: for x in xs: names.append(x.get("name", (x["lane"], x["barcode_id"]))) return len(set(names)) if __name__ == "__main__": kwargs = parse_cl_args(sys.argv[1:]) if kwargs["upgrade"]: install.upgrade_bcbio(kwargs["args"]) else: if kwargs["workflow"]: setup_info = workflow.setup(kwargs["workflow"], kwargs["inputs"]) if setup_info is None: # no automated run after setup sys.exit(0) workdir, new_kwargs = setup_info os.chdir(workdir) kwargs.update(new_kwargs) main(**kwargs)
def _needed_workers(run_info): """Determine workers needed to run multiplex flowcells in parallel. """ names = [] for xs in run_info["details"]: for x in xs: names.append(x.get("name", (x["lane"], x["barcode_id"]))) return len(set(names)) def _upgrade_bcbio(method): """Perform upgrade of bcbio to latest release, or from GitHub development version. """ url = "https://raw.github.com/chapmanb/bcbb/master/nextgen/requirements.txt" pip_bin = os.path.join(os.path.dirname(sys.executable), "pip") if method in ["stable", "system"]: sudo_cmd = [] if method == "stable" else ["sudo"] subprocess.check_call(sudo_cmd + [pip_bin, "install", "--upgrade", "distribute"]) subprocess.check_call(sudo_cmd + [pip_bin, "install", "-r", url]) else: raise NotImplementedError("Development upgrade") if __name__ == "__main__": config_file, kwargs = parse_cl_args(sys.argv[1:]) if kwargs["upgrade"] and config_file is None: _upgrade_bcbio(kwargs["upgrade"]) else: main(config_file, **kwargs)