galaxy.visualization.data_providers.phyloviz package

Data providers code for PhyloViz

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

Bases: BaseDataProvider

dataset_type = 'phylo'

Create basic data provider.


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

original_dataset: DatasetInstance


galaxy.visualization.data_providers.phyloviz.baseparser module

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

__init__(nodeName, **kwargs)[source]

Creates a node and adds in the typical annotations


Adds a child node to the current node

toJson() Dict[str, Any][source]

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


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


Adds other misc attributes to json if they are present

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.


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

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

addRoot(root: Node)[source]

Creates a root for phyloTree


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…

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


Base method that all phylogeny file parser should have


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

galaxy.visualization.data_providers.phyloviz.newickparser module

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

Bases: 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..


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


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


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

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

galaxy.visualization.data_providers.phyloviz.nexusparser module

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

Bases: Newick_Parser


passes a file and extracts its Nexus content.


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: Nexus can store multiple trees


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


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

galaxy.visualization.data_providers.phyloviz.phyloxmlparser module

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

Bases: Base_Parser

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


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