Viking database!

19
1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg .. Build new class for representing this tree..?

description

Viking database!. Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg .. Build new class for representing this tree..?. tree.py. No!. We already have a generic tree class: Phylogeny_node. general_tree.py. Create copy with more general name - PowerPoint PPT Presentation

Transcript of Viking database!

Page 1: Viking database!

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!

2

No!

We already have a

generic tree class:

Phylogeny_node

tree

.py

Page 3: Viking database!

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!

• 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!

Test program

Not queen/king: no reign given

roya

l_vi

king

s.py

(pa

rt 2

)

Page 6: Viking database!

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!

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!

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!

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!

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!

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!

12

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

2/50/0

mismatches = 0

alignmentlength = 0

Page 13: Viking database!

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!

14

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

mismatches = 3

alignmentlength = 11

0/01/6

Page 15: Viking database!

15

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

3/11

Page 16: Viking database!

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!

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!

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!

19

.. on to the exercises