1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
# We will need to create Qt4 items
from ...treeview.qt import QtCore
from ...treeview.qt import QGraphicsRectItem, QColor, QPen, QBrush
from ...treeview.qt import QGraphicsSimpleTextItem, QFont
from ... import faces, TreeStyle, PhyloTree, TextFace, SequenceFace
from random import random
_aafgcolors = {
'A':"#000000" ,
'R':"#000000" ,
'N':"#000000" ,
'D':"#000000" ,
'C':"#000000" ,
'Q':"#000000" ,
'E':"#000000" ,
'G':"#000000" ,
'H':"#000000" ,
'I':"#000000" ,
'L':"#000000" ,
'K':"#000000" ,
'M':"#000000" ,
'F':"#000000" ,
'P':"#000000" ,
'S':"#000000" ,
'T':"#000000" ,
'W':"#000000" ,
'Y':"#000000" ,
'V':"#000000" ,
'B':"#000000" ,
'Z':"#000000" ,
'X':"#000000",
'.':"#000000",
'-':"#000000",
}
_aabgcolors = {
'A':"#C8C8C8" ,
'R':"#145AFF" ,
'N':"#00DCDC" ,
'D':"#E60A0A" ,
'C':"#E6E600" ,
'Q':"#00DCDC" ,
'E':"#E60A0A" ,
'G':"#EBEBEB" ,
'H':"#8282D2" ,
'I':"#0F820F" ,
'L':"#0F820F" ,
'K':"#145AFF" ,
'M':"#E6E600" ,
'F':"#3232AA" ,
'P':"#DC9682" ,
'S':"#FA9600" ,
'T':"#FA9600" ,
'W':"#B45AB4" ,
'Y':"#3232AA" ,
'V':"#0F820F" ,
'B':"#FF69B4" ,
'Z':"#FF69B4" ,
'X':"#BEA06E",
'.':"#FFFFFF",
'-':"#FFFFFF",
}
_ntfgcolors = {
'A':'#000000',
'G':'#000000',
'I':'#000000',
'C':'#000000',
'T':'#000000',
'U':'#000000',
'.':"#000000",
'-':"#000000",
' ':"#000000"
}
_ntbgcolors = {
'A':'#A0A0FF',
'G':'#FF7070',
'I':'#80FFFF',
'C':'#FF8C4B',
'T':'#A0FFA0',
'U':'#FF8080',
'.':"#FFFFFF",
'-':"#FFFFFF",
' ':"#FFFFFF"
}
def test_layout_evol(node):
'''
layout for CodemlTree
'''
if hasattr(node, "collapsed"):
if node.collapsed == 1:
node.img_style["draw_descendants"]= False
if node.is_leaf():
if hasattr (node, "sequence"):
seqface = SequenceFace(node.sequence, "aa",
codon=node.nt_sequence, fsize=10,
col_w=11, interactive=True)
faces.add_face_to_node(seqface, node, 1, aligned=True)
def test_layout_phylo_aa(node):
'''
layout for CodemlTree
'''
if hasattr(node, "collapsed"):
if node.collapsed == 1:
node.img_style["draw_descendants"]= False
if node.is_leaf():
if hasattr (node, "sequence"):
seqface = SequenceFace(node.sequence, "aa",
fsize=10,
col_w=11, interactive=False)
faces.add_face_to_node(seqface, node, 1, aligned=True)
def test_layout_phylo_aa_motif(node):
'''
layout for CodemlTree
'''
if hasattr(node, "collapsed"):
if node.collapsed == 1:
node.img_style["draw_descendants"]= False
special_col = [[10,100],[150,1000],[1000,2000],[3000,4990]]
if node.is_leaf():
if hasattr (node, "sequence"):
seqface = SequenceFace(node.sequence, "aa",
fsize=10,special_col=special_col,
alt_col_w=3,
col_w=11, interactive=True)
faces.add_face_to_node(seqface, node, 1, aligned=True)
def test_layout_phylo_nt(node):
'''
layout for CodemlTree
'''
if hasattr(node, "collapsed"):
if node.collapsed == 1:
node.img_style["draw_descendants"]= False
if node.is_leaf():
if hasattr (node, "sequence"):
seqface = SequenceFace(node.sequence, "nt",
fsize=10,
col_w=11, interactive=True)
faces.add_face_to_node(seqface, node, 1, aligned=True)
if __name__ == "__main__":
tree = PhyloTree('(Orangutan,Human,Chimp);')
tree.link_to_alignment("""
>Chimp
HARWLNEKLRCELRTLKKLGLDGYKAVSQYVKGRA
>Orangutan
DARWINEKLRCVSRTLKKLGLDGYKGVSQYVKGRP
>Human
DARWHNVKLRCELRTLKKLGLVGFKAVSQFVIRRA
""")
nt_sequences = {"Human" : "GACGCACGGTGGCACAACGTAAAATTAAGATGTGAATTGAGAACTCTGAAAAAATTGGGACTGGTCGGCTTCAAGGCAGTAAGTCAATTCGTAATACGTCGTGCG",
"Chimp" : "CACGCCCGATGGCTCAACGAAAAGTTAAGATGCGAATTGAGAACTCTGAAAAAATTGGGACTGGACGGCTACAAGGCAGTAAGTCAGTACGTTAAAGGTCGTGCG",
"Orangutan": "GATGCACGCTGGATCAACGAAAAGTTAAGATGCGTATCGAGAACTCTGAAAAAATTGGGACTGGACGGCTACAAGGGAGTAAGTCAATACGTTAAAGGTCGTCCG"
}
for l in nt_sequences:
(tree & l).nt_sequence = nt_sequences[l]
tree.dist = 0
ts = TreeStyle()
ts.title.add_face(TextFace("Example for nucleotides...", fsize=15), column=0)
ts.layout_fn = test_layout_evol
tree.show(tree_style=ts)
# Show very large algs
tree = PhyloTree('(Orangutan,Human,Chimp);')
tree.link_to_alignment(">Human\n" + ''.join([_aabgcolors.keys()[int(random() * len (_aabgcolors))] for _ in range(5000)]) + \
"\n>Chimp\n" + ''.join([_aabgcolors.keys()[int(random() * len (_aabgcolors))] for _ in range(5000)]) + \
"\n>Orangutan\n" + ''.join([_aabgcolors.keys()[int(random() * len (_aabgcolors))] for _ in range(5000)]))
tree.dist = 0
ts = TreeStyle()
ts.title.add_face(TextFace("better not set interactivity if alg is very large", fsize=15), column=0)
ts.layout_fn = test_layout_phylo_aa
tree.show(tree_style=ts)
|