phyloviz Package

phyloviz Package

Data providers code for PhyloViz

class galaxy.visualization.data_providers.phyloviz.PhylovizDataProvider(original_dataset=None)[source]

Bases: galaxy.visualization.data_providers.basic.BaseDataProvider

dataset_type = 'phylo'
get_data(tree_index=0)[source]

Returns trees. Trees are actually an array of JsonDicts. It’s usually one tree, except in the case of Nexus

baseparser Module

class galaxy.visualization.data_providers.phyloviz.baseparser.Base_Parser[source]

Bases: object

Base parsers contain all the methods to handle phylogeny tree creation and converting the data to json that all parsers should have

parseFile(filePath)[source]

Base method that all phylogeny file parser should have

toJson(jsonDict)[source]

Convenience method to get a json string from a python json dict

class galaxy.visualization.data_providers.phyloviz.baseparser.Node(nodeName, **kwargs)[source]

Bases: object

Node class of PhyloTree, which represents a CLAUDE in a phylogenetic tree

addChildNode(child)[source]

Adds a child node to the current node

addChildrenToJson(jsonDict)[source]

Needs a special method to addChildren, such that the key does not appear in the Jsondict when the children is empty this requirement is due to the layout algorithm used by d3 layout for hiding subtree

addMiscToJson(jsonDict)[source]

Adds other misc attributes to json if they are present

toJson()[source]

Converts the data in the node to a dict representation of json

class galaxy.visualization.data_providers.phyloviz.baseparser.PhyloTree[source]

Bases: object

Standardized python based class to represent the phylogenetic tree parsed from different phylogenetic file formats.

addAttributesToRoot(attrDict)[source]

Adds attributes to root, but first we put it in a temp store and bind it with root when .toJson is called

addRoot(root)[source]

Creates a root for phyloTree

generateJsonableDict()[source]

Changes itself into a dictonary by recurssively calling the tojson on all its nodes. Think of it as a dict in an array of dict in an array of dict and so on...

makeNode(nodeName, **kwargs)[source]

Called to make a node within PhyloTree, arbitrary kwargs can be passed to annotate nodes Tracks the number of nodes via internally incremented id

newickparser Module

class galaxy.visualization.data_providers.phyloviz.newickparser.Newick_Parser[source]

Bases: galaxy.visualization.data_providers.phyloviz.baseparser.Base_Parser

For parsing trees stored in the newick format (.nhx) It is necessarily more complex because this parser is later extended by Nexus for parsing newick as well..

cleanNewickString(rawNewick)[source]

removing semi colon, and illegal json characters (,’,”) and white spaces

parseData(newickString)[source]

To be called on a newickString directly to parse it. Returns: jsonableDict

parseFile(filePath)[source]

Parses a newick file to obtain the string inside. Returns: jsonableDict

parseNode(string, depth)[source]

Recursive method for parsing newick string, works by stripping down the string into substring of newick contained with brackers, which is used to call itself.

Eg ... ( A, B, (D, E)C, F, G ) ...

We will make the preceeding nodes first A, B, then the internal node C, its children D, E, and finally the succeeding nodes F, G

nexusparser Module

class galaxy.visualization.data_providers.phyloviz.nexusparser.Nexus_Parser[source]

Bases: galaxy.visualization.data_providers.phyloviz.newickparser.Newick_Parser

checkComments(line)[source]

Check to see if the line/lines is a comment.

parseFile(filePath)[source]

passes a file and extracts its Nexus content.

parseNexus(filename)[source]

Nexus data is stored in blocks between a line starting with begin and another line starting with end; Commends inside square brackets are to be ignored, For more information: http://wiki.christophchamp.com/index.php/NEXUS_file_format Nexus can store multiple trees

splitLinebyWhitespaces(line)[source]

replace tabs and write spaces to a single write space, so we can properly split it.

phyloxmlparser Module

class galaxy.visualization.data_providers.phyloviz.phyloxmlparser.Phyloxml_Parser[source]

Bases: galaxy.visualization.data_providers.phyloviz.baseparser.Base_Parser

Parses a phyloxml file into a json file that will be passed to PhyloViz for display

cleanTag(tagString)[source]
parseFile(filePath)[source]

passes a file and extracts its Phylogeny Tree content.

parseNode(node, depth)[source]

Parses any node within a phyloxml tree and looks out for claude, which signals the creation of nodes - internal OR leaf