1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class...
-
Upload
lana-handford -
Category
Documents
-
view
226 -
download
2
Transcript of 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class...
1
Viking database!
• Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg ..
• Build new class for representing this tree..?
2
No!
We already have a
generic tree class:
Phylogeny_node
tree
.py
3
• Create copy with more general name
• Build Royal class as a subclass of this class:– Needs same attributes
and methods, plus perhaps more
gene
ral_
tree
.py
• A Royal viking in a family tree has a father/parent node, a name, and a string representing the reigning period (if viking was queen/king)
roya
l_vi
king
s.py
(pa
rt 1
)
Overrides __str__ method of Node class
Test program
Not queen/king: no reign given
roya
l_vi
king
s.py
(pa
rt 2
)
Navigating the family tree, starting with Niels
roya
l_vi
king
s.py
(pa
rt 3
)[..]Name: Svend EstridsenParent: EstridSiblings: Sons: Harald Hen, Knud den Hellige, Oluf Hunger, Erik Ejegod, Niels(f)ather, (s)on, si(b)ling, (p)rint, (q)uit? f
Name: EstridParent: Svend TveskægSiblings: Harald 2., Knud den StoreSons: Svend Estridsen(f)ather, (s)on, si(b)ling, (p)rint, (q)uit? bNumber of sibling (0-1)? 1
Name: Knud den StoreParent: Svend TveskægSiblings: Harald 2., EstridSons: Knud 3. Hardeknud(f)ather, (s)on, si(b)ling, (p)rint, (q)uit? pKnud den Store (1014-1035) - Svend Tveskæg (987-1014) - Harald Blåtand (958-987) – Gorm den Gamle (?-958)
7
Another kind of tree: Newick trees
((monkey:100.85,cat:47.14):20.59);
monkeycat
100.8547.14
20.59
8
Project: Newick trees
• Load and parse newick tree file
– Need newick class
• Newick node has name, list of sons, distance to father, sequence
• Inherit from general_tree's Node class!
– Need parser
• Check that loaded tree corresponds to “current sequences”
– Create (ID, sequence) dictionary from current seqs (efficient!)
– After parsing tree file, traverse tree and look up sequence from
each node ID, store in node
– Give error message if ID not found
• Calculate “Average Hamming error”
9
Project: Newick trees
• Load and parse newick tree file
– Need newick class
• Newick node has name, list of sons, distance to father, sequence
• Inherit from general_tree's Node class!
– Need parser
• Check that loaded tree corresponds to “current sequences”
– Create (ID, sequence) dictionary from current seqs (efficient!)
– After parsing tree file, traverse tree and look up sequence from
each node ID, store in node
– Give error message if ID not found
• Calculate “Average Hamming error”
10
Average Hamming Error in tree
• Average number of mismatches per alignment position
over all alignments in tree
• (2+1+1+1)/(5+6+5+4) = 5/20 = 0.25 errors per alignment
position
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
2/5 1/6
1/5 1/4
11
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
Exercise: Newick_node method
Newick_node derives from Node
12
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
2/50/0
mismatches = 0
alignmentlength = 0
13
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
2/50/0
mismatches = 2
alignmentlength = 5
0/01/6
14
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
mismatches = 3
alignmentlength = 11
0/01/6
15
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
3/11
16
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
3/11 1/5 1/4 0/0
17
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
3/11 1/5 1/4 0/0
5/20
18
Average Hamming Error
ham
min
g.py
(p
art 2
)
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
Average Hamming error: 0.250
19
.. on to the exercises