comparison transform_json_to_pkl.py @ 0:dd4b5b9daf6b draft

planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/humann2/ commit b46aa969c01b7e5f4f133192899fa4da286ecf89-dirty
author iuc
date Mon, 13 Mar 2017 12:37:08 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:dd4b5b9daf6b
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import argparse
5 import bz2
6 import cPickle as pickle
7 import json
8
9
10 def transform_json_to_pkl(args):
11 with open(args.json_input, 'r') as json_file:
12 json_str = json_file.read()
13 metadata = json.loads(json_str)
14
15 for marker in metadata["markers"]:
16 a_set = set(metadata["markers"][marker]["ext"])
17 metadata["markers"][marker]["ext"] = a_set
18
19 pkl_output = bz2.BZ2File(args.pkl_output, 'w')
20 pickle.dump(metadata, pkl_output, pickle.HIGHEST_PROTOCOL)
21 pkl_output.close()
22
23
24 if __name__ == '__main__':
25 parser = argparse.ArgumentParser()
26 parser.add_argument('--json_input', required=True)
27 parser.add_argument('--pkl_output', required=True)
28 args = parser.parse_args()
29
30 transform_json_to_pkl(args)