Beispiel #1
0
def setupTestProject(cls):
    """ Create and setup a Project for a give Test class. """
    projName = cls.__name__
    if os.environ.get('SCIPION_TEST_CONTINUE', None) == '1':
        proj = Manager().loadProject(projName)
    else:
        proj = Manager().createProject(
            projName)  # Now it will be loaded if exists

    cls.outputPath = proj.path
    cls.projName = projName
    cls.proj = proj
Beispiel #2
0
def setupTestProject(cls):
    """ Create and setup a Project for a give Test class. """
    projName = cls.__name__
    if os.environ.get('SCIPION_TEST_CONTINUE', None) == '1':
        proj = Manager().loadProject(projName)
    else:
        proj = Manager().createProject(projName) # Now it will be loaded if exists

    
    cls.outputPath = proj.path
    # Create project does not change the working directory anymore
    os.chdir(cls.outputPath)
    cls.projName = projName
    cls.proj = proj
Beispiel #3
0
    def __init__(self, parent, windows, **args):
        tk.Frame.__init__(self, parent, bg='white', **args)
        self.windows = windows
        self.manager = windows.manager
        self.root = windows.root

        #tkFont.Font(size=12, family='verdana', weight='bold')
        bigSize = pwgui.cfgFontSize + 2
        smallSize = pwgui.cfgFontSize - 2
        fontName = pwgui.cfgFontName

        self.projNameFont = tkFont.Font(size=bigSize,
                                        family=fontName,
                                        weight='bold')
        self.projDateFont = tkFont.Font(size=smallSize, family=fontName)
        self.projDelFont = tkFont.Font(size=smallSize,
                                       family=fontName,
                                       weight='bold')
        self.manager = Manager()
        btn = HotButton(self,
                        text=Message.LABEL_CREATE_PROJECT,
                        font=self.projNameFont,
                        command=self._onCreateProject)
        btn.grid(row=0, column=0, sticky='nw', padx=10, pady=10)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)
        text = TaggedText(self, width=40, height=15, bd=0, bg='white')
        text.grid(row=1, column=0, sticky='news')

        self.createProjectList(text)
        text.setReadOnly(True)
        self.text = text
Beispiel #4
0
def run_scipion_qc(movie_file):

    manager = Manager()
    project = manager.loadProject(PROJECT)
    path, pattern = os.path.split(movie_file)

    add_movies = project.newProtocol(
        ProtImportMovies,
        filesPath=path,
        filesPattern=pattern,
        voltage=VOLTAGE,
        samplingRate=SAMPLING_RATE,
    )
    project.launchProtocol(add_movies, wait=True)

    align_movies = project.newProtocol(
        ProtMovieAlignment,
        inputMovies=add_movies.outputMovies,
    )
    project.launchProtocol(align_movies, wait=True)

    find_ctf = project.newProtocol(
        ProtCTFFind,
        inputMicrographs=align_movies.outputMicrographs,
    )
    project.launchProtocol(find_ctf, wait=False)
Beispiel #5
0
    def test_createNoChdir(self):
        """Test the list with several Complex"""
        cwd = os.getcwd()
        manager = Manager()
        projectName = "TestProjectCreate"
        project = manager.createProject(projectName, chdir=False)
        dataset = DataSet.getDataSet('emx')

        prot1 = project.newProtocol(
            em.ProtImportParticles,
            objLabel='from emx (coordinatesT1)',
            importFrom=em.ProtImportParticles.IMPORT_FROM_EMX,
            emxFile=dataset.getFile('coordinatesT1'),
            alignType=3,
            voltage=100,
            magnification=10000,
            samplingRate=2.46)
        project.launchProtocol(prot1, wait=True)

        # Execute a copy of prot1
        prot2 = project.copyProtocol(prot1)
        project.launchProtocol(prot2, wait=True)

        # Now restart prot2
        prot2.runMode.set(MODE_RESTART)
        project.launchProtocol(prot2, wait=True)

        #self.assertEqual(cwd, project.getPath())
        self.assertEqual(cwd, os.getcwd())
Beispiel #6
0
def delete_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = request.GET.get('projectName')
        manager.deleteProject(projectName)

    return HttpResponse(mimetype='application/javascript')
