forked from etetoolkit/ete
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_seq_motifs.py
39 lines (34 loc) · 1.81 KB
/
test_seq_motifs.py
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
import sys
sys.path.insert(0, "./")
from ete_dev import faces, Tree, SeqMotifFace
from random import sample, randint
from copy import deepcopy
# sample sequence and a list of example motif types
seq = "LHGRISQQVEQSRSQVQAIGEKVSLAQAKIEKIKGSKKAIKVFSSAKYPAPERLQEYGSIFTDAQDPGLQRRPRHRIQSKQRPLDERALQEKLKDFPVCVSTKPEPEDDAEEGLGGLPSNISSVSSLLLFNTTENLYKKYVFLDPLAGAVTKTHVMLGAETEEKLFDAPLSISKREQLEQQVPENYFYVPDLGQVPEIDVPSYLPDLPGIANDLMYIADLGPGIAPSAPGTIPELPTFHTEVAEPLKVGELGSGMGAGPGTPAHTPSSLDTPHFVFQTYKMGAPPLPPSTAAPVGQGARQDDSSSSASPSVQGAPREVVDPSGGWATLLESIRQAGGIGKAKLRSMKERKLEKQQQKEQEQVRATSQGGHLMSDLFNKLVMRRKGISGKGPGAGDGPGGAFARVSDSIPPLPPPQQPQAEDEDDWES"
motifs = [
# seq.start, seq.end, shape, width, height, fgcolor, bgcolor
[120, 130, ">", 34, 13, "black", "red", None],
[145, 150, "<", 60, 5, "black", "green", None],
[10, 30, "o", 100, 10, "black", "rgradient:blue", None],
[20, 50, "[]", 100, 10, "blue", "pink", None],
[55, 80, "()", 100, 10, "blue", "rgradient:purple", None],
[160, 170, "^", 50, 14, "black", "yellow", None],
[172, 180, "v", 20, 12, "black", "rgradient:orange", None],
[185, 190, "o", 12, 12, "black", "brown", None],
[198, 200, "<>", 15, 15, "black", "rgradient:gold", None],
[210, 240, "compactseq", 2, 10, None, None, None],
[300, 320, "seq", 10, 10, None, None, None],
[340, 350, "<>", 15, 15, "black", "rgradient:black", None],
]
# Show usage help for SeqMotifFace
print SeqMotifFace.__doc__
# Create a random tree and add to each leaf a random set of motifs
# from the original set
t = Tree()
t.populate(40)
for l in t.iter_leaves():
seq_motifs = sample(motifs, randint(2, len(motifs)))
seqFace = SeqMotifFace(seq, seq_motifs, intermotif_format="line", seqtail_format="compactseq")
seqFace.margin_bottom = 4
f = l.add_face(seqFace, 0, "aligned")
t.show()