# **************************************************************************
# *
# * Authors: Carlos Oscar Sanchez Sorzano (coss@cnb.csic.es), March 2014
# * Slavica Jonic (slavica.jonic@upmc.fr)
# *
# * This program is free software; you can redistribute it and/or modify
# * it under the terms of the GNU General Public License as published by
# * the Free Software Foundation; either version 2 of the License, or
# * (at your option) any later version.
# *
# * This program is distributed in the hope that it will be useful,
# * but WITHOUT ANY WARRANTY; without even the implied warranty of
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# * GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License
# * along with this program; if not, write to the Free Software
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# * 02111-1307 USA
# *
# * All comments concerning this program package may be sent to the
# * e-mail address 'scipion@cnb.csic.es'
# *
# **************************************************************************
from pwem.emlib import (MetaData, MDL_NMA, MDL_ENABLED, MDL_NMA_MINRANGE,
MDL_NMA_MAXRANGE)
from pwem.objects import AtomStruct
from pyworkflow.protocol import STEPS_PARALLEL, PointerParam, BooleanParam
from xmipp3.convert import getImageLocation
from . import FlexProtConvertToPseudoAtomsBase
from .protocol_nma_base import *
from pwem.utils import runProgram
#from xmipp3.protocols.pdb.protocol_pseudoatoms_base import *
#from ..pdb.protocol_pseudoatoms_base import *
[docs]class FlexrotNMAChoose(FlexProtConvertToPseudoAtomsBase, FlexProtNMABase):
""" Protocol for choosing a volume to construct an NMA analysis """
_label = 'choose NMA'
def __init__(self, **args):
FlexProtConvertToPseudoAtomsBase.__init__(self, **args)
FlexrotNMABase.__init__(self, **args)
self.stepsExecutionMode = STEPS_PARALLEL
# --------------------------- DEFINE param functions --------------------------------------------
def _defineParams(self, form):
form.addSection(label='Input')
form.addParam('inputStructures', PointerParam, label="Input volumes",
important=True,
pointerClass='SetOfVolumes')
form.addParam('alignVolumes', BooleanParam, label="Align volumes",
default=False,
help="Align deformed PDBs to volume to maximize match")
FlexProtConvertToPseudoAtomsBase._defineParams(self, form)
form.addParallelSection(threads=4, mpi=1)
form.addSection(label='Normal Mode Analysis')
FlexProtNMABase._defineParamsCommon(self, form)
# --------------------------- INSERT steps functions --------------------------------------------
def _insertAllSteps(self):
inputStructures = self.inputStructures.get()
self.sampling = inputStructures.getSamplingRate()
filenames = []
for inputStructure in inputStructures:
filenames.append(getImageLocation(inputStructure))
deps = []
for volCounter in range(1, len(filenames) + 1):
fnIn = filenames[volCounter - 1]
prefix = "_%02d" % volCounter
fnMask = self._insertMaskStep(fnIn, prefix)
self._insertFunctionStep('convertToPseudoAtomsStep', inputStructure,
fnIn, fnMask, prefix, prerequisites=deps)
parentId = self._insertFunctionStep('computeNMAStep', self._getPath(
"pseudoatoms%s.pdb" % prefix), prefix)
deps = []
for volCounter2 in range(1, len(filenames) + 1):
if volCounter2 != volCounter:
args = "-i %s --pdb %s --modes %s --sampling_rate %f -o %s --fixed_Gaussian %f --opdb %s" % \
(filenames[volCounter2 - 1],
self._getPath("pseudoatoms%s.pdb" % prefix), \
self._getPath("modes%s.xmd" % prefix),
self.sampling, \
self._getExtraPath('alignment_%02d_%02d.xmd' % (
volCounter, volCounter2)), \
self.sampling * self.pseudoAtomRadius.get(),
self._getExtraPath('alignment_%02d_%02d.pdb' % (
volCounter, volCounter2)))
if self.alignVolumes.get():
args += " --alignVolumes"
stepId = self._insertRunJobStep("xmipp_nma_alignment_vol",
args,
prerequisites=[parentId])
deps.append(stepId)
self._insertFunctionStep('evaluateDeformationsStep', prerequisites=deps)
# --------------------------- Step functions --------------------------------------------
[docs] def convertToPseudoAtomsStep(self, inputStructure, fnIn, fnMask, prefix):
FlexProtConvertToPseudoAtomsBase.convertToPseudoAtomsStep(self, fnIn,
fnMask,
prefix)
self.createChimeraScriptStep(inputStructure, fnIn, prefix)
createLink(self._getPath("pseudoatoms%s.pdb" % prefix),
self._getPath("pseudoatoms.pdb"))
[docs] def computeNMAStep(self, fnIn, prefix):
cutoffStr = ''
if self.cutoffMode == NMA_CUTOFF_REL:
cutoffStr = 'Relative %f' % self.rcPercentage.get()
else:
cutoffStr = 'Absolute %f' % self.rc.get()
self.computeModesStep(fnIn, self.numberOfModes.get(), cutoffStr)
self.reformatOutputStep("pseudoatoms.pdb")
self.qualifyModesStep(self.numberOfModes.get(),
self.collectivityThreshold.get(), True)
fnModes = self._getPath("modes.xmd")
fnModesPrefix = self._getPath("modes%s.xmd" % prefix)
runProgram("xmipp_metadata_utilities",
"-i %s --operate modify_values \"nmaModeFile=replace(nmaModeFile,'/modes/','/modes%s/')\" -o %s" %
(fnModes, prefix, fnModesPrefix))
runProgram("mv", "%s %s" % (
self._getPath('modes'), self._getPath('modes%s' % prefix)))
# Remove intermediate files
cleanPath(self._getPath("pseudoatoms.pdb"), fnModes,
self._getExtraPath('vec_ani.pkl'))
# ToDo: the self.outputPdb should be a Pointer, not an object
# self._defineSourceRelation(self.outputPdb, self.outputModes)
# --------------------------- INFO functions --------------------------------------------
def _summary(self):
summary = []
summary.append(
'Pseudoatom radius (voxels): %f' % self.pseudoAtomRadius.get())
summary.append(
'Approximation target error (%%): %f' % self.pseudoAtomTarget.get())
return summary
def _methods(self):
summary = []
# summary.append('We converted the volume %s into a pseudoatomic representation with Gaussian atoms (sigma=%f A and a target error'\
# ' of %f%%) [Nogales2013].'%(self.inputStructure.get().getNameId(),
# self.pseudoAtomRadius.get()*self.inputStructure.get().getSamplingRate(),
# self.pseudoAtomTarget.get()));
# if self.hasAttribute('outputPdb'):
# summary.append('We refer to the pseudoatomic model as %s.'%self.outputPdb.getNameId())
return summary
def _citations(self):
return ['Nogales2013', 'Jin2014']