def close(self, e=None): try: print("Deleting temporary folder: ", customUserData) pwutils.cleanPath(customUserData) except Exception as ex: print("Error: ", ex) ProjectWindow.close(self, e)
def close(self, e=None): try: print("Writing protocols to: ", jsonFn) proj.getRunsGraph(refresh=True) # Build project runs graph proj.exportProtocols(proj.getRuns(), jsonFn) print("Deleting temporary folder: ", customUserData) pwutils.cleanPath(customUserData) except Exception as ex: print("Error saving the workflow: ", ex) ProjectWindow.close(self, e)
class EditorProjectWindow(ProjectWindow): def close(self, e=None): try: print "Deleting temporary folder: ", customUserData pwutils.cleanPath(customUserData) except Exception, ex: print "Error: ", ex ProjectWindow.close(self, e)
def openProject(projectName): """ Opens a scipion project: :param projectName: Name of a existing project to open, or "here" to create a project in the current working dir, or "last" to open the most recent project """ manager = Manager() projName = os.path.basename(projectName) # Handle special name 'here' to create a project # from the current directory if projName == 'here': cwd = Config.SCIPION_CWD if " " in cwd: print("Projects can't have spaces in the name: %s" % cwd) sys.exit(1) print("\nYou are trying to create a project here:", pwutils.cyan(cwd)) if os.listdir(cwd): print(pwutils.red('\nWARNING: this folder is not empty!!!')) key = input("\nDo you want to create a project here? [y/N]?") if key.lower().strip() != 'y': print("\nAborting...") sys.exit(0) else: print("\nCreating project....") projName = os.path.basename(cwd) projDir = os.path.dirname(cwd) manager.createProject(projName, location=projDir) elif projName == 'last': # Get last project projects = manager.listProjects() if not projects: sys.exit("No projects yet, cannot open the last one.") projName = projects[0].projName projPath = manager.getProjectPath(projName) projWindow = ProjectWindow(projPath) projWindow.show()
class EditorProjectWindow(ProjectWindow): def close(self, e=None): try: print "Writing protocols to: ", jsonFn proj.getRunsGraph() # Build project runs graph proj.exportProtocols(proj.getRuns(), jsonFn) print "Deleting temporary folder: ", customUserData pwutils.cleanPath(customUserData) except Exception, ex: print "Error saving the workflow: ", ex ProjectWindow.close(self, e)
plotter.createSubPlot(title, 'atom index', ylabel) plotter.plotMdFile(mdFn, None, xmippLib.MDL_NMA_ATOMSHIFT) return plotter def createDistanceProfilePlot(protocol, modeNumber): vectorMdFn = protocol._getExtraPath("distanceProfiles", "vec%d.xmd" % modeNumber) plotter = createShiftPlot(vectorMdFn, "Atom shifts for mode %d" % modeNumber, "shift") return plotter def createVmdView(protocol, modeNumber): vmdFile = protocol._getExtraPath("animations", "animated_mode_%03d.vmd" % modeNumber) return VmdView('-e "%s"' % vmdFile) def showDistanceProfilePlot(protocol, modeNumber): createDistanceProfilePlot(protocol, modeNumber).show() def showVmdView(protocol, modeNumber): createVmdView(protocol, modeNumber).show() ProjectWindow.registerObjectCommand(OBJCMD_NMA_PLOTDIST, showDistanceProfilePlot) ProjectWindow.registerObjectCommand(OBJCMD_NMA_VMD, showVmdView)
print "ERROR: ", msg print "\nUSAGE: scipion tutorial [TUTORIAL_NAME]" print "\nwhere TUTORIAL_NAME can be:" print "\n".join([' %s' % k for k in ALL_TUTORIALS.keys()]) if pwutils.envVarOn('SCIPION_DEBUG'): # Add callback for remote debugging if available. try: from rpdb2 import start_embedded_debugger from signal import signal, SIGUSR2 signal(SIGUSR2, lambda sig, frame: start_embedded_debugger('a')) except ImportError: pass if len(sys.argv) == 2: manager = Manager() tutorialName = sys.argv[1] if not tutorialName in ALL_TUTORIALS: printUsage("Invalid tutorial '%s'." % tutorialName) else: # Instanciate the proper tutorial class tutorial = ALL_TUTORIALS[tutorialName]() projWindow = ProjectWindow(tutorial.project.getName()) projWindow.show() else: msg = 'Too many arguments.' if len(sys.argv) > 2 else '' printUsage(msg)
# we only consider the 'doSaveUnweightedMic' flag if the # weighted ones should be created. return (self.doSaveAveMic and self.doSaveUnweightedMic) def _createOutputWeightedMicrographs(self): return (self.doSaveAveMic and self.doApplyDoseFilter) def _getOutputMovieUnWtName(self, movie): """ Returns the name of the output dose-weighted movie. (relative to micFolder) """ return self._getMovieRoot(movie) + '_aligned_movie.mrcs' def showCartesianShiftsPlot(inputSet, itemId): item = inputSet[itemId] if item.hasAttribute('_xmipp_OFMeanX'): meanX = [float(x) for x in item._xmipp_OFMeanX] meanY = [float(y) for y in item._xmipp_OFMeanY] plotter = createAlignmentPlot(meanX, meanY) plotter.show() else: print("These items do not have OF alignment set. ") ProjectWindow.registerObjectCommand(OBJCMD_MOVIE_ALIGNCARTESIAN, showCartesianShiftsPlot) # Just for backwards compatibility ProtMovieAlignment = XmippProtOFAlignment
""" import pickle import sys import os from pyworkflow.project import Manager, Label from pyworkflow.gui.project import ProjectWindow if __name__ == '__main__': manager = Manager() projName = os.path.basename(sys.argv[1]) projPath = manager.getProjectPath(projName) projWindow = ProjectWindow(projPath) proj = projWindow.project sett = proj.getSettings() sett.setColorMode(sett.COLOR_MODE_LABELS) with open(proj.getPath('labels.pkl'), 'r') as f: labelsDict, colorsDict = pickle.load(f) for labelName, prots in labelsDict.iteritems(): label = Label(name=labelName, color=colorsDict[labelName]) sett.getLabels().addLabel(label) for protId in prots: node = sett.getNodeById(protId) node.setLabels([labelName])
if i == 0: res['freq'] = [float(x) for x in line.split()] elif i == 2: res['amp'] = [float(x) for x in line.split()] elif i == 3: res['fit'] = [float(x) for x in line.split()] elif i == 4: res['quality'] = [float(x) for x in line.split()] break i += 1 return res OBJCMD_CTFFIND4 = "CTFFind plot results" ProjectWindow.registerObjectCommand(OBJCMD_CTFFIND4, createCtfPlot) class CtffindViewer(Viewer): """ Specific way to visualize SetOfCtf. """ _environments = [DESKTOP_TKINTER] _targets = [CistemProtCTFFind] def _visualize(self, prot, **kwargs): outputCTF = getattr(prot, 'outputCTF', None) if outputCTF is not None: ctfView = CtfView(self._project, outputCTF) viewParams = ctfView.getViewParams() viewParams[showj.OBJCMDS] = "'%s'" % OBJCMD_CTFFIND4 return [ctfView]
'CTF', yformat=False) a.invert_xaxis() for i in range(1, 5): _plotCurve(a, i, fn) xplotter.showLegend([ 'simulated CTF', 'equiphase avg.', 'equiphase avg. - bg', 'cross correlation' ]) a.grid(True) xplotter.show() OBJCMD_GCTF = "Display Ctf Analysis" ProjectWindow.registerObjectCommand(OBJCMD_GCTF, createCtfPlot) def _plotCurve(a, i, fn): freqs = _getValues(fn, 0) curv = _getValues(fn, i) a.plot(freqs, curv) def _getValues(fn, col): f = open(fn) values = [] for line in f: if not line.startswith('Resolution', 2, 12): column = line.split() value = float(column[col])
def showExtraFile(volumeSet, volId, suffix): vol = volumeSet[volId] volFn = vol.getFileName().replace('.hdf', suffix) vw.DataView(volFn).show() def showClassAvgProjs(volumeSet, volId): showExtraFile(volumeSet, volId, '_aptcl.hdf') def showProjs(volumeSet, volId): showExtraFile(volumeSet, volId, '_proj.hdf') def showInitialRandomVolume(volumeSet, volId): showExtraFile(volumeSet, volId, '_init.hdf') ProjectWindow.registerObjectCommand(OBJCMD_CLASSAVG_PROJS, showClassAvgProjs) ProjectWindow.registerObjectCommand(OBJCMD_PROJS, showProjs) ProjectWindow.registerObjectCommand(OBJCMD_INITVOL, showInitialRandomVolume) class RefineEasyViewer(ProtocolViewer): """ Visualization of Refine Easy.""" _targets = [EmanProtRefine] _environments = [DESKTOP_TKINTER, WEB_DJANGO] _label = 'viewer Refine Easy' def _defineParams(self, form): self._env = os.environ.copy() form.addSection(label='Results per Iteration') form.addParam('iterToShow', EnumParam,
legendName = ['rotational avg. No Astg', 'rotational avg.', 'CTF Fit', 'Cross Correlation', '2sigma cross correlation of noise'] for i in range(1, 6): _plotCurve(a, i, fn) xplotter.showLegend(legendName) a.grid(True) xplotter.show() OBJCMD_CTFFIND4 = "Display Ctf Fitting" ProjectWindow.registerObjectCommand(OBJCMD_CTFFIND4, createCtfPlot) class CtffindViewer(Viewer): """ Specific way to visualize SetOfCtf after Gctf. """ _environments = [DESKTOP_TKINTER, WEB_DJANGO] _targets = [ProtCTFFind] def _visualize(self, prot, **kwargs): outputCTF = getattr(prot, 'outputCTF', None) if outputCTF is not None: ctfView = CtfView(self._project, outputCTF) viewParams = ctfView.getViewParams() viewParams[showj.OBJCMDS] = "'%s'" % OBJCMD_CTFFIND4 return [ctfView]
return (self.doSaveAveMic and self.doSaveUnweightedMic) def _createOutputWeightedMicrographs(self): return (self.doSaveAveMic and self.doApplyDoseFilter) def _getOutputMovieWtName(self, movie): """ Returns the name of the output dose-weighted movie. (relative to micFolder) """ return self._getMovieRoot(movie) + '_aligned_movie_DW.mrcs' def showCartesianShiftsPlot(inputSet, itemId): item = inputSet[itemId] if item.hasAttribute('_xmipp_OFMeanX'): meanX = [float(x) for x in item._xmipp_OFMeanX] meanY = [float(y) for y in item._xmipp_OFMeanY] plotter = createAlignmentPlot(meanX, meanY) plotter.show() else: print "These items do not have OF alignment set. " ProjectWindow.registerObjectCommand(OBJCMD_MOVIE_ALIGNCARTESIAN, showCartesianShiftsPlot) # Just for backwards compatibility ProtMovieAlignment = XmippProtOFAlignment
(PYTHON, os.path.join(getInstallPath(), PLUGIN_MANAGER_PY))) def launchTemplates(window): os.system("%s %s" % (PYTHON, os.path.join(getScriptsPath(), KICKOFF))) # Cancel this for now to prevent an early import of Config and a false initialization from pyworkflow.gui.project import ProjectManagerWindow, ProjectWindow ProjectManagerWindow.registerPluginMenu("Plugin manager", launchPluginManager, None) ProjectManagerWindow.registerPluginMenu("Workflow templates", launchTemplates, None) def importFromTemplate(window): templates = getTemplates() chosenTemplate = chooseTemplate(templates, parentWindow=window.getRoot()) if chosenTemplate is not None and resolveTemplate(chosenTemplate, [], showScheduleOption=False, schedule=False, showProjectOption=False, showProject=False, showProjectName=False): importTemplate(chosenTemplate, window) ProjectWindow.registerPluginMenu("Import workflow template", importFromTemplate, None)
print "\nAborting..." sys.exit(0) else: print "\nCreating project...." projName = os.path.basename(cwd) projDir = os.path.dirname(cwd) proj = manager.createProject(projName, location=projDir) elif projName == 'last': # Get last project projects = manager.listProjects() if not projects: sys.exit("No projects yet, cannot open the last one.") projName = projects[0].projName projPath = manager.getProjectPath(projName) # try: projWindow = ProjectWindow(projPath) # except Exception as e: # # Print any exception # print("ERROR: At pw_project.py loading Project %s.\n" # " Message: %s\n" % (projPath, e)) # # import traceback # traceback.print_exc(file=sys.stderr) # # sys.exit(e) projWindow.show() else: print "usage: pw_project.py PROJECT_NAME"
DataView(volFn).show() def showClassAvgProjs(volumeSet, volId): showExtraFile(volumeSet, volId, '_aptcl.hdf') def showProjs(volumeSet, volId): showExtraFile(volumeSet, volId, '_proj.hdf') def showInitialRandomVolume(volumeSet, volId): showExtraFile(volumeSet, volId, '_init.hdf') ProjectWindow.registerObjectCommand(OBJCMD_CLASSAVG_PROJS, showClassAvgProjs) ProjectWindow.registerObjectCommand(OBJCMD_PROJS, showProjs) ProjectWindow.registerObjectCommand(OBJCMD_INITVOL, showInitialRandomVolume) class Refine2DViewer(ProtocolViewer): """ Visualization of e2refine2d results. """ _targets = [EmanProtRefine2D, EmanProtRefine2DBispec] _environments = [DESKTOP_TKINTER, WEB_DJANGO] _label = 'viewer refine 2d' def _defineParams(self, form): self._env = os.environ.copy() form.addSection(label='Results per Iteration') form.addParam('iterToShow',
a = xplotter.createSubPlot(plot_title, 'Resolution (Angstroms)', 'CTF', yformat=False) a.invert_xaxis() for i in range(1, 5): _plotCurve(a, i, fn) xplotter.showLegend(['simulated CTF', 'equiphase avg.', 'equiphase avg. - bg', 'cross correlation']) a.grid(True) xplotter.show() OBJCMD_GCTF = "Display Ctf Analysis" ProjectWindow.registerObjectCommand(OBJCMD_GCTF, createCtfPlot) def _plotCurve(a, i, fn): freqs = _getValues(fn, 0) curv = _getValues(fn, i) a.plot(freqs, curv) def _getValues(fn, col): f = open(fn) values = [] for line in f: if not line.startswith('Resolution', 2, 12): column = line.split() value = float(column[col])