def yield_karyotype(self, karyotype): assert self.level == 1, "Karyotype file can only be built for the top level." line = ['chr','-','c_c','Cell_Communication','0','725', 'spectral-5-div-1'] ### if there s only one chromosome create a hypothetical one ##### very unpythonic but it's too late to quench the root of the circular import evil. from pacfm.controller import CircosConfigParser ccp= CircosConfigParser("conf") ccp.parse() chromosomes= [] for chromosome in self.chromosomes: name= chromosome.name line[2] = karyotype[name] line[3] = name.replace(' ','_') line[5] = str(chromosome.get_end()) chromosomes.append(karyotype[name]) yield "\t".join(line)+ "\n" if len(self.chromosomes) == 1: name= "Hypothetical" abbr= "h" end= "2" line[2]= abbr line[3]= name line[5]= end chromosomes.append(abbr) yield "\t".join(line) +"\n" ccp.set("chromosomes", ";".join(chromosomes)) ccp.write()
def dump(self): ### very unpythonic from pacfm.controller import CircosConfigParser pickle.dump(self.items, open(self.dmp_file,'w')) parser= CircosConfigParser('plots') parser.parse() for plot in self.items: parser.set('type', plot.plot_type, 'plot', 'index', 'plot_%s'%plot.level) parser.set('color', plot.color_scheme, 'plot', 'index', 'plot_%s'%plot.level) color=plot.color if color is not None: color= list(color) if len(color) == 4: color= list(color) color[3] = 1- (color[3] / 255.0) color= ','.join(map(str, color)) parser.set('fill_color',color, 'plot', 'index', 'plot_%s'%plot.level) parser.set('min', plot.min_value, 'plot', 'index', 'plot_%s'%plot.level) parser.set('max', plot.max_value, 'plot', 'index', 'plot_%s'%plot.level)