Beispiel #7
0
def delete_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = getVarFromRequest(request, PROJECT_NAME)
        manager.deleteProject(projectName)

    return HttpResponse(content_type='application/javascript')
Beispiel #8
0
def project_content(request):
    projectName = request.GET.get('projectName', None)
    if projectName is None:
        projectName = request.POST.get('projectName', None)
    project = Manager().loadProject(projectName)
    context = contentContext(request, project)
    context.update({'mode': None, 'formUrl': 'form'})
    return render_to_response('project_content/project_content.html', context)
Beispiel #9
0
def create_project(request):
    manager = Manager()

    if request.is_ajax():
        projectName = getVarFromRequest(request, PROJECT_NAME)
        workflow = getVarFromRequest(request, WORKFLOW)
        manager.createProject(projectName, chdir=False, workflow=workflow)

    return HttpResponse(content_type='application/javascript')
Beispiel #10
0
def project_content(request):
    projectName = getVarFromRequest(request, PROJECT_NAME)
    mode = getVarFromRequest(request, MODE)
    project = Manager().loadProject(projectName, chdir=False)
    context = contentContext(request, project)
    context.update({'mode': mode, 'formUrl': 'form'})

    if mode == MODE_WORKFLOW:
        context.update({'nowest': True})

    return render_to_response('project_content/project_content.html', context)
Beispiel #11
0
    def test_create(self):
        """Test the list with several Complex"""
        cwd = os.getcwd()
        manager = Manager()
        projectName = "TestProjectCreate"
        project = manager.createProject(projectName)
        self.assertNotEqual(cwd, os.getcwd())
        self.assertEqual(project.getPath(), os.getcwd())

        os.chdir(cwd)
        manager.deleteProject(projectName)
Beispiel #12
0
 def __init__(self):
     projName = self.__class__.__name__
     manager = Manager()
     if manager.hasProject(projName):
         self.project = manager.loadProject(projName)
     else:
         self.project = manager.createProject(projName)
         # Use graph view as default
         settings = self.project.getSettings()
         settings.setRunsView(1) # graph view
         settings.write()
         self.loadWorkflow()
    def __init__(self, config, **kwargs):
        try:
            title = '%s (%s on %s)' % (Message.LABEL_PROJECTS,
                                       pwutils.getLocalUserName(),
                                       pwutils.getLocalHostName())
        except Exception:
            title = Message.LABEL_PROJECTS

        settings = ProjectSettings()
        self.generalCfg = settings.getConfig()

        self.config = config
        ProjectBaseWindow.__init__(self, title, minsize=(400, 550), **kwargs)
        self.viewFuncs = {VIEW_WIZARD: BoxWizardView}
        self.manager = Manager()
        self.switchView(VIEW_WIZARD)
Beispiel #14
0
    def _select(self):
        projName = self.projName.get().strip()
        projLocation = self.projLocation.get().strip()
        copyFiles = self.tkCheckVar.get() != 0
        searchLocation = self.searchLocation.get().strip()
        manager = Manager()

        # If project name is empty we will use the same name as the source
        if not projName:
            projName = os.path.basename(projLocation)

        errorMessage = ''

        # Validate that project location is not empty
        if not projLocation:
            errorMessage = "Project location is empty\n"

        # Validate that project location exists
        elif not os.path.exists(projLocation):
            errorMessage += "Project location does not exist\n"

        # Validate that project location is a directory
        elif not os.path.isdir(projLocation):
            errorMessage += "Project location is not a directory\n"
        # Validate that the project location is a scipion project folder
        elif not os.path.exists(os.path.join(projLocation, PROJECT_DBNAME)):
            errorMessage += "Project location doesn't look like a scipion folder\n"

        # Validate that there isn't already a project with the same name
        if manager.hasProject(projName):
            errorMessage += "Project [%s] already exists\n" % projName

        # Validate that search location exists
        if searchLocation:
            if not os.path.exists(searchLocation):
                errorMessage += "Raw files location does not exist\n"
            # Validate that search location is a directory
            elif not os.path.isdir(searchLocation):
                errorMessage += "Raw files location is not a directory\n"

        if errorMessage:
            showError("Validation error", errorMessage, self.root)
        else:
            self.parent.importProject(projLocation, copyFiles, projName,
                                      searchLocation)
            self.close()
Beispiel #15
0
def getServiceManager(serviceName):
    print "getServiceManager"
    print "serviceName: ", serviceName
    scipionUserData = os.path.join(os.environ['SCIPION_USER_DATA'],
                                   serviceName)
    manager = Manager(SCIPION_USER_DATA=scipionUserData)

    serviceConf = os.path.join(os.environ['HOME'], '.config', 'scipion',
                               serviceName)
    manager.config = os.path.join(serviceConf, 'scipion.conf')
    manager.protocols = os.path.join(serviceConf, 'protocols.conf')
    manager.hosts = os.path.join(serviceConf, 'hosts.conf')

    print "config: ", manager.config
    print "protocols: ", manager.protocols
    print "hosts: ", manager.hosts

    return manager
Beispiel #16
0
def check_project_id(request):
    result = 0
    projectName = request.GET.get('code', None)
    serviceName = request.GET.get('serviceName', None)

    try:
        if serviceName is None:
            project = Manager().loadProject(projectName)
        else:
            manager = getServiceManager(serviceName)
            project = manager.loadProject(projectName,
                                          protocolsConf=manager.protocols,
                                          hostsConf=manager.hosts)
        result = 1
    except Exception:
        pass

    return HttpResponse(result, mimetype='application/javascript')
Beispiel #17
0
def projects(request):
    from pyworkflow.utils.utils import prettyDate

    manager = Manager()
    projects = manager.listProjects()
    for p in projects:
        p.pTime = prettyDate(p.mTime)

    if 'projectName' in request.session: request.session['projectName'] = ""
    if 'projectPath' in request.session: request.session['projectPath'] = ""

    context = {
        'projects': projects,
        'projects_css': getResourceCss('projects'),
        'project_utils_js': getResourceJs('project_utils'),
    }

    context = base_grid(request, context)

    return render_to_response('projects.html', context)
    def _writeSubset(self, subset):
        """ Generated the output of this subset. """
        newSubsetName = 'outputParticles_%03d' % self._counter
        self.info("Creating new subset: %s" % newSubsetName)
        subset.write()
        self._defineOutputs(**{newSubsetName: subset})
        self._defineTransformRelation(self.inputParticles, subset)
        # The following is required to commit the changes to the database
        self._store(subset)
        subset.close()

        from pyworkflow.manager import Manager
        manager = Manager()
        project = manager.loadProject(self.getProject().getName())
        input2D = self.input2dProtocol.get()
        copyProt = project.copyProtocol(project.getProtocol(input2D.getObjId()))
        copyProt.inputParticles.set(project.getProtocol(self.getObjId()))
        copyProt.inputParticles.setExtended(newSubsetName)
        project.scheduleProtocol(copyProt, self._runPrerequisites)
        # Next schedule will be after this one
        self._runPrerequisites.append(copyProt.getObjId())
Beispiel #19
0
def getServiceManager(serviceName):
    global SERVICE_MANAGERS

    manager = SERVICE_MANAGERS.get(serviceName, None)

    if manager is None:
        print "...Creating new cached Manager"
        scipionUserData = os.environ['SCIPION_USER_DATA']
        servicePath = '' if serviceName is None else serviceName
        scipionUserData = os.path.join(scipionUserData, servicePath)

        manager = Manager(SCIPION_USER_DATA=scipionUserData)

        serviceConf = os.path.join(os.environ['HOME'], '.config', 'scipion',
                                   servicePath)
        manager.config = os.path.join(serviceConf, 'scipion.conf')
        manager.protocols = os.path.join(serviceConf, 'protocols.conf')
        manager.hosts = os.path.join(serviceConf, 'hosts.conf')
        SERVICE_MANAGERS[serviceName] = manager

    return manager
