Skip to content

Python function to convert a json object to a newick string.

Notifications You must be signed in to change notification settings

okeeffdp/json_to_newick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

JSON to Newick

json_to_newick.py contains a function, json_to_newick, to convert a json object to newick format.

Parameters:

json - A JSON object. See JSON.

Output:

string - A string in Newick format. See Newick format.

Example:

>>> json = {
	"name" : "F",
	"children": [
		{"name": "A", "branch_length": 0.1},
		{"name": "B", "branch_length": 0.2},
		{"name": "E","branch_length": 0.5,
		"children": [
			{"name": "C", "branch_length": 0.3},
			{"name": "D", "branch_length": 0.4}
			]
		}
		]
	}
>>> print(json_to_newick(json))
(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F;

By Daniel O'Keeffe

About

Python function to convert a json object to a newick string.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages