biosimulators_utils.model_lang.smoldyn package#

Submodules#

biosimulators_utils.model_lang.smoldyn.simularium_converter module#

Using the Biosimulators side of Smoldyn to generate a modelout.txt Smoldyn file for a specified OMEX/COMBINE archive which then is used to generate a .simularium file for the given simulation. That .simularium file is then stored along with the log.yml and report.{FORMAT} relative to the simulation. Remember: each simulation, while not inherently published, has the potential for publication based purely on the simulation’s ability to provide a valid OMEX/COMBINE archive. There exists (or should exist) an additional layer of abstraction to then validate and verify the contents therein.

class biosimulators_utils.model_lang.smoldyn.simularium_converter.BiosimulatorsDataConverter(archive: SmoldynCombineArchive)[source]#

Bases: ABC

static generate_camera_data_object(position: ndarray, look_position: ndarray, up_vector: ndarray) CameraData[source]#
static generate_display_data_object(name: str, radius: float, display_type=DISPLAY_TYPE.SPHERE, obj_color: str | None = None) DisplayData[source]#
generate_display_data_object_dict(agent_names: List[Tuple[str, str, float, str]]) Dict[str, DisplayData][source]#

Generate a display object dict.

Parameters:
  • agent_namesList[Tuple[str, str, float]] -> a list of tuples defining the Display Data configuration parameters.

  • such (The Tuple is expected to be as) – [(agent_name: str, display_name: str, radius: float, color: str)]

Returns:

Dict[str, DisplayData]

generate_input_file_data_object(model_output_file: str | None = None) InputFileData[source]#

Generates a new instance of simulariumio.data_model.InputFileData based on self.archive.model_output_filename (which itself is derived from the model file) if no model_output_file is passed.

Parameters:

model_output_file (str) – Optional: file on which to base the InputFileData instance.

Returns:

simulariumio input file data object based on self.archive.model_output_filename

Return type:

(InputFileData)

static generate_metadata_object(box_size: ndarray[int], camera_data: CameraData) MetaData[source]#
abstract generate_output_data_object(file_data: InputFileData, display_data: Dict[str, DisplayData] | None = None, spatial_units='nm', temporal_units='ns')[source]#

Generate a data object to fit the simulariumio.TrajectoryData interface.

abstract generate_simularium_file(simularium_filename: str, box_size: float, spatial_units='nm', temporal_units='ns', n_dim=3, display_data: Dict[str, DisplayData] | None = None) None[source]#

Create a data_object, optionally translate it, convert to simularium, and save.

prepare_agent_data() AgentData[source]#

Create a new instance of an AgentData object following the specifications of the simulation within the relative combine archive.

static prepare_simularium_fp(**simularium_config) str[source]#

Generate a simularium dir and joined path if not using the init object.

Kwargs:

(obj):**simularium_config: keys are ‘simularium_dirpath’ and ‘simularium_fname’

Returns:

str: complete simularium filepath

Return type:

(obj)

static save_simularium_file(data: SmoldynData | TrajectoryData, simularium_filename) None[source]#

Takes in either a SmoldynData or TrajectoryData instance and saves a simularium file based on it with the name of simularium_filename. If none is passed, the file will be saved in self.archive.rootpath

Parameters:
  • data (Union[SmoldynData, TrajectoryData]) – data object to save.

  • simularium_filename (str) – Optional: name by which to save the new simularium file. If None is passed, will default to self.archive.rootpath/self.archive.simularium_filename

abstract translate_data_object(data_object, box_size, n_dim) TrajectoryData[source]#

Create a mirrored negative image of a distribution and apply it to 3dimensions if AND ONLY IF it contains all non-negative values.

class biosimulators_utils.model_lang.smoldyn.simularium_converter.SmoldynCombineArchive(rootpath: str, outputs_dirpath: str | None = None, model_output_filename: str | None = None, simularium_filename: str | None = None, name='my_combine_archive')[source]#

Bases: object

get_manifest_filepath() List[str] | str[source]#

Read SmoldynCombineArchive manifest files. Return all filepaths containing the word ‘manifest’.

Returns:

path if there is just one manifest file, otherwise List[str] of manifest filepaths.

Return type:

str

set_model_filepath(model_filename: str | None = None) str | None[source]#
verify_smoldyn_in_manifest() bool[source]#

Pass the return value of self.get_manifest_filepath() into a new instance of CombineArchiveReader such that the string manifest object tuples are evaluated for the presence of smoldyn.

Returns:

Whether there exists a smoldyn model in the archive based on the archive’s manifest.

Return type:

bool

class biosimulators_utils.model_lang.smoldyn.simularium_converter.SmoldynDataConverter(archive: SmoldynCombineArchive)[source]#

Bases: BiosimulatorsDataConverter

generate_output_data_object(file_data: InputFileData, display_data: Dict[str, DisplayData] | None = None, meta_data: MetaData | None = None, spatial_units='nm', temporal_units='ns') SmoldynData[source]#
Generate a new instance of SmoldynData. If passing meta_data, please create a new MetaData instance

using the self.generate_metadata_object interface of this same class.

Parameters:
  • file_data – (InputFileData): simulariumio.InputFileData instance based on model output.

  • display_data – (Dict[Dict[str, DisplayData]]): Optional: if passing this parameter, please use the self.generate_display_object_dict interface of this same class.

  • meta_data – (Metadata): new instance of Metadata object. If passing this parameter, please use the self.generate_metadata_object interface method of this same class.

  • spatial_units – (str): spatial units by which to measure this simularium output. Defaults to nm.

  • temporal_units – (str): time units to base this simularium instance on. Defaults to ns.

Returns:

SmoldynData

generate_simularium_file(box_size=1.0, spatial_units='nm', temporal_units='ns', n_dim=3, simularium_filename: str | None = None, display_data: Dict[str, DisplayData] | None = None) None[source]#

Create a data_object, optionally translate it, convert to simularium, and save.

read_model_output_dataframe() DataFrame[source]#
translate_data_object(data_object: SmoldynData, box_size: float, n_dim=3) TrajectoryData[source]#

Create a mirrored negative image of a distribution and apply it to 3dimensions if AND ONLY IF it contains all non-negative values.

write_model_output_dataframe_to_csv(save_fp: str) None[source]#

biosimulators_utils.model_lang.smoldyn.utils module#

biosimulators_utils.model_lang.smoldyn.validation module#