Viking database!
description
Transcript of Viking database!
![Page 1: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/1.jpg)
1
Viking database!
• Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg ..
• Build new class for representing this tree..?
![Page 2: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/2.jpg)
2
No!
We already have a
generic tree class:
Phylogeny_node
tree
.py
![Page 3: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/3.jpg)
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
![Page 4: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/4.jpg)
• 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
![Page 5: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/5.jpg)
Test program
Not queen/king: no reign given
roya
l_vi
king
s.py
(pa
rt 2
)
![Page 6: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/6.jpg)
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)
![Page 7: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/7.jpg)
7
Another kind of tree: Newick trees
((monkey:100.85,cat:47.14):20.59);
monkeycat
100.8547.14
20.59
![Page 8: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/8.jpg)
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”
![Page 9: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/9.jpg)
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”
![Page 10: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/10.jpg)
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
![Page 11: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/11.jpg)
11
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
Exercise: Newick_node method
Newick_node derives from Node
![Page 12: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/12.jpg)
12
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
2/50/0
mismatches = 0
alignmentlength = 0
![Page 13: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/13.jpg)
13
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
2/50/0
mismatches = 2
alignmentlength = 5
0/01/6
![Page 14: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/14.jpg)
14
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
mismatches = 3
alignmentlength = 11
0/01/6
![Page 15: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/15.jpg)
15
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
3/11
![Page 16: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/16.jpg)
16
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
3/11 1/5 1/4 0/0
![Page 17: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/17.jpg)
17
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
ham
min
g.py
(p
art 1
)
3/11 1/5 1/4 0/0
5/20
![Page 18: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/18.jpg)
18
Average Hamming Error
ham
min
g.py
(p
art 2
)
CGTAT
CGATAT
CGAGAT
GTAT
CATAT
Average Hamming error: 0.250
![Page 19: Viking database!](https://reader036.fdocuments.us/reader036/viewer/2022070406/568140e7550346895dacb533/html5/thumbnails/19.jpg)
19
.. on to the exercises