Mercurial > repos > iuc > humann_join_tables
diff transform_json_to_pkl.py @ 0:cf7f80d59099 draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/humann commit 077b8f34e081e6c427acb0fde0fbb97d1b241e0b"
author | iuc |
---|---|
date | Wed, 12 May 2021 09:02:06 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/transform_json_to_pkl.py Wed May 12 09:02:06 2021 +0000 @@ -0,0 +1,30 @@ +#!/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)