mobspy package — MobsPy 2.2 documentation

# mobspy package

## Subpackages

- mobspy.data_handler package
  - Submodules
  - mobspy.data_handler.process_result_data module
    - `convert_data_to_desired_unit()`
  - mobspy.data_handler.time_series_object module
    - `MobsPyList_of_TS`
      - `MobsPyList_of_TS.add_ts_to_data()`
      - `MobsPyList_of_TS.get_max_time_for_species()`
      - `MobsPyList_of_TS.return_pandas()`
      - `MobsPyList_of_TS.to_dict()`
    - `MobsPyTimeSeries`
  - Module contents
- mobspy.modules package
  - Submodules
  - mobspy.modules.class_of_meta_specie_named_any module
    - `Context_specie_named_any`
      - `Context_specie_named_any.context_finish_for_meta_specie_named_any()`
      - `Context_specie_named_any.context_initiator_for_meta_specie_named_any()`
  - mobspy.modules.event_functions module
    - `format_event_dictionary_for_sbml()`
  - mobspy.modules.function_rate_code module
    - `basic_kinetics_string()`
    - `deterministic_string()`
    - `extract_reaction_rate()`
    - `prepare_arguments_for_callable()`
    - `search_for_parameters_in_str()`
    - `stochastic_string()`
  - mobspy.modules.logic_operator_objects module
    - `MetaSpeciesLogicResolver`
      - `MetaSpeciesLogicResolver.add_double_symbol()`
      - `MetaSpeciesLogicResolver.find_all_species_strings()`
      - `MetaSpeciesLogicResolver.generate_string()`
    - `ReactingSpeciesComparator`
      - `ReactingSpeciesComparator.add_operation_and_number()`
      - `ReactingSpeciesComparator.check_context()`
    - `SpeciesComparator`
      - `SpeciesComparator.add_operation_and_number()`
      - `SpeciesComparator.check_parenthesis()`
      - `SpeciesComparator.compile_code_line()`
      - `SpeciesComparator.logical_add_reacting_species()`
      - `SpeciesComparator.logical_add_species()`
      - `SpeciesComparator.reformat_number_and_species()`
  - mobspy.modules.meta_class module
    - `BaseSpecies()`
    - `Compiler`
      - `Compiler.add_phantom_reactions()`
      - `Compiler.add_to_parameters_to_sbml()`
      - `Compiler.compile()`
      - `Compiler.entity_counter`
      - `Compiler.last_rate`
      - `Compiler.override_get_item()`
      - `Compiler.ref_characteristics_to_object`
    - `ListSpecies()`
    - `List_Species`
      - `List_Species.append()`
      - `List_Species.extend()`
      - `List_Species.insert()`
      - `List_Species.is_in()`
      - `List_Species.remove()`
      - `List_Species.remove_repeated_elements()`
    - `New()`
    - `Reacting_Species`
      - `Reacting_Species.c()`
      - `Reacting_Species.context_finish_for_reacting_specie()`
      - `Reacting_Species.context_initiator_for_reacting_specie()`
      - `Reacting_Species.is_spe_or_reac()`
      - `Reacting_Species.is_species()`
      - `Reacting_Species.label()`
      - `Reacting_Species.old_context`
    - `Reactions`
      - `Reactions.set_rate()`
    - `Species`
      - `Species.add_characteristic()`
      - `Species.add_quantities()`
      - `Species.add_reaction()`
      - `Species.add_reference()`
      - `Species.c()`
      - `Species.check_if_valid_characteristic()`
      - `Species.get_all_characteristics()`
      - `Species.get_characteristics()`
      - `Species.get_index_from_reference_dict()`
      - `Species.get_name()`
      - `Species.get_ordered_references()`
      - `Species.get_quantities()`
      - `Species.get_reactions()`
      - `Species.get_references()`
      - `Species.get_simulation_context()`
      - `Species.is_spe_or_reac()`
      - `Species.is_species()`
      - `Species.label()`
      - `Species.meta_specie_named_any_context`
      - `Species.name()`
      - `Species.order_references()`
      - `Species.print_characteristics()`
      - `Species.remove_characteristic()`
      - `Species.remove_repeated_elements()`
      - `Species.reset_counts()`
      - `Species.reset_quantities()`
      - `Species.reset_reactions()`
      - `Species.reset_references()`
      - `Species.reset_simulation_context()`
      - `Species.set_reactions()`
      - `Species.set_references()`
      - `Species.set_simulation_context()`
      - `Species.show_characteristics()`
      - `Species.show_quantities()`
      - `Species.show_reactions()`
      - `Species.show_references()`
      - `Species.str_under_context()`
      - `Species.unit()`
      - `Species.update_meta_specie_named_any_context()`
    - `compile_species_number_line()`
  - mobspy.modules.meta_class_utils module
    - `check_orthogonality_between_references()`
    - `combine_references()`
    - `complete_characteristics_with_first_values()`
    - `create_orthogonal_vector_structure()`
    - `unite_characteristics()`
  - mobspy.modules.mobspy_expressions module
    - `Bool_Override`
    - `ExpressionDefiner`
      - `ExpressionDefiner.combine_binary_attributes()`
      - `ExpressionDefiner.create_from_new_operation()`
      - `ExpressionDefiner.execute_op()`
      - `ExpressionDefiner.execute_quantity_op()`
    - `MobsPyExpression`
      - `MobsPyExpression.generate_string_operation()`
    - `OverrideQuantity`
      - `OverrideQuantity.convert()`
      - `OverrideQuantity.convert_into()`
      - `OverrideQuantity.non_expression_add()`
      - `OverrideQuantity.non_expression_mul()`
      - `OverrideQuantity.non_expression_pow()`
      - `OverrideQuantity.non_expression_radd()`
      - `OverrideQuantity.non_expression_rmul()`
      - `OverrideQuantity.non_expression_rsub()`
      - `OverrideQuantity.non_expression_rtruediv()`
      - `OverrideQuantity.non_expression_sub()`
      - `OverrideQuantity.non_expression_truediv()`
      - `OverrideQuantity.set_ms_active()`
    - `OverrideUnitRegistry`
    - `QuantityConverter`
      - `QuantityConverter.convert_received_unit()`
    - `Specific_Species_Operator`
      - `Specific_Species_Operator.add()`
      - `Specific_Species_Operator.get_characteristics()`
      - `Specific_Species_Operator.get_name()`
      - `Specific_Species_Operator.is_a()`
  - mobspy.modules.mobspy_parameters module
    - `Mobspy_Parameter`
      - `Mobspy_Parameter.parameter_stack`
      - `Mobspy_Parameter.rename()`
    - `ModelParameters()`
  - mobspy.modules.order_operators module
  - mobspy.modules.reaction_construction_nb module
    - `check_for_invalid_reactions()`
    - `construct_order_structure()`
    - `construct_product_structure()`
    - `construct_rate_function_arguments()`
    - `construct_reactant_structures()`
    - `construct_single_reaction_for_sbml()`
    - `copy_reaction()`
    - `count_string_dictionary()`
    - `create_all_reactions()`
    - `expression_compilation_finish()`
    - `expression_compilation_initiation()`
    - `get_involved_species()`
    - `iterator_for_combinations()`
  - mobspy.modules.reaction_construction_nb_parallel module
    - `check_for_invalid_reactions()`
    - `construct_order_structure()`
    - `construct_product_structure()`
    - `construct_rate_function_arguments()`
    - `construct_reactant_structures()`
    - `construct_single_reaction_for_sbml()`
    - `copy_reaction()`
    - `count_string_dictionary()`
    - `create_all_reactions()`
    - `get_involved_species()`
    - `iterator_for_combinations()`
  - mobspy.modules.set_counts_module module
    - `set_counts()`
  - mobspy.modules.species_string_generator module
    - `characteristics_dictionary()`
    - `construct_all_combinations()`
    - `construct_species_char_list()`
  - mobspy.modules.unit_handler module
    - `check_dimension()`
    - `convert_counts()`
    - `convert_rate()`
    - `convert_time()`
    - `convert_volume()`
    - `extract_length_dimension()`
  - mobspy.modules.user_functions module
    - `Apply()`
  - Module contents
