# Fast and Interactive Positioning of Proteins within Membranes
## 2 Materials and Methods
### Software Components for Integration of IMPALA in an Interactive Setup  
Interactive molecular simulations allow the control and visualization of a molecular simulation, such as an ongoing membrane insertion. To this end, we developed a generic library called MDDriver that facilitates the implementation of such interactive simulations [22]. MDDriver allows the easy creation of a network socket between a molecular visualization user interface and a physics-based simulation engine. We use our own molecular visualization tool, UnityMol [23], to drive the dynamic behavior of the molecule in our IMPALA implementation. The relationship between these three software components is shown schematically in Figure 3 and uses standardized protocol and data structures for information exchange. More details on such interactive simulations can be found in [12].  
The visualization part uses the Unity game engine for development, whose C# language allows for modularity. It is possible to quickly test new features in a dedicated and proven framework for user experience, device management, user interface, etc. The IMD protocol is implemented natively in UnityMol and communicates directly with the MDDriver socket for simulation data exchange. Likewise, it is possible to extend the exchange to new data types by adding interaction features, as described later. The implementation of the IMPALA algorithm was built on our interactive simulation engine BioSpring [24].  
Figure 3: Interactive molecular simulations rely on three pillars: visualization, a network socket layer, and a simulation engine. Here, we show the three software components used in the present implementation and illustrate the data flow and task distribution.  
BioSpring, similar to molecular dynamics simulation engines, uses additive energy and force terms to represent the various contributions to a given model representation. Thus, the main task in implementing a new computational method such as IMPALA is to compute the forces and energies during the main simulation loop and add them to the other forces and energies, at least those generated by the user in an interactive experiment, and possibly to other force field or elastic network terms if, for example, flexibility is to be considered. The steps required to implement IMPALA are shown as pseudo-code in Figure 4.  
Before entering the main calculation loop, you may need to set some parameters. Within the loop, the surface area accessible to the solvent is first calculated for all particles, as it is entered into both Equations (2) and (3). Next, the IMPALA energy is calculated and  
Figure 4: Pseudo-code for adjustments to the main BioSpring calculation loop to accommodate the interactive method for calculating membrane insertion.  
added to the existing restraints, such as user-generated forces. Depending on whether you selected the option to enable molecular flexibility or to use a static model, either the spring network routines or the rigid body routines are then called to update the positions of the molecule under investigation. The energy calculations of IMPALA can easily be replaced by any alternative calculation of membrane insertion energetics that is desired. In future developments, one could envision a library of different methods from the literature from which the user could select on the fly the algorithm best suited for a particular task.