def convert_run_to_metagroups(run):
    """
    Function to convert runs to metagroups like dictionaries.

    Parameters
    ----------
    run : LogFileReader.run
        Run dictionary.

    Returns
    -------
    meta_groups : dict
        Dictionary of metagroups.
    """
    meta_groups = dict(
        simulation=dict(engine='LAMMPS'),
        thermostat=dict(),
        barostat=dict(),
    )

    simulation_keywords = ['n_steps', 'time_step', 'units']
    for keyword in simulation_keywords:
        if keyword in run:
            meta_groups['simulation'][keyword] = run[keyword]
    if 'thermostat' in run:
        meta_groups['thermostat'].update(run['thermostat'])

    if 'barostat' in run:
        meta_groups['barostat'].update(run['barostat'])

    for key in list(meta_groups.keys()):
        if len(meta_groups[key]) == 0:
            meta_groups.pop(key)
    return meta_groups