Mercurial > repos > iuc > humann2
view transform_json_to_pkl.py @ 2:ca82f52681af draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/humann2 commit 11ee7ac206d41894c0b6a11f2439aaea490824f0
author | iuc |
---|---|
date | Thu, 09 Nov 2017 13:44:40 -0500 |
parents | 1ab06263e083 |
children |
line wrap: on
line source
#!/usr/bin/env python # -*- coding: utf-8 -*- import argparse import bz2 import cPickle as pickle import json def transform_json_to_pkl(args): with open(args.json_input, 'r') as json_file: json_str = json_file.read() metadata = json.loads(json_str) for marker in metadata["markers"]: a_set = set(metadata["markers"][marker]["ext"]) metadata["markers"][marker]["ext"] = a_set pkl_output = bz2.BZ2File(args.pkl_output, 'w') pickle.dump(metadata, pkl_output, pickle.HIGHEST_PROTOCOL) pkl_output.close() if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--json_input', required=True) parser.add_argument('--pkl_output', required=True) args = parser.parse_args() transform_json_to_pkl(args)