Mercurial > repos > bebatut > humann2
comparison transform_json_to_pkl.py @ 1:bcd414bb721b draft default tip
planemo upload for repository https://github.com/ASaiM/galaxytools/tree/master/tools/humann2/ commit 79571d981d7d56657699be8aa24a40a36a8d0ab5-dirty
author | bebatut |
---|---|
date | Thu, 02 Jun 2016 04:23:09 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:3d6f37e7e3a8 | 1:bcd414bb721b |
---|---|
1 #!/usr/bin/env python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 import cPickle as pickle | |
5 import bz2 | |
6 import json | |
7 import argparse | |
8 | |
9 def transform_json_to_pkl(args): | |
10 with open(args.json_input, 'r') as json_file: | |
11 json_str = json_file.read() | |
12 metadata = json.loads(json_str) | |
13 | |
14 for marker in metadata["markers"]: | |
15 metadata["markers"][marker]["ext"] = set(metadata["markers"][marker]["ext"]) | |
16 | |
17 pkl_output = bz2.BZ2File(args.pkl_output, 'w') | |
18 pickle.dump(metadata, pkl_output, pickle.HIGHEST_PROTOCOL) | |
19 pkl_output.close() | |
20 | |
21 if __name__ == '__main__': | |
22 parser = argparse.ArgumentParser() | |
23 parser.add_argument('--json_input', required=True) | |
24 parser.add_argument('--pkl_output', required=True) | |
25 | |
26 args = parser.parse_args() | |
27 | |
28 transform_json_to_pkl(args) |