System

Description

The System class is a class used to store all the information on the atoms belonging to a specific molecule type and required to process Machine Learning training and predictions in ML-LPA.

Attributes and Methods

Initialisation

Instances of the System class can be generated in ML-LPA via two functions:

It is recommended to use these functions to generate the instances of the class. However, if one wants to generate it by calling the class, the following data are required:

  1. The name of the molecule type, as listed by the getTypes() function.

  2. The array of positions of the atom in the correct dimensions, as extracted by the extractPositions() function.

  3. The dictionary of information of the molecule type, as extracted by the getMolInfos() function.

  4. The array of dimensions of the simulation box over time, in the correct dimensions, as extracted by the extractPositions() function.

Attributes

Name Type  Description
system.type str Name of the molecule type stored in the instance. 
system.positions np.ndarray Positions of all the atoms of each molecules collected.
system.boxes np.ndarray Dimensions of the simulation box.
system.infos dict Dictionary containing all relevant informations on the molecules (e.g. atom masses, bonds).
system.coordinates np.ndarray  Coordinates of the atoms of each molecule, after centering the molecule on their centers of mass and rotation.
system.distances np.ndarray  Distances between atoms pairs, pairs are set to a given neighbor rank.
system.rank int Rank used for the distance calculation.
system.phases np.ndarray Phases of each molecules in the system.

Methods

Name Argument(s)  Description
system.getCoordinates() <ul><li>up=, {bool}, (Opt.) Make sure the molecule is always pointing “up”. Default is True.</li></ul> Compute the coordinate set based on the atom positions of the system. The results are directly stored in the instance.
system.getDistances() <ul><li>rank=, {int}, (Opt.) Rank for the distance calculation. Default is 6.</li></ul> Calculate the distance between atom pairs based on the atom positions of the system and the neighbor rank. The results are directly stored in the instance.
system.getPhases() <ul><li>models, {str or dict of models}, Path to the model files or dictionary of the models to use to predict the states.</li></ul> Predict the phases of all the molecules in the system using the provided models. Return the array of phases.
system.setPhases() <ul><li>phases, {str or np.ndarray}, Phases to apply to the molecules of the system.</li></ul> Set manually the phases of all the molecules in the system using the provided models. Return the array of phases.
system.save() <ul><li>file_path, {str}, Path and name of the file to generate.</li><li>format, {str}, File extension and format to use for the output file.</li></ul> Save the instance of the System class in a file.

The .save() method uses the same argument and generates the same files than the saveSystems() function.

Examples

Initialise an instance of the class

The following example will initialise an instance of the System class, named here loaded_system, from the given molecule type DPPC, the position array atom_positions, the dictionary of type information mol_infos, and the array of dimensions of the simulation boxes, simulation_boxes.

from mllpa.system_class import System

loaded_system = System("DPPC", position_array, mol_infos, simulation_boxes)

Convert the positions into coordinates

The following example will convert the position array inside the instance of the System class loaded_system into the array of coordinates directly stored in the instance.

loaded_system.getCoordinates()

Convert the positions into distances

The following example will convert the position array inside the instance of the System class loaded_system into the array of distances directly stored in the instance. The conversion will use a neighbor rank equals to 6.

loaded_system.getDistances(rank=6)

Prediction with a model file

The following example will use the model file new_model.lpm to predict the phase of loaded_system, an instance of the System class. The output will be stored in the attributes of the instance.

loaded_system.getPhases("./new_model.lpm")

Prediction with a model dictionary

The following example will use the models stored in the variable models to predict the phase of loaded_system, an instance of the System class. The output will be stored in the instance.

loaded_system.getPhases(models)

Assigning a single phase

The following example will assign the phase name fluid to all molecules of loaded_system, an instance of the System class. The output will be stored in the attributes of the instance.

loaded_system.setPhases("fluid")

Assigning a phase array

The following example will assign the array of phases phase_array to loaded_system, an instance of the System class. The output will be stored in the instance of the System class.

loaded_system.setPhases(phase_array)

### Save the instance in a file

The following example will save the content of the instance of the System class loaded_system in a file test_file.xml

loaded_system.save(file_path='test_file.xml')

The following function(s) uses the System class either in their input our output:

The following tutorial(s) detail further the use of the System class: