@@ -590,6 +590,14 @@ def analyse(
590590 f"traj { type (traj )} must be of type 'BioSimSpace.Trajectory._trajectory.Trajectory'"
591591 )
592592
593+ n_frames = traj .nFrames ()
594+ if not n_frames >= 50 :
595+ _warnings .warn (
596+ f"The trajectory for restraint selection has less than 50 frames ({ n_frames } frames). "
597+ "This may result in poor restraint selection with excessively high force constants. "
598+ "Consider running a longer simulation or saving more frames."
599+ )
600+
593601 if not isinstance (temperature , _Temperature ):
594602 raise ValueError (
595603 f"temperature { type (temperature )} must be of type 'BioSimSpace.Types.Temperature'"
@@ -667,6 +675,18 @@ def analyse(
667675 decoupled_mol = _system .getDecoupledMolecules ()[0 ]
668676 decoupled_resname = decoupled_mol .getResidues ()[0 ].name ()
669677
678+ # Warn the user if the decoupled molecule is water or a macromoelcule
679+ if decoupled_mol .isWater ():
680+ _warnings .warn (
681+ "The decoupled molecule is water. Ensure that this is intended. Using constrained water hydrogens as anchor "
682+ "points may produce instabilities."
683+ )
684+
685+ if decoupled_mol .nResidues () > 1 :
686+ _warnings .warn (
687+ "The decoupled molecule has more than one residue and is likely a macromolecule. Ensure that this is intended."
688+ )
689+
670690 ligand_selection_str = f"((resname { decoupled_resname } ) and (not name H*))"
671691 if append_to_ligand_selection :
672692 ligand_selection_str += " and "
@@ -1012,6 +1032,20 @@ def _findOrderedPairs(u, ligand_selection_str, receptor_selection_str, cutoff):
10121032 """
10131033
10141034 lig_selection = u .select_atoms (ligand_selection_str )
1035+
1036+ # Ensure that there are no shared atoms between the ligand selection and all possible receptor selections.
1037+ all_possible_receptor_selection = u .select_atoms (receptor_selection_str )
1038+ shared_atoms = [
1039+ atom for atom in lig_selection if atom in all_possible_receptor_selection
1040+ ]
1041+ if shared_atoms :
1042+ raise _AnalysisError (
1043+ "Shared atoms between ligand and receptor selections detected. "
1044+ "Please ensure that you are decoupling the intended molecule and that "
1045+ "the ligand and receptor selections are mutually exclusive. "
1046+ f"Shared atoms: { shared_atoms } "
1047+ )
1048+
10151049 pair_variance_dict = {}
10161050
10171051 # Get all receptor atoms within specified distance of cutoff
@@ -1488,7 +1522,9 @@ def _findOrderedBoresch(
14881522 dtheta = abs (val - circmean )
14891523 corrected_values .append (min (dtheta , 2 * _np .pi - dtheta ))
14901524 corrected_values = _np .array (corrected_values )
1491- boresch_dof_data [pair ][dof ]["var" ] = corrected_values .var ()
1525+ boresch_dof_data [pair ][dof ]["var" ] = _np .mean (
1526+ corrected_values ** 2
1527+ )
14921528
14931529 # Assume Gaussian distributions and calculate force constants for harmonic potentials
14941530 # so as to reproduce these distributions at 298 K
0 commit comments