Skip to content

Instantly share code, notes, and snippets.

View benmaier's full-sized avatar

Benjamin F. Maier benmaier

View GitHub Profile
@benmaier
benmaier / Newick2JSON.py
Last active June 4, 2020 11:50 — forked from grabear/Newick2JSON.py
Converts a newick file into JSON format for d3/TreeWidget javascript component
import sys
from ete3 import Tree
import random
def get_json(node):
# Read ETE tag for duplication or speciation events
if not hasattr(node, 'evoltype'):
dup = random.sample(['N','Y'], 1)[0]
elif node.evoltype == "S":
dup = "N"