hw2 - To add to an internal node, follow the appropriate...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
http://www.writely.com/RawDocContents.aspx?docID=dggds9kn_6. .. Biological Computation 20.181 Homework 2 Data Structures. In class, we looked at a simple data structure for representing phylogenies. A dictionary with several predefined keys: name, left, and right. This structure is sufficient to represent the topology (of a rooted tree), but in general we are sometimes interested in the length of the different branches. For this homework exercise, you will write a subroutine that outputs a tree data structure as a string in Newick format as outlined in class, but you will modify the code such that it also reports branch lengths. For reference, the following tree: ...can be represented as: "(a,((b,c),(d,e)));" in Newick format. In Newick notation, additional information can be added to each node by following the node with a colon.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: To add to an internal node, follow the appropriate right paren with a colon. For example, here is the above tree with branch lengths added: "(a:3,((b:1,c:1):1,(d:1,e:1):1):1):1;" In this (and most subsequent) homework, you will be responsible for adding functions to an existing codebase. You can download the appropriate Python codebase from the class website. Your function, which will print out Newick formatted strings including branch lengths, will have the following form: def tree2String(tree): ...your code here. .. and will be called by the 'wrapper' function: def printTree(tree): treeStr = tree2String(tree) print tree2String + ";" Finally, your code should detect whether there are branch lengths to report (!= None), otherwise it should output a standard Newick formatted file without lengths. 1 of 1 9/11/06 12:17 AM...
View Full Document

This note was uploaded on 11/11/2011 for the course BIO 20.010j taught by Professor Lindagriffith during the Spring '06 term at MIT.

Ask a homework question - tutors are online