def run_output(self): targets = input( "Search for config files for (a)ll or (s)elect targets:\n") path = self.get_path() if targets.lower() == ("a" or "all"): self.search_configfiles(path) elif targets.lower() == ("s" or "select"): targets = Input().targetinput() while (targets == "help" or targets == "" or targets is None): targets = Input().helpmessage(targets) self.targets = Input().parse_targets(targets) for target in self.targets: configpath = os.path.join(path, target, "config", "config.json") if os.path.isfile(configpath): self.config_paths.append(configpath) else: info = ("No configuration files found for " + target + " in specified path") print(info) G.logger(info) return self.run_output() else: print("no valid input: choose (a)ll or (s)elect") sys.exit() for index, target in enumerate(self.targets): config_path = self.config_paths[index] self.read_config(target, config_path) return self.config_dict
def search_configfiles(self, path): print("Search in " + path) for root, dirs, files in os.walk(path): for file_name in files: if "config.json" == file_name: file_path = os.path.join(root, file_name) print("found:", file_path) G.logger("> Found config file: " + file_path) target = "/".join(root.split("/")[-2:-1]) abbr = H.abbrev(target, dict_path) primer_csv = os.path.join(path, "Summary", target, abbr + "_primer.csv") if not os.path.isfile(primer_csv): self.targets.append(target) self.config_paths.append(file_path) else: G.logger("> Skip run found results for " + target) return self.targets, self.config_paths
def read_config(self, target, config_path): self.config_dict.update({target: {}}) with open(config_path, "r") as f: for line in f: self.config_dict[target] = json.loads(line) # new 20.11.2018 # make old config files compatible with the updated pipeline for key in self.default_dict: try: self.config_dict[target][key] except KeyError: self.config_dict[target].update({key: self.default_dict[key]}) info1 = ("Warning! new option " + str(key) + " was not found in config file") info2 = ("Used default value: " + str(key) + " = " + str(self.default_dict[key])) print("\n" + info1 + "\n") print("\n" + info2 + "\n") G.logger(info1) G.logger(info2)
def run_gui_output(self, targets, path): if targets is None: self.search_configfiles(path) else: self.targets = Input().parse_targets(targets) for target in self.targets: configpath = os.path.join(path, target, "config", "config.json") if os.path.isfile(configpath): self.config_paths.append(configpath) else: self.config_paths.append('None') info = ("No configuration files found for " + target + " in specified path") print(info) G.logger(info) for index, target in enumerate(self.targets): config_path = self.config_paths[index] if not config_path == 'None': self.read_config(target, config_path) return self.config_dict