def __init__(self): super(Phyloxml_Parser, self).__init__() self.phyloTree = PhyloTree() self.tagsOfInterest = { "clade": "", "name": "name", "branch_length": "length", "confidence": "bootstrap", "events": "events" }
def _parseNewickToJson(self, newickString, treeName=None, nameMap=None): """parses a newick representation of a tree into a PhyloTree data structure, which can be easily converted to json""" self.phyloTree = PhyloTree() newickString = self.cleanNewickString(newickString) if nameMap: newickString = self._mapName(newickString, nameMap) self.phyloTree.root = self.parseNode(newickString, 0) if nameMap: self.phyloTree.addAttributesToRoot({"treeName": treeName}) return self.phyloTree.generateJsonableDict()