def generate_project_kernel(project, cluster_json=None): """ run graph kernel computation """ out_dir = dot.dot_dirs(project)[0] print("Generating kernel for {0} with dot files in {1}.".format(project, out_dir)) kernel_file_path = dot.get_kernel_path(project, out_dir) if cluster_json: print("Using clustering output for node relabeling:") graph_kernel_cmd = ['python', common.get_simprog('precompute_kernel.py'), os.path.join(dot.dot_dir(project), out_dir), kernel_file_path, cluster_json ] common.run_cmd(graph_kernel_cmd, True) else: graph_kernel_cmd = ['python', common.get_simprog('precompute_kernel.py'), os.path.join(dot.dot_dir(project), out_dir), kernel_file_path ] common.run_cmd(graph_kernel_cmd, True) print("Generated kernel file for {0} in {1}.".format(project, kernel_file_path))
def generate_project_kernel(project, cluster_json=None): """ run graph kernel computation """ project_dir = common.get_project_dir(project) dot_dirs = dot.dot_dirs(project) if not dot_dirs: print("No graphs generated for {}".format(project)) return out_dir = dot_dirs[0] kernel_file_path = dot.get_kernel_path(project, out_dir) if cluster_json: graph_kernel_cmd = [ 'python', common.get_simprog('precompute_kernel.py'), project_dir, kernel_file_path, cluster_json ] common.run_cmd(graph_kernel_cmd, 'graphkernel') else: graph_kernel_cmd = [ 'python', common.get_simprog('precompute_kernel.py'), project_dir, kernel_file_path ] common.run_cmd(graph_kernel_cmd, 'graphkernel')
def gather_kernels(projects, corpus_kernel_file): print("Gathering kernels from projects {0}".format(" and ".join(projects))) with open(corpus_kernel_file, "w") as corpus_kernel_file_handle: for project in projects: project_dir = common.get_project_dir(project) out_dir = dot.dot_dirs(project)[0] # only consider the first one project_kernel_file_path = dot.get_kernel_path(project, out_dir) if os.path.isfile(project_kernel_file_path): with open(project_kernel_file_path, "r") as fi: corpus_kernel_file_handle.write(fi.read()) else: print ("No kernel file find for project {0}.\n {1} is not a file.".format( project, project_kernel_file_path ))