1 viking database! family tree of gorm den gamle, harald blåtand, svend tveskæg.. build new class...

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

Upload: lana-handford

Post on 14-Dec-2015

222 views

Category:

Documents


2 download

TRANSCRIPT

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

1

Viking database!

• Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg ..

• Build new class for representing this tree..?

Page 2: 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

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

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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

• 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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

Test program

Not queen/king: no reign given

roya

l_vi

king

s.py

(pa

rt 2

)

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

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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

7

Another kind of tree: Newick trees

((monkey:100.85,cat:47.14):20.59);

monkeycat

100.8547.14

20.59

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

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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

11

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

Exercise: Newick_node method

Newick_node derives from Node

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

12

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

2/50/0

mismatches = 0

alignmentlength = 0

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

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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

14

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

mismatches = 3

alignmentlength = 11

0/01/6

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

15

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

3/11

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

16

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

ham

min

g.py

(p

art 1

)

3/11 1/5 1/4 0/0

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

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: 1 Viking database! Family tree of Gorm den Gamle, Harald Blåtand, Svend Tveskæg.. Build new class for representing this tree..?

18

Average Hamming Error

ham

min

g.py

(p

art 2

)

CGTAT

CGATAT

CGAGAT

GTAT

CATAT

Average Hamming error: 0.250

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

19

.. on to the exercises