def finish(project): log = task.logger conf = task.conf project_id = project["id"] log.info("Cleaning project {0} ...".format(project_id)) projres = ProjectResults(project) projres.clean(conf) # save project.conf projres.save_def()
def make_project(log, conf, project, base_path=None): project_id = project["id"] project_path = get_project_path(conf, project_id) if not os.path.exists(project_path): os.makedirs(project_path) temp_path = get_temp_path(conf, project_id) if not os.path.exists(temp_path): os.makedirs(temp_path) projdb_path = os.path.join(project_path, "project.db") if "annotations" in project: annotations = project["annotations"] if not isinstance(annotations, dict): log.warn("Overriding project annotations field with an empty dictionary") project["annotations"] = annotations = {} else: project["annotations"] = annotations = {} for key in project.keys(): if key not in ["id", "assembly", "files", "annotations", "oncodriveclust", "oncodrivefm"]: value = project[key] del project[key] annotations[key] = value project["path"] = project_path project["temp_path"] = temp_path project["db"] = projdb_path if "assembly" not in project: project["assembly"] = "hg19" files = project["files"] # make absolute paths if necessary if base_path is not None: for i, file in enumerate(files): if not os.path.isabs(file): files[i] = os.path.join(base_path, file) missing_files = [] # copy variants files into project path for i, file in enumerate(files): file_base_name = os.path.basename(file) if not os.path.dirname(file).startswith(project_path): dst_name = "{0:02d}-{1}".format(i, file_base_name) dst_path = os.path.join(project_path, dst_name) log.info(" {0} --> {1}".format(file_base_name, dst_name)) if os.path.exists(file): shutil.copy(file, dst_path) files[i] = dst_path else: missing_files += [file] else: log.info(" {0}".format(file_base_name)) if len(missing_files) > 0: raise Exception("Project {0} references some missing files:\n{1}".format(project_id, "\n".join(missing_files))) # save project.conf projres = ProjectResults(project) projres.save_def()