Beispiel #20
0
def data_content(request):        
    projectName = request.GET.get('projectName', None)
    
    manager = Manager()
    request.session['projectPath'] = manager.getProjectPath(projectName)
    project = loadProject(request)
    
    context = {'projectName': projectName,
               'editTool': getResourceIcon('edit_toolbar'),
               'graph_utils': getResourceJs('graph_utils'),
               'project_content_utils': getResourceJs('project_content_utils'),
               'data_content_utils': getResourceJs('data_content_utils'),
               'jquery_cookie': getResourceJs('jquery_cookie'),
               'jquery_treeview': getResourceJs('jquery_treeview'),
               'project_content_css':getResourceCss('project_content'),
               'view':'data'
               }
    
    context = base_flex(request, context)
    
    return render_to_response('data_content/data_content.html', context)
Beispiel #21
0
def data_content(request):
    projectName = getVarFromRequest(request, PROJECT_NAME)

    manager = Manager()
    request.session[CTX_PROJECT_PATH] = manager.getProjectPath(projectName)
    # project = loadProject(request)

    context = {CTX_PROJECT_NAME: projectName,
               'editTool': getResourceIcon('edit_toolbar'),
               'graph_utils': getResourceJs('graph_utils'),
               'project_content_utils': getResourceJs('project_content_utils'),
               'data_content_utils': getResourceJs('data_content_utils'),
               'jquery_cookie': getResourceJs('jquery_cookie'),
               'jquery_treeview': getResourceJs('jquery_treeview'),
               'project_content_css': getResourceCss('project_content'),
               'view': 'data'
               }

    context = base_flex(request, context)

    return render_to_response('data_content/data_content.html', context)
Beispiel #22
0
    def __init__(self, **kwargs):
        # Load global configuration
        settings = ProjectSettings()

        # TODO: put the menu part more nicely. From here:
        menu = MenuConfig()

        fileMenu = menu.addSubMenu('File')
        fileMenu.addSubMenu('Browse files',
                            'browse',
                            icon='fa-folder-open.png')
        fileMenu.addSubMenu('Exit', 'exit', icon='fa-sign-out.png')

        confMenu = menu.addSubMenu('Configuration')
        confMenu.addSubMenu('General', 'general')
        confMenu.addSubMenu('Hosts', 'hosts')
        confMenu.addSubMenu('Protocols', 'protocols')
        confMenu.addSubMenu('User', 'user')

        helpMenu = menu.addSubMenu('Help')
        helpMenu.addSubMenu('Online help',
                            'online_help',
                            icon='fa-external-link.png')
        helpMenu.addSubMenu('About', 'about', icon='fa-question-circle.png')

        self.menuCfg = menu
        self.generalCfg = settings.getConfig()

        try:
            title = '%s (%s on %s)' % (Message.LABEL_PROJECTS,
                                       pwutils.getLocalUserName(),
                                       pwutils.getLocalHostName())
        except Exception:
            title = Message.LABEL_PROJECTS

        ProjectBaseWindow.__init__(self, title, minsize=(750, 500), **kwargs)
        self.manager = Manager()

        self.switchView(VIEW_PROJECTS)
Beispiel #23
0
def projects(request):
    from pyworkflow.utils.utils import prettyDate

    manager = Manager()
    projectsList = manager.listProjects()
    for p in projectsList:
        p.pTime = prettyDate(p.mTime)

    if CTX_PROJECT_NAME in request.session:
        request.session[CTX_PROJECT_NAME] = ""
    if CTX_PROJECT_PATH in request.session:
        request.session[CTX_PROJECT_PATH] = ""

    context = {
        'projects': projectsList,
        'projects_css': getResourceCss('projects'),
        'project_utils_js': getResourceJs('project_utils'),
        'workflows': json.dumps(getWorkflowsList())
    }

    context = base_grid(request, context)

    return render_to_response('projects.html', context)
Beispiel #24
0
n = len(sys.argv)

if n > 3:
    usage("Incorrect number of input parameters")

delete = '--delete' in sys.argv

arg1 = sys.argv[1]
if n > 1 and arg1 != '--delete':
    customUserData = arg1
else:
    customUserData = os.environ['SCIPION_USER_DATA']

print "Loading projects from:\n", customUserData

# Create a new project
manager = Manager(SCIPION_USER_DATA=customUserData)

