import gzip
import json


def read_optimization_inputs(input_json_gz):
    """ Read data generated by 01_generate.py
    Returns
    -------
    optimization_inputs: dict
        Dictionary for selected torsions, has this structure:
        [
            {
                'cmiles_identifiers': {
                    "canonical_smiles": ...,
                    ..
                },
                'atom_indices': [
                    [
                        1,
                        2,
                        3,
                        4
                    ]
                ],
                'initial_molecules': [
                    Molecule1a,
                    Molecule1b,
                    ..
                ]
            },
            ..
        ]
    """
    with gzip.open(input_json_gz, 'r') as f:
        optimization_inputs = json.load(f)
    return optimization_inputs