{'fraction_non_alphanumeric': 0.023777019340159272, 'fraction_numerical': 0.005858930602957907, 'mean_word_length': 5.100277585010409, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
LAST: Latent Space Assisted Adaptive Sampling for Protein Trajectories

Molecular dynamics (MD) simulation is widely used to study protein conformations and dynamics. However, conventional simulation suffers from being trapped in some local energy minima that are hard to escape. Thus, most computational time is spent sampling in the already visited regions. This leads to an inefficient sampling process and further hinders the exploration of protein movements in affordable simulation time. The advancement of deep learning provides new opportunities for protein sampling. Variational autoencoders are a class of deep learning models to learn a low-dimensional representation (referred to as the latent space) that can capture the key features of the input data. Based on this characteristic, we proposed a new adaptive sampling method, latent space assisted adaptive sampling for protein trajectories (LAST), to accelerate the exploration of protein conformational space. This method comprises cycles of (i) variational autoencoders training, (ii) seed structure selection on the latent space and (iii) conformational sampling through additional MD simulations. The proposed approach is validated through the sampling of four structures of two protein systems: two metastable states of E. Coli adenosine kinase (ADK) and two native states of Vivid (VVD). In all four conformations, seed structures were shown to lie on the boundary of conformation distributions. Moreover, large conformational changes were observed in a shorter simulation time when compared with conventional MD (cMD) simulations in both systems. In metastable ADK simulations, LAST explored two transition paths toward two stable states while cMD became trapped in an energy basin. In VVD light state simulations, LAST was three times faster than cMD simulation with a similar conformational space.


Introduction
Molecular dynamics (MD) simulation has wide application on the study of protein conformations and dynamics. Recent developments in bio-computing, such as Anton, 1 AMBER 2 and OpenMM, 3 have enabled the simulation time scale to milliseconds, which promotes the research in sampling protein motions and structure landscapes. 4,5 However, the time scales of many protein functions exceed the time scales achievable through traditional MD simulations. Moreover, protein sampling suffers from being trapped within local energy minima, proving difficult to escape. 6,7 As a result, most of the computational time is typically spent in sampling previously visited regions, which hinders efficient exploration of protein conformational space.
Many enhanced sampling methods have been developed to address this issue. These methods can be classified into two types. In the first type, biasing potentials are introduced to expand the sampling space, such as metadynamics 8,9 and Gaussian-accelerated MD. 10 In the second type, seed structures are selected as restarts for iterative MD simulations. This is referred to as adaptive sampling and numerous methods have been proposed that differ in seed selection methods. Markov state models have been applied to cluster conformations into microstates; 11 parallel cascade selection MD (PaCS-MD) 12 and nontargeted PaCS-MD 13 calculates the root-mean-square deviation (RMSD) to select top snapshots; frontier expansion sampling 14 [17][18][19][20] In our previous work, 21 we showed that VAEs are capable of learning a low-dimensional representation (referred to as the latent space) of protein systems. Through a quantitative study, the learned latent space is shown to be able to represent conformational characteristics. This property indicates that the larger differences two protein conformations have, the farther their corresponding latent points are from each other.
In this study, we proposed a new adaptive sampling method, latent space assisted adaptive sampling for protein trajectories (LAST), to accelerate the exploration of protein conformational space. This method iterates through three steps. First, a VAE is trained using previous MD simulations. Then, seed structures are selected on the learned latent space.
Finally, additional simulations are conducted with these selected seeds. To quantify the performance, we applied LAST on four conformations in two protein systems: two metastable states of E. Coli adenosine kinase (ADK) and two native states of Vivid (VVD). ADK conformations are projected onto two intrinsic angles while VVD conformations to RMSDs of two native structures. Our results showed that seed structures were consistently located on the boundary of sampled conformational distributions in all four conformations regardless of protein projection methods on reduced coordinates. We further compared the sampling efficiency between LAST and conventional MD (cMD). In both systems, large conformational changes were observed in a shorter time in LAST simulations. To be specific, LAST explored two transition paths toward two stable states while cMD being trapped in an energy basin in the metastable ADK simulations. In VVD simulations, LAST only took one third of cMD simulation time to discover a similar conformational space.

Variational Autoencoder
An autoencoder is a type of deep learning models that aims to encode a high-dimensional input to a low-dimensional latent space through an encoder module and decode it back to the original dimensions through a decoder module. By minimizing the differences between inputs and outputs, known as reconstruction loss, the latent space is expected to learn a low-dimensional representation of the input space. However, the latent space in an AE is not well-constrained and leads to unsatisfying results when sampling in the latent space. 22 To overcome this issue, variational autoencoders add an optimization constraint on the latent space to follow a certain distribution.
The encoder module q φ (z|x) is an inference model that transforms data x into output latent variable z, being parametrized with φ. In reverse, the decoder module p θ (x|z) is a generative model that transforms latent variable z into output datax, being parametrized with θ. Both models are trained simultaneously with a joint distribution as p(x, z) = p θ (x|z)p(z).
p(z) is the constraint distribution for latent space and typically is chosen as a normal distribution. 23 The tractable variational Bayes approach is used to approximate the intractable posterior p θ (z|x) = p θ (x|z)p(z)/( p θ (x|z)p(z)dz) by maximizing the Evidence Lower Bound (ELBO): where KL is the Kullback-Leibler divergence.
In our implementation, the VAE model is developed using Keras package 24 with Tensorflow backend. 25

Molecular Dynamics Simulations
The initial structures of four conformations in two protein systems: two metastable states (PDB ID 1DVR and 2AK3) of E. Coli adenosine kinase (ADK) and two native states (PDB ID 2PD7 and 3RH8) of Vivid (VVD) were taken from the Protein Data Bank (PDB) 26 . For each conformation, ligands and crystal waters were removed and chain A was extracted as the starting structure. The system was further solvated in a box of TIP3P water molecules and neutralized using Na + and Cl − . Simulation files were generated using tleap 27 with the AMBER ff14SB force filed. 28 100 ps NVT Langevin MD simulations were carried out,

VAE Training
In each iteration, some preprocessing procedures are needed. The simulation trajectories are firstly aligned to the first frame and heavy atoms are extracted with Cartesian coordinates being expanded as a feature vector ( Figure 1A-B). Then, each feature is transformed to a range of 0 to 1 using min-max linear scaling, which is used to construct a dataset for VAE training.
The architecture of VAE model is shown in Figure 1C. In the current study, we design

Seeds Selection
Appropriate seed selection method is needed to expedite the sampling of protein conformational space. In LAST, seeds are selected on the two-dimensional learned latent space of VAE, which has two important characteristics to enable an efficient seeds selection. First, as demonstrated in our previous work, the distance between two data points on the latent space is meaningful. Two structurally similar proteins have a shorter distance between their corresponding latent vectors. Second, the sampling distribution of latent space in the VAE is similar to a normal distribution due to the KL divergence term in the loss function. As for the distribution of the VAE latent space of protein conformations, the most common protein structures are encoded in the center of the latent space while structurally different proteins are encoded on the boundary. In a data distribution, outliers refer to those points that differ significantly from other data. Based on the above two points, it is reasonable to treat outliers on the latent space as seeds to accelerate conformational space exploration, as their conformations deviate the majority of the sampled ones.
To implement the seed selection method, we propose three improvements to make LAST computationally efficient.
1. Latent space of VAE is not strictly normal after optimization even though the normality is incentivized in the loss function. Therefore, a non-parametric multivariate kernel density estimator, instead of multivariate normal density function, is used to fit the latent space. The estimator is developed in Python statsmodels library. 29 2. Latent space distribution might be skewed so that the top N outliers with the smallest probability densities tend to gather on one side of distribution. To avoid the above issue, the cumulative distribution function (CDF) of combined data distribution on the latent space, instead of probability density, is applied to guarantee that samples from both sides of CDF (values close to 0 and 1) are equally selected.
3. Protein conformations corresponding to outliers can be located and selected based on data index. These protein conformations might be similar to each other, resulting in sampling repeated conformational space from MD simulations starting from these conformations. Thus, to further boost sampling efficiency, we require new seed structures to have at least 1Å RMSD with all previously selected seeds.
One example of seeds selection result is shown in Figure 1D, where seeds are highlighted in red stars in the latent space visualization.

Additional MD Simulations
Short MD simulations are conducted in each round. In the current study, 10 seeds are selected in one round and 100ps simulation is done starting from each seed. Thus, the total simulation time in each round is 1ns. The detail of these simulations is described in section 2.2.
The above three steps are iteratively done until convergence. Here, we design the convergence criterion by calculating the mean RMSD of Cα atoms with regard to the starting protein structure. The iterative sampling process is terminated once the mean RMSD stops to increase for successive five rounds or reaches the maximum round number. The LAST algorithm is summarized in Algorithm 1 with codes are freely available at the GitHub site of https://github.com/smu-tao-group/LAST.

Results
Four structures of two protein systems (ADK and VVD) were prepared for MD simulations as Proper low-dimensional protein representations are needed to evaluate the quality of seed selection. In the current study, ADK protein structure is projected to LID-CORE and NMP-CORE 2D angle plot. We followed the same reside selection rule to calculate vectors and angles. 21 For VVD structure, 2D root-mean-square deviation (RMSD) with reference to the native dark and light structures was used to show the sampled protein conformational space.
Both the angle plot in ADK and RMSD plot in VVD were used to display the protein conformation of seed structures (Figure 3). In each subplot, seed structures are highlighted as red stars. In two metastable ADK conformations ( Figure 3A  To compare the effectiveness of LAST to conventional molecular dynamics simulations, the sampled protein conformational space in each round of LAST method is displayed to- However, cMD simulation was being trapped in an energy basin, which is also indicated in the free energy plot of LAST. This demonstrates that LAST has a better chance to jump out of energy minimum without biasing potential energies. For the VVD system, LAST simulation took 30 iterations (30 ns simulation time) to converge. The conformational space is illustrated in Figure 6A. Two cMD simulations were

Discussion
In this study, we proposed a new adaptive sampling method to explore protein conformational to follow a normal distribution). Therefore, in order to have a well-constructed and normal regularized latent space, appropriate weights are needed to be set for both terms. This is a challenging task with finetuning by hand, as the sample size keeps growing linearly with additional MD simulations in each round. Therefore, instead of trying to find weights to balance the reconstruction loss and KL divergence, we allow the latent space not strictly follow a normal distribution and use a non-parametric multivariate kernel density estimator to fit the latent space.
One potential problem is that the distribution of the latent space might be skewed or kurtotic. In such cases, one side of probability density function will have a long tail with low values. This could lead to the situation that all selected seed structures lie in the long tail side, and the corresponding protein structures of these seeds might be similar to each other. Seeds gathering on one side of latent space distribution decreases the chance to explore more structurally different conformations and thus leads to a less efficient protein sampling process. To partially overcome this issue, we used the cumulative distribution function to select outliers: data points on the two sides of the CDF are evenly selected. This improvement prevents sampling similar seeds on the boundary of protein conformational spaces.
Still, seed structures might be similar to each other. Nontargeted PaCS-MD proposed a nonredundant selection rule which calculates pairwise RMSDs between the current simulation cycle and seeds selected in all the past cycles. 35 Protein configurations with large RMSD are then selected as new seeds in the current cycle. We took reference from this idea to select seeds. Outliers from two ends of the estimated CDF are picked sequentially while the pairwise RMSDs to previously selected seeds are calculated. We required the RMSD threshold should be greater than 1Å. If not, LAST discards this outlier and moves to the next. Moreover, LAST is a memory method: the selected seed structures are stored for RMSD calculation in future iterations, which avoids repeated sampling in the same conformational region and further improves the sampling efficiency.
There are some tuning parameters in the LAST sampling scheme, including the number of seed structures, the RMSD threshold in seed selection, the architecture of VAE model and the number of rounds in convergence. In this work, 10 seeds are selected in each round.
This could be changed under different protein systems and is subjected to the available computing resources. Also, the MD simulation time starting from seeds, currently set as 100 ps, can be adjusted accordingly. However, it should be noted that this simulation time should match the RMSD threshold: the simulation time should not be too short with large RMSD threshold. Given that the conformational space of selected seeds is not likely to be visited again, it is expected to have a reasonable simulation time to fully explore the conformations in each additional MD run. Besides, the number of hidden layers in VAE model is important to learn a useful latent space. Our previous finding suggests that a VAE model with three hidden layers is sufficient to learn the ADK protein conformations. Larger model architectures do not have a significant improvement but instead will lead to longer training time. The proper architecture of VAE, in terms of the number of hidden layers and the number of dimensions in the latent space, is worth studying to provide general guidelines when dealing with different protein families. Lastly, it is worth noting that the convergence criterion used in this study does not represent the "true" convergence of protein systems. The notion of "true" convergence, as discussed in previous studies, [36][37][38] is elusive in simulations. More appropriate criteria are needed for the convergence signal in adaptive sampling, through either numerical indicators or self-consistency checks.

Conclusion
In this study, we present an adaptive sampling method, latent space assisted adaptive sampling for protein trajectories, to accelerate the exploration of protein conformational spaces.
LAST iterates through variational autoencoder training, seed selection and additional short MD simulations. LAST differs with previous methods in seed selection where the outliers in the learned latent space are selected and treated as seed structures. We tested LAST method in ADK and VVD protein systems, each with different low-dimensional protein representations. In both systems, LAST can capture the key protein characteristics and select seeds that lie in the boundary of conformational space. For ADK simulations, LAST explored two transition paths that are in agreement with previous findings. For VVD simulations, LAST is three times faster than conventional MD for exploring the same conformational regions.