Skip to content

Instantly share code, notes, and snippets.

@mtholder
Created April 17, 2017 16:50
Show Gist options
  • Select an option

  • Save mtholder/924dd1da9e6bc2775d2d6fe88acade8f to your computer and use it in GitHub Desktop.

Select an option

Save mtholder/924dd1da9e6bc2775d2d6fe88acade8f to your computer and use it in GitHub Desktop.
reads an opentree summary tree annotated_supertree/annotations.json file and reports on the taxonomy-only nodes
#!/usr/bin/env python
import sys
try:
annot_fp = sys.argv[1]
except:
sys.exit("Expecting a path to an annotations.json file as the only argument.\n")
import json
import codecs
with codecs.open(annot_fp, 'rU', encoding='utf-8') as inp:
obj = json.load(inp)
nd_list = obj["nodes"]
nabsent = 0
for node_id, nd in nd_list.items():
sb = nd.get("supported_by")
if sb is None:
nabsent += 1
sys.stderr.write("taxonomy-only {}\n".format(node_id))
sys.stdout.write("{} taxonomy-only nodes\n".format(nabsent))
@mtholder

Copy link
Copy Markdown
Author

Note that this only reports on taxonomy-only internals. Thanks to @hyanwong for pointing that out!
See https://gist.github.com/mtholder/dc9c225dcda9a1d93859065d2245ecd0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment