Created
April 17, 2017 16:50
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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)) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that this only reports on taxonomy-only internals. Thanks to @hyanwong for pointing that out!
See https://gist.github.com/mtholder/dc9c225dcda9a1d93859065d2245ecd0