runscripts.create_variants

class runscripts.create_variants.SimData[source]

Bases: object

Mock sim_data class for testing.

runscripts.create_variants.apply_and_save_variants(sim_data, param_dicts, variant_name, outdir, skip_baseline)[source]

Applies variant function to sim_data with each parameter dictionary in param_dicts. Saves each variant as {i}.cPickle in outdir, where i is the index of the parameter dictionary in param_dicts used to create that variant. Also saves metadata.json in outdir that maps each {i} to the parameter dictionary used to create it.

Parameters:
  • sim_data (SimulationDataEcoli) – Simulation data object to modify

  • param_dicts (list[dict[str, Any]]) – Return value of parse_variants()

  • variant_name (str) – Name of variant function file in ecoli/variants folder

  • outdir (str) – Path to folder where variant sim_data pickles are saved

  • skip_baseline (bool) – Whether to save metadata for baseline sim_data

runscripts.create_variants.main()[source]
runscripts.create_variants.parse_variants(variant_config)[source]

Parse parameters for a variant specified under variants key of config.

Parameters:

variant_config (dict[str, str | dict[str, Any]]) –

Dictionary of the form:

{
    # Define one or more parameters with any names EXCEPT `op`
    'param_name': {
        # Each parameter defines only ONE of the following keys
        # A list of parameter values
        'value': [...]
        # Numpy function that returns array of parameter values
        # Example: np.linspace
        'linspace': {
            # Kwargs
            'start': ...,
            'stop': ...,
            'num' (optional): ...
        }
        # Dictionary of parameters with same rules as this one
        'nested': {...}
    },
    # When more than one parameter is defined, an 'op' key
    # MUST define how to combine them. The three options are:
    # 'zip': Zip parameters (must have same length)
    # 'prod': Cartesian product of parameters
    # 'add': Concatenate parameter lists into single parameter
    #        named {param_name_1}__{param_name_2}__...
    'param_2': {...},
    'op': 'zip'
}

Returns:

List of parameter dictionaries generated from variant config

Return type:

list[dict[str, Any]]