diff --git a/prody/dynamics/functions.py b/prody/dynamics/functions.py index 0cdb961e3..e565101ba 100644 --- a/prody/dynamics/functions.py +++ b/prody/dynamics/functions.py @@ -512,7 +512,7 @@ def parseScipionModes(metadata_file, title=None, pdb=None, parseIndices=False): def writeScipionModes(output_path, modes, write_star=False, scores=None, - only_sqlite=False, collectivityThreshold=0.): + only_sqlite=False, collectivityThreshold=0., norm=True): """Writes *modes* to a set of files that can be recognised by Scipion. A directory called **"modes"** will be created if it doesn't already exist. Filenames inside will start with **"vec"** and have the mode number as the extension. @@ -538,6 +538,10 @@ def writeScipionModes(output_path, modes, write_star=False, scores=None, :arg collectivityThreshold: collectivity threshold below which modes are not enabled Default is 0. :type collectivityThreshold: float + + :arg norm: whether to normalize mode vectors before calculating collectivities + Default is **True** + :type norm: bool """ if not isinstance(output_path, str): raise TypeError('output_path should be a string, not {0}' @@ -567,6 +571,10 @@ def writeScipionModes(output_path, modes, write_star=False, scores=None, raise TypeError('collectivityThreshold should be float, not {0}' .format(type(collectivityThreshold))) + if not isinstance(norm, bool): + raise TypeError('norm should be boolean, not {0}' + .format(type(norm))) + if modes.numModes() == 1 and not isinstance(modes, (NMA, ModeSet)): old_modes = modes modes = NMA(old_modes) @@ -586,6 +594,12 @@ def writeScipionModes(output_path, modes, write_star=False, scores=None, modefiles.append(writeArray(modes_dir + 'vec.{0}'.format(mode_num), mode.getArray(), '%12.4e', '')) + if norm: + eigvecs = modes.getEigvecs() + eigvecs /= np.array([((evecs[:, i]) ** 2).sum() ** 0.5 + for i in range(evecs.shape[1])]) + modes.setEigens(eigvecs, eigvals) + if modes.numModes() > 1: order = modes.getIndices() collectivities = list(calcCollectivity(modes))