def load(self): import yaml try: config_file_map = yaml.load(open(self.path, 'r')) except: raise Exception("Error importing file - %s , Make" " sure it is in correct yaml format") for page in self.nb.get_page_list(): ctrl_list = page.page.get_ctrl_list() for ctrl in ctrl_list: name = ctrl.get_name() val = config_file_map.get(str(name)) sample_list = ctrl.get_values() s_map = dict((v, k) for k, v in substitution_map.iteritems()) if val: if isinstance(val, list): if ctrl.get_datatype() == 8: value = [] for item in val: data = "" for k, v in item.iteritems(): if v == 1 and k in sample_list: if data: data = data + "," + k else: data = k value.append(data) elif ctrl.get_datatype() == 6: value = [] for v in val: value.append(str(v)) elif ctrl.get_datatype() == 3: value = [ sample_list[i] for i, x in enumerate(val) if x == True ] elif ctrl.get_datatype() == 4: if 1 in val and 0 in val: val = [10] if 'ANTS' in val and 'FSL' in val: val = [11] if '3dAutoMask' in val and 'BET' in val: val = [12] value = [ s_map.get(item) for item in val if s_map.get(item) != None ] if not value: value = [str(item) for item in val] elif ctrl.get_datatype() == 5 and \ ctrl.get_type() == 6: value = [sample_list[v] for v in val] elif ctrl.get_datatype() == 9: value = val[0] # pass the dictionary straight up else: value = None for v in val: if value: value = value + "," + str(v) else: value = str(v) else: if ctrl.get_datatype() == 2 and \ ctrl.get_type() == 0 and \ str(val) not in sample_list: value = sample_list[val] else: value = str(val) else: value = "" ctrl.set_value(value)
def load(self): import yaml try: config_file_map = yaml.load(open(self.path, 'r')) except: raise Exception("Error importing file - %s , Make" " sure it is in correct yaml format") #for config in config_file_map: # print "\n\n config: ", config, " selection: ", config_file_map[config] for page in self.nb.get_page_list(): ctrl_list = page.page.get_ctrl_list() for ctrl in ctrl_list: name = ctrl.get_name() val = config_file_map.get(str(name)) #print "loading ctrl ->", name, "->", val sample_list = ctrl.get_values() #print "sample_list -->", sample_list s_map = dict((v, k) for k, v in substitution_map.iteritems()) if val: if isinstance(val, list): if ctrl.get_datatype() == 8: value = [] for item in val: data = "" for k, v in item.iteritems(): if v == 1 and k in sample_list: if data: data = data + "," + k else: data = k value.append(data) elif ctrl.get_datatype() == 6: value = [] for v in val: value.append(str(v)) elif ctrl.get_datatype() == 3: value = [sample_list[i] for i, x in enumerate(val) if x == True] elif ctrl.get_datatype() == 4: if 1 in val and 0 in val: val = [10] if 'ANTS' in val and 'FSL' in val: val = [11] if '3dAutoMask' in val and 'BET' in val: val = [12] value = [s_map.get(item) for item in val if s_map.get(item) != None] if not value: value = [ str(item) for item in val] elif ctrl.get_datatype() == 5 and ctrl.get_type() == 6: value = [sample_list[v] for v in val] else: value = None for v in val: if value: value = value + "," + str(v) else: value = str(v) else: if ctrl.get_datatype() == 2 and ctrl.get_type() == 0 and\ str(val) not in sample_list: value = sample_list[val] else: value = str(val) else: value = "" #print "setting value in ctrl -->", value #print "type -->", type(value) ctrl.set_value(value)
def load(self): import yaml try: config_file_map = yaml.load(open(self.path, 'r')) except: raise Exception("Error importing file - %s , Make" " sure it is in correct yaml format") #for config in config_file_map: # print "\n\n config: ", config, " selection: ", config_file_map[config] for page in self.nb.get_page_list(): ctrl_list = page.page.get_ctrl_list() for ctrl in ctrl_list: name = ctrl.get_name() val = config_file_map.get(str(name)) #print "loading ctrl ->", name, "->", val sample_list = ctrl.get_values() #print "sample_list -->", sample_list s_map = dict((v, k) for k, v in substitution_map.iteritems()) if val: if isinstance(val, list): if ctrl.get_datatype() == 8: value = [] for item in val: data = "" for k, v in item.iteritems(): if v == 1 and k in sample_list: if data: data = data + "," + k else: data = k value.append(data) elif ctrl.get_datatype() == 6: value = [] for v in val: value.append(str(v)) elif ctrl.get_datatype() == 3: value = [ sample_list[i] for i, x in enumerate(val) if x == True ] elif ctrl.get_datatype() == 4: if 1 in val and 0 in val: val = [10] if 'ANTS' in val and 'FSL' in val: val = [11] value = [ s_map.get(item) for item in val if s_map.get(item) != None ] if not value: value = [str(item) for item in val] elif ctrl.get_datatype() == 5 and ctrl.get_type() == 6: value = [sample_list[v] for v in val] else: value = None for v in val: if value: value = value + "," + str(v) else: value = str(v) else: if ctrl.get_datatype() == 2 and ctrl.get_type() == 0 and\ str(val) not in sample_list: value = sample_list[val] else: value = str(val) else: value = "" #print "setting value in ctrl -->", value #print "type -->", type(value) ctrl.set_value(value)