def __runEman2Program(self, program, args): """ Internal workaround to launch an EMAN2 program. """ from pwem import Domain eman2 = Domain.importFromPlugin('eman2') from pyworkflow.utils.process import runJob runJob(self._log, eman2.Plugin.getProgram(program), args, env=eman2.Plugin.getEnviron())
def __runEman2Program(self, program, args): """ Internal workaround to launch an EMAN2 program. """ import pyworkflow.em.packages.eman2 as eman2 from pyworkflow.utils.process import runJob runJob(self._log, eman2.getEmanProgram(program), args, env=eman2.getEnviron())
def __runEman2Program(cls, program, args): """ Internal workaround to launch an EMAN2 program. """ eman2 = pwutils.importFromPlugin('eman2') from pyworkflow.utils.process import runJob runJob(None, eman2.Plugin.getProgram(program), args, env=eman2.Plugin.getEnviron())
def runJob(self, log, programName, params, numberOfMpi=1, numberOfThreads=1, env=None, cwd=None): """ This function is a wrapper around runJob, providing the host configuration. """ process.runJob(log, programName, params, numberOfMpi, numberOfThreads, self.hostConfig, env=env, cwd=cwd)
def _computePSD(self, inputFn, outputFn, scaleFactor=6): """ Generate a thumbnail of the PSD with EMAN2""" args = "%s %s " % (inputFn, outputFn) args += "--process=math.realtofft --meanshrink %s " % scaleFactor args += "--fixintscaling=sane" from pwem import Domain eman2 = Domain.importFromPlugin('eman2') from pyworkflow.utils.process import runJob runJob(self._log, eman2.Plugin.getProgram('e2proc2d.py'), args, env=eman2.Plugin.getEnviron()) return outputFn
def _generateAnimation(self): prot = self.protocol projectorFile = prot.getProjectorFile() animation = self.trajectoriesWindow.getAnimationName() animationPath = prot._getExtraPath('animation_%s' % animation) cleanPath(animationPath) makePath(animationPath) animationRoot = join(animationPath, 'animation_%s' % animation) trajectoryPoints = np.array( [p.getData() for p in self.trajectoriesWindow.pathData]) if projectorFile: M = np.loadtxt(projectorFile) deformations = np.dot(trajectoryPoints, np.linalg.pinv(M)) np.savetxt(animationRoot + 'trajectory.txt', trajectoryPoints) else: Y = np.loadtxt(prot.getOutputMatrixFile()) X = np.loadtxt(prot.getDeformationFile()) # Find closest points in deformations deformations = [ X[np.argmin(np.sum((Y - p)**2, axis=1))] for p in trajectoryPoints ] pdb = prot.getInputPdb() pdbFile = pdb.getFileName() modesFn = prot.inputNMA.get()._getExtraPath('modes.xmd') for i, d in enumerate(deformations): atomsFn = animationRoot + 'atomsDeformed_%02d.pdb' % (i + 1) cmd = '-o %s --pdb %s --nma %s --deformations %s' % ( atomsFn, pdbFile, modesFn, str(d)[1:-1]) runJob(None, 'xmipp_pdb_nma_deform', cmd, env=prot._getEnviron()) # Join all deformations in a single pdb # iterating going up and down through all points # 1 2 3 ... n-2 n-1 n n-1 n-2 ... 3, 2 n = len(deformations) r1 = range(1, n + 1) r2 = range(2, n) # Skip 1 at the end r2.reverse() loop = r1 + r2 trajFn = animationRoot + '.pdb' trajFile = open(trajFn, 'w') for i in loop: atomsFn = animationRoot + 'atomsDeformed_%02d.pdb' % i atomsFile = open(atomsFn) for line in atomsFile: trajFile.write(line) trajFile.write('TER\nENDMDL\n') atomsFile.close() trajFile.close() # Delete temporary atom files cleanPattern(animationRoot + 'atomsDeformed_??.pdb') # Generate the vmd script vmdFn = animationRoot + '.vmd' vmdFile = open(vmdFn, 'w') vmdFile.write(""" mol new %s animate style Loop display projection Orthographic mol modcolor 0 0 Index mol modstyle 0 0 Beads 1.000000 8.000000 animate speed 0.5 animate forward """ % trajFn) vmdFile.close() VmdView(' -e ' + vmdFn).show()
def _generateAnimation(self): prot = self.protocol projectorFile = prot.getProjectorFile() animation = self.trajectoriesWindow.getAnimationName() animationPath = prot._getExtraPath('animation_%s' % animation) cleanPath(animationPath) makePath(animationPath) animationRoot = join(animationPath, 'animation_%s' % animation) trajectoryPoints = np.array([p.getData() for p in self.trajectoriesWindow.pathData]) if projectorFile: M = np.loadtxt(projectorFile) deformations = np.dot(trajectoryPoints, np.linalg.pinv(M)) np.savetxt(animationRoot + 'trajectory.txt', trajectoryPoints) else: Y = np.loadtxt(prot.getOutputMatrixFile()) X = np.loadtxt(prot.getDeformationFile()) # Find closest points in deformations deformations = [X[np.argmin(np.sum((Y - p)**2, axis=1))] for p in trajectoryPoints] pdb = prot.getInputPdb() pdbFile = pdb.getFileName() modesFn = prot.inputNMA.get()._getExtraPath('modes.xmd') for i, d in enumerate(deformations): atomsFn = animationRoot + 'atomsDeformed_%02d.pdb' % (i+1) cmd = '-o %s --pdb %s --nma %s --deformations %s' % (atomsFn, pdbFile, modesFn, str(d)[1:-1]) runJob(None, 'xmipp_pdb_nma_deform', cmd, env=prot._getEnviron()) # Join all deformations in a single pdb # iterating going up and down through all points # 1 2 3 ... n-2 n-1 n n-1 n-2 ... 3, 2 n = len(deformations) r1 = range(1, n+1) r2 = range(2, n) # Skip 1 at the end r2.reverse() loop = r1 + r2 trajFn = animationRoot + '.pdb' trajFile = open(trajFn, 'w') for i in loop: atomsFn = animationRoot + 'atomsDeformed_%02d.pdb' % i atomsFile = open(atomsFn) for line in atomsFile: trajFile.write(line) trajFile.write('TER\nENDMDL\n') atomsFile.close() trajFile.close() # Delete temporary atom files cleanPattern(animationRoot + 'atomsDeformed_??.pdb') # Generate the vmd script vmdFn = animationRoot + '.vmd' vmdFile = open(vmdFn, 'w') vmdFile.write(""" mol new %s animate style Loop display projection Orthographic mol modcolor 0 0 Index mol modstyle 0 0 Beads 1.000000 8.000000 animate speed 0.5 animate forward """ % trajFn) vmdFile.close() VmdView(' -e ' + vmdFn).show()
def lanchEmanForTomogram(self, tomo): # self._moveCoordsToInfo(tomo) program = emantomo.Plugin.getProgram("e2spt_boxer.py") arguments = "%s" % os.path.abspath(tomo.getFileName()) runJob(None, program, arguments, env=emantomo.Plugin.getEnviron(), cwd=self.path)
def __runEman2Program(self, program, args): """ Internal workaround to launch an EMAN2 program. """ import pyworkflow.em.packages.eman2 as eman2 from pyworkflow.utils.process import runJob runJob(None, eman2.getEmanProgram(program), args, env=eman2.getEnviron())