- mobspy.parameter_scripts package
  - Submodules
  - mobspy.parameter_scripts.parameter_reader module
    - `parameter_process()`
    - `read_json()`
  - mobspy.parameter_scripts.parametric_sweeps module
    - `assign_values_to_model()`
    - `generate_all_sbml_models()`
    - `unite_parameter_dictionaries()`
  - Module contents
- mobspy.parameters package
  - Submodules
  - mobspy.parameters.default_reader module
    - `get_default_parameters()`
  - mobspy.parameters.example_reader module
    - `get_example_parameters()`
  - Module contents
- mobspy.plot_params package
  - Submodules
  - mobspy.plot_params.default_plot_reader module
    - `get_default_plot_parameters()`
  - mobspy.plot_params.example_plot_reader module
    - `get_example_plot_parameters()`
  - Module contents
- mobspy.plot_scripts package
  - Submodules
  - mobspy.plot_scripts.default_plots module
    - `deterministic_plot()`
    - `parametric_plot()`
    - `raw_plot()`
    - `read_plot_json()`
    - `set_plot_units()`
    - `stochastic_plot()`
  - mobspy.plot_scripts.hierarchical_plot module
    - `Color_cycle`
    - `figure_hash()`
    - `figure_hash_creation()`
    - `find_parameter()`
    - `find_species_time_series()`
    - `get_total_figure_number()`
    - `plot_curves()`
    - `plot_data()`
    - `set_figure_characteristics()`
    - `set_global_parameters()`
  - mobspy.plot_scripts.process_plot_data module
    - `check_plot_parameters()`
    - `query_plot_data()`
    - `time_filter_operation()`
  - mobspy.plot_scripts.statistics_calculations module
    - `average_plus_standard_deviation()`
    - `standard_deviation()`
    - `time_series_average()`
  - Module contents
