view 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
line wrap: on
line source

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import cPickle as pickle
import bz2
import json
import argparse

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"]:
            metadata["markers"][marker]["ext"] = set(metadata["markers"][marker]["ext"])

    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)