def newick_from_string(self):
<EOL>for chunk in self.data.split("<STR_LIT:(>")[<NUM_LIT:1>:]:<EOL><INDENT>self.current_parent = (<EOL>self.root if self.current_parent is None else<EOL>self.current_parent.add_child()<EOL>)<EOL>subchunks = [ch.strip() for ch in chunk.split("<STR_LIT:U+002C>")]<EOL>if subchunks[-<NUM_LIT:1>] != '<STR_LIT>' and not subchunks[-<NUM_LIT:1>].endswith('<STR_LIT:;>'):<EOL><INDENT>raise NewickError(<EOL>'<STR_LIT>'.format(chunk))<EOL><DEDENT>for idx, leaf in enumerate(subchunks):<EOL><INDENT>if leaf.strip() == '<STR_LIT>' and idx == len(subchunks) - <NUM_LIT:1>:<EOL><INDENT>continue<EOL><DEDENT>closing_nodes = leaf.split("<STR_LIT:)>")<EOL>self.apply_node_data(closing_nodes[<NUM_LIT:0>], "<STR_LIT>")<EOL>if len(closing_nodes) > <NUM_LIT:1>:<EOL><INDENT>for closing_internal in closing_nodes[<NUM_LIT:1>:]:<EOL><INDENT>closing_internal = closing_internal.rstrip("<STR_LIT:;>")<EOL>self.apply_node_data(closing_internal, "<STR_LIT>")<EOL>self.current_parent = self.current_parent.up<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return self.root<EOL>
Reads a newick string in the New Hampshire format.