- mobspy.sbml_simulator package
  - Submodules
  - mobspy.sbml_simulator.SBMLWriter module
    - `check()`
    - `create_model()`
  - mobspy.sbml_simulator.builder module
    - `build()`
  - mobspy.sbml_simulator.run module
    - `job_execution()`
    - `reformat_time_series()`
    - `simulate()`
  - Module contents
- mobspy.simulation_logging package
  - Submodules
  - mobspy.simulation_logging.log_scripts module
    - `debug()`
    - `error()`
    - `warning()`
  - Module contents

## Submodules

## mobspy.simulation module

Main MobsPy module. It stocks the Simulation class which is responsible for simulating a Model

class mobspy.simulation.Simulation(model, names=None, parameters=None, plot_parameters=None)

  Bases: `object`

  compile(verbose=True)

    Compiler method that calls the Compiler class in the modules directory

    Parameters:

      verbose – (bool) = print or not the results of the compilation

  configure_parameters(config)

    Configure simulation parameters from json file or dictionary

    Parameters:

      file_name – (str) name of the json file

  configure_plot_parameters(config)

    Configure plot parameters from json file or dictionary

    Parameters:

      file_name – (str) name of the json file

  classmethod event_compilation_error()
  event_condition(trigger, delay=0)

    Context manager for condition events. Called in “with Simulation.event_condition(trigger) :” format.

    Parameters:

      - trigger – () condition that triggers the event when fulfilled

      - delay – (int, float, Quantity) time to wait before triggering the event once the trigger condition has been fulfilled

  event_context_add(time, trigger)

    Adds an event to the event context

    Parameters:

      - trigger – () condition that triggers the event when fulfilled

      - time – (int, float, Quantity) time to wait before triggering the event once the trigger condition has been fulfilled

  event_context_finish()

    Removes the context in all meta-species and resets some varaiables. Called each time an event context is finished.

  event_context_initiator()

    Sets the context in all meta-species. Called each time an event context is initiated.

  event_time(time)

    Context manager for time events. Called in “with Simulation.event_time(time) :” format.

    Parameters:

      time – (int, float, Quantity) any time used

  extract_plot_essentials(*species)

    Extract essential information for plotting

    Parameters:

      species – (meta-species objects) meta-species objects to plot

    Returns:

      species_strings (str) = species strings to be plotted, self.results = data resulting from the

    simulation, self.plot_parameters (dict) = parameters for plotting

  generate_sbml()

    Generates sbmls strings from the current stored models in the simulation

    “return: to_return (list of str) list of sbml files from all the simulations stored

  classmethod is_simulation()
  plot(*species)

    Another way of calling plot_deterministic for simplicity

    Parameters:

      species – (str or meta-species objects) list of species to be plotted

  plot_deterministic(*species)

    Calls deterministic plot. See default_plots module in the plot_scripts directory

    Parameters:

      species – (str or meta-species objects) list of species to be plotted

  plot_parametric(*species)
  plot_raw(parameters_or_file)

    Calls raw plot. See default_plots module in the plot_scripts directory

    Parameters:

      parameters_or_file – json file name with plot parameter configuration or dictionary with plot

    parameter configuration

  plot_stochastic(*species)

    Calls stochastic plot. See default_plots module in the plot_scripts directory

    Parameters:

      species – (str or meta-species objects) list of species to be plotted

  run()

    Runs the simulation by colling the models in the sbml_simulator directory. Compiles the model if it was not yet compiled

  save_data(file=None)

    Saves the simulation result data to a file in json format

    Parameters:

      file – (str) name of the file to save the data to. If none a default name is provided

  set_from_json(file_name)

    Set simulation parameters from json file

    Parameters:

      file_name – (str) name of the json file

  classmethod set_job_number(params)

class mobspy.simulation.SimulationComposition(S1, S2)

  Bases: `object`

  compile(verbose=True)
  generate_sbml()
  classmethod is_simulation()
  plot(*species)
  plot_deterministic(*species)
  plot_raw(parameters_or_file)
  plot_stochastic(*species)
  run()

## Module contents

MobsPy: A Query-Based Language for Chemical Reaction Networks