for projInfo in manager.listProjects():
    projName = projInfo.getName()
    proj = manager.loadProject(projName)
    settings = proj.getSettings()

    leftTime = proj.getLeftTime()
    if (leftTime is not None and leftTime.days < 0):
        if delete:
            print "Deleting: %s (%s) " % (projName, leftTime)
            manager.deleteProject(projName)
        else:
            print "Should delete: %s (%s)" % (projName, leftTime)
    def __init__(self, parent, windows, **kwargs):
        tk.Frame.__init__(self, parent, bg='white', **kwargs)
        self.windows = windows
        self.manager = windows.manager
        self.root = windows.root
        self.vars = {}
        self.checkvars = []
        self.microscope = None
        # Regular expression to validate username and sample name
        self.re = re.compile('\A[a-zA-Z][a-zA-Z0-9_-]+\Z')

        # tkFont.Font(size=12, family='verdana', weight='bold')
        bigSize = pwgui.cfgFontSize + 2
        smallSize = pwgui.cfgFontSize - 2
        fontName = pwgui.cfgFontName

        self.bigFont = tkFont.Font(size=bigSize, family=fontName)
        self.bigFontBold = tkFont.Font(size=bigSize,
                                       family=fontName,
                                       weight='bold')

        self.projDateFont = tkFont.Font(size=smallSize, family=fontName)
        self.projDelFont = tkFont.Font(size=smallSize,
                                       family=fontName,
                                       weight='bold')
        self.manager = Manager()

        # Header section
        headerFrame = tk.Frame(self, bg='white')
        headerFrame.grid(row=0, column=0, sticky='new')
        headerText = "Create New Session"

        headerText += "  %s" % pwutils.prettyTime(dateFormat='%Y-%m-%d')

        label = tk.Label(headerFrame,
                         text=headerText,
                         font=self.bigFontBold,
                         borderwidth=0,
                         anchor='nw',
                         bg='white',
                         fg=pwgui.Color.DARK_GREY_COLOR)
        label.grid(row=0, column=0, sticky='nw', padx=(20, 5), pady=10)

        # Body section
        bodyFrame = tk.Frame(self, bg='white')
        bodyFrame.grid(row=1, column=0, sticky='news')
        self._fillContent(bodyFrame)

        # Add the create project button
        btnFrame = tk.Frame(self, bg='white')
        btn = HotButton(btnFrame,
                        text="Create New Session",
                        font=self.bigFontBold,
                        command=self._onAction)
        btn.grid(row=0, column=1, sticky='ne', padx=10, pady=10)

        # Add the Import project button
        btn = Button(btnFrame,
                     Message.LABEL_BUTTON_CANCEL,
                     Icon.ACTION_CLOSE,
                     font=self.bigFontBold,
                     command=self.windows.close)
        btn.grid(row=0, column=0, sticky='ne', padx=10, pady=10)

        btnFrame.grid(row=2, column=0, sticky='sew')
        btnFrame.columnconfigure(0, weight=1)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(1, weight=1)
Beispiel #26
0
    sys.exit(1)


n = len(sys.argv)

if n <> 2:
    usage("This script accepts 1 parameter: the project name.")

projName = sys.argv[1]

path = os.path.join(os.environ['SCIPION_HOME'], 'pyworkflow', 'gui',
                    'no-tkinter')
sys.path.insert(1, path)

# Create a new project
manager = Manager()

if not manager.hasProject(projName):
    usage("There is no project with this name: %s" % pwutils.red(projName))

# the project may be a soft link which may be unavailable to the cluster so get the real path
try:
    projectPath = os.readlink(manager.getProjectPath(projName))
except:
    projectPath = manager.getProjectPath(projName)

project = Project(projectPath)
project.load()

