def test_colorspiral(self): """ Set of 625 colours, with jitter, using get_colors().""" boxedge = 20 boxes_per_row = 25 rows = 0 for i, c in enumerate(get_colors(625)): self.c.setFillColor(c) x1 = boxedge * (i % boxes_per_row) y1 = rows * boxedge self.c.rect(x1, y1, boxedge, boxedge, fill=1, stroke=0) if not (i + 1) % boxes_per_row: rows += 1 self.finish()
def test_colorspiral(self): """ Set of 625 colours, with jitter, using get_colors().""" boxedge = 20 boxes_per_row = 25 rows = 0 for i, c in enumerate(get_colors(625)): self.c.setFillColor(c) x1 = boxedge * (i % boxes_per_row) y1 = rows * boxedge self.c.rect(x1, y1, boxedge, boxedge, fill=1, stroke=0) if not (i+1) % boxes_per_row: rows += 1 self.finish()
# Convenience function for getting feature locations def get_ft_loc(org, ft): for f in records[org].features: if f.type == "CDS" and f.qualifiers["locus_tag"][0] == str(ft): return f.location.nofuzzy_start, f.location.nofuzzy_end # Get data for crosslinks from i-ADHoRe results data = IadhoreData( os.path.join("dickeya_all_output_params2", "multiplicons.txt"), os.path.join("dickeya_all_output_params2", "segments.txt"), ) full_leaves = data.get_multiplicons_at_level(29) region_colours = list(get_colors(len(full_leaves), a=5, b=0.33, jitter=0.25)) for midx, m in enumerate(full_leaves): segments = data.get_multiplicon_segments(m) # Loop over the pairs of consecutive genomes in the table, and add # crosslinks for multiplicons print "Cross-linking multiplicon %d" % m for idx in range(1, len(orgs)): org1, org2 = orgs[idx - 1], orgs[idx] org1loc = list(chain.from_iterable([get_ft_loc(org1, f) for f in segments[org1]])) org2loc = list(chain.from_iterable([get_ft_loc(org2, f) for f in segments[org2]])) org1ft = (tracks[org1], min(org1loc), max(org1loc)) org2ft = (tracks[org2], min(org2loc), max(org2loc)) # Need to create a colour rather than pass a tuple - unlike features. # Raise this bug in Biopython! c = colors.Color(region_colours[midx][0], region_colours[midx][1], region_colours[midx][2]) crosslink = gd.CrossLink(org1ft, org2ft, c)
regionsets[org] = tracks[org].new_set(name="collinear regions") # Convenience function for getting feature locations def get_ft_loc(org, ft): for f in records[org].features: if f.type == 'CDS' and f.qualifiers['locus_tag'][0] == str(ft): return f.location.nofuzzy_start, f.location.nofuzzy_end # Get data for crosslinks from i-ADHoRe results data = IadhoreData(os.path.join('dickeya_all_output_params2', 'multiplicons.txt'), os.path.join('dickeya_all_output_params2', 'segments.txt')) full_leaves = data.get_multiplicons_at_level(29) region_colours = list(get_colors(len(full_leaves), a=5, b=0.33, jitter=0.25)) for midx, m in enumerate(full_leaves): segments = data.get_multiplicon_segments(m) # Loop over the pairs of consecutive genomes in the table, and add # crosslinks for multiplicons print "Cross-linking multiplicon %d" % m for idx in range(1, len(orgs)): org1, org2 = orgs[idx-1], orgs[idx] org1loc = list(chain.from_iterable([get_ft_loc(org1, f) for f in segments[org1]])) org2loc = list(chain.from_iterable([get_ft_loc(org2, f) for f in segments[org2]])) org1ft = (tracks[org1], min(org1loc), max(org1loc)) org2ft = (tracks[org2], min(org2loc), max(org2loc)) # Need to create a colour rather than pass a tuple - unlike features. # Raise this bug in Biopython!