def ly_condensed_alg(self, node): if node.is_leaf(): if 'sequence' in node.features: seqFace = SeqMotifFace(node.sequence, [], intermotif_format="line", seqtail_format="line", scale_factor=1) add_face_to_node(seqFace, node, 10, aligned=True)
def ly_leaf_names(node): if node.is_leaf(): spF = TextFace(node.species, fsize=10, fgcolor='#444444', fstyle='italic', ftype='Helvetica') add_face_to_node(spF, node, column=0, position='branch-right') if hasattr(node, 'genename'): geneF = TextFace(" (%s)" %node.genename, fsize=8, fgcolor='#777777', ftype='Helvetica') add_face_to_node(geneF, node, column=1, position='branch-right')
def ly_block_alg(node): if node.is_leaf(): if 'sequence' in node.features: seqFace = SeqMotifFace(node.sequence, []) # [10, 100, "[]", None, 10, "black", "rgradient:blue", "arial|8|white|domain Name"], motifs = [] last_lt = None for c, lt in enumerate(node.sequence): if lt != '-': if last_lt is None: last_lt = c if c+1 == len(node.sequence): start, end = last_lt, c motifs.append([start, end, "()", 0, 12, "slategrey", "slategrey", None]) last_lt = None elif lt == '-': if last_lt is not None: start, end = last_lt, c-1 motifs.append([start, end, "()", 0, 12, "grey", "slategrey", None]) last_lt = None seqFace = SeqMotifFace(node.sequence, motifs, intermotif_format="line", seqtail_format="line", scale_factor=ALG_SCALE) add_face_to_node(seqFace, node, ALG_START_COL, aligned=True)
def ly_tax_labels(node): if node.is_leaf(): c = LABEL_START_COL largest = 0 for tname in TRACKED_CLADES: if hasattr(node, "named_lineage") and tname in node.named_lineage: linF = TextFace(tname, fsize=10, fgcolor='white') linF.margin_left = 3 linF.margin_right = 2 linF.background.color = lin2color[tname] add_face_to_node(linF, node, c, position='aligned') c += 1 for n in xrange(c, len(TRACKED_CLADES)): add_face_to_node(TextFace('', fsize=10, fgcolor='slategrey'), node, c, position='aligned') c+=1
def ly_tax_labels(self, node): if node.is_leaf(): c = self.LABEL_START_COL node_lin = getattr(node, "named_lineage", []) for tname in node_lin: if tname.lower() in self.TRACKED_CLADES: linF = self.LIN2FACE[tname.lower()] # linF = TextFace(tname, fsize=10, fgcolor='white') # linF.margin_left = 3 # linF.margin_right = 2 # linF.background.color = self.LIN2COLOR[tname.lower()] add_face_to_node(linF, node, c, position='aligned') c += 1 for n in xrange(c, len(self.TRACKED_CLADES)): add_face_to_node(TextFace('', fsize=10, fgcolor='slategrey'), node, c, position='aligned') c+=1
def ly_basic(node): if node.is_leaf(): node.img_style['size'] = 0 else: node.img_style['size'] = 0 node.img_style['shape'] = 'square' if len(MIXED_RES) > 1 and hasattr(node, "tree_seqtype"): if node.tree_seqtype == "nt": node.img_style["bgcolor"] = "#CFE6CA" ntF = TextFace("nt", fsize=6, fgcolor='#444', ftype='Helvetica') add_face_to_node(ntF, node, 10, position="branch-bottom") if len(NPR_TREES) > 1 and hasattr(node, "tree_type"): node.img_style['size'] = 4 node.img_style['fgcolor'] = "steelblue" node.img_style['hz_line_width'] = 1 node.img_style['vt_line_width'] = 1
def ly_block_alg(self, node): if node.is_leaf(): if 'sequence' in node.features: # [10, 100, "[]", None, 10, "black", "rgradient:blue", "arial|8|white|domain Name"], motifs = [] last_lt = None for c, lt in enumerate(node.sequence): if lt != '-': if last_lt is None: last_lt = c if c+1 == len(node.sequence): start, end = last_lt, c motifs.append([start, end, "()", 0, 12, "slategrey", "slategrey", None]) last_lt = None elif lt == '-': if last_lt is not None: start, end = last_lt, c-1 motifs.append([start, end, "()", 0, 12, "grey", "slategrey", None]) last_lt = None seqFace = SeqMotifFace(node.sequence, motifs, intermotif_format="line", seqtail_format="line", scale_factor=1) add_face_to_node(seqFace, node, 10, aligned=True)
def rotation_layout(node): if node.is_leaf(): F = TextFace(node.name, tight_text=True) F.rotation = randint(0, 360) add_face_to_node(TextFace("third" ), node, column=8, position="branch-right") add_face_to_node(TextFace("second" ), node, column=2, position="branch-right") add_face_to_node(F, node, column=0, position="branch-right") F.border.width = 1 F.inner_border.width = 1
def ly_leaf_names(self, node): if node.is_leaf(): if node.species != 0 and self.ncbitaxa: spF = TextFace("%s" %getattr(node, "spname", ""), fsize=8, fgcolor='#777777', ftype='Helvetica') geneF = TextFace("(%s)" %node.name[:50], fsize=10, fgcolor='#444444', fstyle='italic', ftype='Helvetica') add_face_to_node(spF, node, column=0, position='branch-right') add_face_to_node(geneF, node, column=1, position='branch-right') else: geneF = TextFace("%s" %node.name, fsize=8, fgcolor='#777777', ftype='Helvetica') add_face_to_node(geneF, node, column=0, position='branch-right')
def layout(node): if node.is_leaf(): seqFace = SeqMotifFace(seq, motifs, scale_factor=1) add_face_to_node(seqFace, node, 0, position="aligned")
def ly_supports(self, node): if not node.is_leaf(): supFace = TextFace("%0.3g" %(node.support), fsize=7, fgcolor='indianred') add_face_to_node(supFace, node, column=0, position='branch-top')
def ly(node): node.img_style['vt_line_width'] = 1 node.img_style['hz_line_width'] = 1 if node.is_leaf(): add_face_to_node(TextFace( ' (%s)' % node.name.split()[0].replace("/exon2", ""), fsize=10, fgcolor='slategrey', tight_text=False), node, 1, position='branch-right') add_face_to_node(TextFace(node.species, fsize=12, fgcolor='black', fstyle='italic', tight_text=False), node, 0, position='branch-right') c = 1 for tname in tracked_clades: if tname in node.named_lineage: linF = TextFace(tname, fsize=10, fgcolor='white') linF.margin_left = 3 linF.background.color = lin2color[tname] add_face_to_node(linF, node, c, position='aligned') c += 1 for n in xrange(1, 20 - (c - 1)): add_face_to_node(TextFace('', fsize=10, fgcolor='slategrey'), node, c, position='aligned') c += 1 if draw_alg and 'sequence' in node.features: #seqFace = SequenceFace(node.sequence,"aa",13) seqFace = SeqMotifFace(node.sequence, []) # [10, 100, "[]", None, 10, "black", "rgradient:blue", "arial|8|white|domain Name"], motifs = [] last_lt = None for c, lt in enumerate(node.sequence): if lt != '-': if last_lt is None: last_lt = c if c + 1 == len(node.sequence): start, end = last_lt, c w = end - start motifs.append([ start, end, "[]", w, 13, "slategrey", "slategrey", None ]) last_lt = None elif lt == '-': if last_lt is not None: start, end = last_lt, c - 1 w = end - start motifs.append([ start, end, "[]", w, 13, "slategrey", "slategrey", None ]) last_lt = None if not motifs: print node, node.sequence seqFace = SeqMotifFace(node.sequence, motifs, intermotif_format="line", seqtail_format="line", scale_factor=1) add_face_to_node(seqFace, node, 20, aligned=True) else: if node.up: add_face_to_node(TextFace('% 3g' % node.support, fsize=11, fgcolor='indianred'), node, 0, position='branch-top') if hasattr(node, "support2") and node.up: add_face_to_node(TextFace('% 3g' % float(node.support2), fsize=11, fgcolor='steelblue'), node, 0, position='branch-bottom') node.img_style['size'] = 0 node.img_style['hz_line_color'] = 'black' node.img_style['vt_line_color'] = 'black'
def ly_supports(node): if not node.is_leaf() and node.up: supFace = TextFace("%0.2g" %(node.support), fsize=7, fgcolor='indianred') add_face_to_node(supFace, node, column=0, position='branch-top')
def ly(node): node.img_style['vt_line_width'] = 1 node.img_style['hz_line_width'] = 1 if node.is_leaf(): add_face_to_node(TextFace(' (%s)' %node.name.split()[0].replace("/exon2", ""), fsize=10, fgcolor='slategrey', tight_text=False), node, 1, position='branch-right') add_face_to_node(TextFace(node.species, fsize=12, fgcolor='black', fstyle='italic', tight_text=False), node, 0, position='branch-right') c = 1 for tname in tracked_clades: if tname in node.named_lineage: linF = TextFace(tname, fsize=10, fgcolor='white') linF.margin_left = 3 linF.background.color = lin2color[tname] add_face_to_node(linF, node, c, position='aligned') c += 1 for n in xrange(1, 20-(c-1)): add_face_to_node(TextFace('', fsize=10, fgcolor='slategrey'), node, c, position='aligned') c+=1 if draw_alg and 'sequence' in node.features: #seqFace = SequenceFace(node.sequence,"aa",13) seqFace = SeqMotifFace(node.sequence, []) # [10, 100, "[]", None, 10, "black", "rgradient:blue", "arial|8|white|domain Name"], motifs = [] last_lt = None for c, lt in enumerate(node.sequence): if lt != '-': if last_lt is None: last_lt = c if c+1 == len(node.sequence): start, end = last_lt, c w = end-start motifs.append([start, end, "[]", w, 13, "slategrey", "slategrey", None]) last_lt = None elif lt == '-': if last_lt is not None: start, end = last_lt, c-1 w = end-start motifs.append([start, end, "[]", w, 13, "slategrey", "slategrey", None]) last_lt = None if not motifs: print node, node.sequence seqFace = SeqMotifFace(node.sequence, motifs, intermotif_format="line", seqtail_format="line", scale_factor=1) add_face_to_node(seqFace, node, 20, aligned=True) else: if node.up: add_face_to_node(TextFace('% 3g' %node.support, fsize=11, fgcolor='indianred'), node, 0, position='branch-top') if hasattr(node, "support2") and node.up: add_face_to_node(TextFace('% 3g' %float(node.support2), fsize=11, fgcolor='steelblue'), node, 0, position='branch-bottom') node.img_style['size'] = 0 node.img_style['hz_line_color'] = 'black' node.img_style['vt_line_color'] = 'black'