runs = project.getRuns()
    def _createScipionProject(self, projName, projPath, scipionProjPath):
        manager = Manager()
        project = manager.createProject(projName, location=scipionProjPath)
        self.lastProt = None
        pattern = self._getConfValue(PATTERN)

        smtpServer = self._getConfValue(SMTP_SERVER, '')
        smtpFrom = self._getConfValue(SMTP_FROM, '')
        smtpTo = self._getConfValue(SMTP_TO, '')
        doMail = self._getValue(EMAIL_NOTIFICATION)
        doPublish = self._getValue(HTML_REPORT)

        protImport = project.newProtocol(
            em.ProtImportMovies,
            objLabel='Import movies',
            filesPath=projPath,
            filesPattern=pattern,
            sphericalAberration=self._getConfValue(CS),
            dataStreaming=True)

        # Should I publish html report?
        if doPublish == 1:
            publish = self._getConfValue('HTML_PUBLISH')
            print("\n\nReport available at URL: %s/%s\n\n" %
                  ('http://scipion.cnb.csic.es/scipionbox', projName))
        else:
            publish = ''

        protMonitor = project.newProtocol(em.ProtMonitorSummary,
                                          objLabel='Summary Monitor',
                                          doMail=doMail,
                                          emailFrom=smtpFrom,
                                          emailTo=smtpTo,
                                          smtp=smtpServer,
                                          publishCmd=publish)

        def _saveProtocol(prot, movies=True, monitor=True):
            if movies:
                prot.inputMovies.set(self.lastProt)
                prot.inputMovies.setExtended('outputMovies')
            project.saveProtocol(prot)
            self.lastProt = prot
            if monitor:
                protMonitor.inputProtocols.append(prot)

        _saveProtocol(protImport, movies=False)

        useMC2 = self._getValue(MOTIONCOR2)
        useMC = self._getValue(MOTIONCORR) or useMC2
        useOF = self._getValue(OPTICAL_FLOW)
        useSM = self._getValue(SUMMOVIE)
        useCTF = self._getValue(CTFFIND4)
        useGCTF = self._getValue(GCTF)

        kwargs = {}
        frames = self._getValue(FRAMES_RANGE).split()
        if frames:
            kwargs['alignFrame0'] = kwargs['sumFrame0'] = frames[0]
            kwargs['alignFrameN'] = kwargs['sumFrameN'] = frames[1]

        if useMC:
            # Create motioncorr
            from pyworkflow.em.packages.motioncorr import ProtMotionCorr
            protMC = project.newProtocol(ProtMotionCorr,
                                         objLabel='Motioncorr',
                                         useMotioncor2=useMC2,
                                         **kwargs)
            _saveProtocol(protMC)

        if useOF:
            # Create Optical Flow protocol
            from pyworkflow.em.packages.xmipp3 import XmippProtOFAlignment

            protOF = project.newProtocol(XmippProtOFAlignment,
                                         objLabel='Optical Flow',
                                         doSaveMovie=useSM,
                                         **kwargs)
            _saveProtocol(protOF)

        if useSM:
            # If OF write the movie, then we need to reset frames count
            if frames and useOF:
                kwargs['alignFrame0'] = kwargs['sumFrame0'] = 1
                kwargs['alignFrameN'] = kwargs['sumFrameN'] = 0

            from pyworkflow.em.packages.grigoriefflab import ProtSummovie
            protSM = project.newProtocol(ProtSummovie,
                                         objLabel='Summovie',
                                         cleanInputMovies=useOF,
                                         numberOfThreads=1,
                                         **kwargs)
            _saveProtocol(protSM)

        lastBeforeCTF = self.lastProt

        if useCTF:
            from pyworkflow.em.packages.grigoriefflab import ProtCTFFind
            protCTF = project.newProtocol(ProtCTFFind,
                                          objLabel='Ctffind',
                                          numberOfThreads=1)
            protCTF.inputMicrographs.set(lastBeforeCTF)
            protCTF.inputMicrographs.setExtended('outputMicrographs')
            _saveProtocol(protCTF, movies=False)

        if useGCTF:
            from pyworkflow.em.packages.gctf import ProtGctf
            protGCTF = project.newProtocol(ProtGctf, objLabel='Gctf')
            protGCTF.inputMicrographs.set(lastBeforeCTF)
            protGCTF.inputMicrographs.setExtended('outputMicrographs')
            _saveProtocol(protGCTF, movies=False)

        project.saveProtocol(protMonitor)

        os.system('%s project %s &' % (pw.getScipionScript(), projName))

        self.windows.close()