Created
December 28, 2019 22:14
-
-
Save mtholder/dde04e1e6223590cc38e12aeb400ddc8 to your computer and use it in GitHub Desktop.
summary of subproblem_size_summary.json as a .tsv
This file contains 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
#!/bin/env python | |
import json | |
import sys | |
import subprocess | |
import itertools | |
inpjson = 'subproblem_size_summary.json' | |
with open(inpjson, 'r', encoding='utf-8') as inp: | |
summary_blob = json.load(inp) | |
subprobs = summary_blob["subproblems"] | |
tree_ids = summary_blob["tree_ids"] | |
print('\t'.join(["ID", | |
"num_scaff_leaves", | |
"num_synth_leaves", | |
"num_splits", | |
"num_informative_input_trees", | |
"num_noninformative_overlapping_input_trees", | |
"inf_tree_ids", | |
"noninf_tree_ids"])) | |
for ott_id, summary_blob in subprobs.items(): | |
num_scaff_leaves, num_synth_leaves, by_input = summary_blob | |
inf_by_inp, non_inf = [], [] | |
num_splits = 0 | |
for el in by_input: | |
tid = tree_ids[el[2]] | |
if el[1] > 0: | |
num_splits += el[1] | |
inf_by_inp.append(tid) | |
else: | |
non_inf.append(tid) | |
data = [ott_id, num_scaff_leaves, num_synth_leaves, num_splits, len(inf_by_inp), len(non_inf), ','.join(inf_by_inp), ','.join(non_inf)] | |
print('\t'.join([str(i) for i in data])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment