Пример #1
0
def movies_content(request):

    domain = django_settings.SITE_URL
    projectName = request.GET.get('p', None)
    path_files = django_settings.ABSOLUTE_URL + '/resources_movies/img/'
    command = "rsync -av --port 3333 USER_FOLDER/ %s::mws/%s" % (domain,
                                                                 projectName)

    manager = getServiceManager('movies')
    project = manager.loadProject(projectName,
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts)
    daysLeft = prettyDelta(project.getLeftTime())

    context = contentContext(request, project)
    context.update({
        # MODE
        'formUrl': 'mov_form',
        'mode': 'service',
        # IMAGES
        'importMovies': path_files + 'importMovies.png',
        'movieAlignment': path_files + 'movieAlignment.png',
        'protMovieAlign': path_files + 'protMovieAlign.png',
        'summary': path_files + 'summary.png',
        'showj': path_files + 'showj.png',
        'download': path_files + 'download.png',
        'command': command,
        'daysLeft': daysLeft,
    })

    return render_to_response('movies_content.html', context)
Пример #2
0
def resmap_content(request):
    projectName = request.GET.get('p', None)
    path_files = getAbsoluteURL('resources_myresmap/img/')

    # Get info about when the project was created
    manager = getServiceManager(MYRESMAP_SERVICE)
    project = manager.loadProject(projectName,
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts,
                                  chdir=False)

    daysLeft = prettyDelta(project.getLeftTime())

    context = contentContext(request, project, serviceName=MYRESMAP_SERVICE)
    context.update({
        'importVolumes': path_files + 'importVolumes.png',
        'useResMap': path_files + 'useResMap.png',
        'protResMap': path_files + 'protResMap.png',
        'analyzeResults': path_files + 'analyzeResults.png',
        'formUrl': 'r_form',
        'mode': MODE_SERVICE,
        'daysLeft': daysLeft
    })

    return render_to_response('resmap_content.html', context)
Пример #3
0
def resmap_content(request):
    projectName = request.GET.get('p', None)
    path_files = django_settings.ABSOLUTE_URL + '/resources_myresmap/img/'
    
    # Get info about when the project was created
    manager = getServiceManager('myresmap')
    project = manager.loadProject(projectName, 
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts)
    
    project.getSettings().setLifeTime(336) # 14 days * 24 hours
    project.saveSettings()
   
    daysLeft = prettyDelta(project.getLeftTime())

    context = contentContext(request, project)
    context.update({'importVolumes': path_files + 'importVolumes.png',
                    'useResMap': path_files + 'useResMap.png',
                    'protResMap': path_files + 'protResMap.png',
                    'analyzeResults': path_files + 'analyzeResults.png',
                    'formUrl': 'r_form',
                    'mode':'service',
                    'daysLeft': daysLeft,
                    })
    
    return render_to_response('resmap_content.html', context)
Пример #4
0
def movies_content(request):
    projectName = request.GET.get('p', None)
    path_files = django_settings.ABSOLUTE_URL + '/resources_movies/img/'
    command = "rsync -av --port 3333 USER_FOLDER/ scipion.cnb.csic.es::mws/" + projectName
    
    manager = getServiceManager('movies')
    project = manager.loadProject(projectName, 
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts)
    daysLeft = prettyDelta(project.getLeftTime())
    
    context = contentContext(request, project)
    context.update({
                    # MODE
                    'formUrl': 'mov_form',
                    'mode':'service',
                    # IMAGES
                    'importMovies': path_files + 'importMovies.png',
                    'movieAlignment': path_files + 'movieAlignment.png',
                    'protMovieAlign': path_files + 'protMovieAlign.png',
                    'summary': path_files + 'summary.png',
                    'showj': path_files + 'showj.png',
                    'download': path_files + 'download.png',
                    'command' : command,
                    'daysLeft': daysLeft,
                    })
    
    return render_to_response('movies_content.html', context)
Пример #5
0
def resmap_content(request):
    projectName = request.GET.get('p', None)
    path_files = django_settings.ABSOLUTE_URL + '/resources_myresmap/img/'
    
    # Get info about when the project was created
    manager = getServiceManager('myresmap')
    project = manager.loadProject(projectName, 
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts)
    
    project.getSettings().setLifeTime(14)
    project.saveSettings()
   
    daysLeft = prettyDelta(project.getLeftTime())

    context = contentContext(request, project)
    context.update({'importVolumes': path_files + 'importVolumes.png',
                    'useResMap': path_files + 'useResMap.png',
                    'protResMap': path_files + 'protResMap.png',
                    'analyzeResults': path_files + 'analyzeResults.png',
                    'formUrl': 'r_form',
                    'mode':'service',
                    'daysLeft': daysLeft,
                    })
    
    return render_to_response('resmap_content.html', context)
Пример #6
0
def service_content(request):
    projectName = request.GET.get('p', None)
    path_files = django_settings.ABSOLUTE_URL + '/resources_myfirstmap/img/'
    
    # Get info about when the project was created
    manager = getServiceManager('myfirstmap')
    project = manager.loadProject(projectName, 
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts)
    
    daysLeft = prettyDelta(project.getLeftTime())
    
    context = contentContext(request, project)
    context.update({'importAverages': path_files + 'importAverages.png',
                    'useProtocols': path_files + 'useProtocols.png',
                    'protForm': path_files + 'protForm.png',
                    'summary': path_files + 'summary.png',
                    'showj': path_files + 'showj.png',
                    'alignVol': path_files + 'alignVol.png',
                    'validateVols': path_files + 'validateVols.png',
                    'download': path_files + 'download.png',
                    'formUrl': 'my_form',
                    'mode':'service',
                    'daysLeft': daysLeft,
                    })
    
    return render_to_response('service_content.html', context)
Пример #7
0
def service_content(request):
    projectName = request.GET.get('p', None)
    path_files = django_settings.ABSOLUTE_URL + '/resources_myfirstmap/img/'

    # Get info about when the project was created
    manager = getServiceManager('myfirstmap')
    project = manager.loadProject(projectName,
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts)

    daysLeft = prettyDelta(project.getLeftTime())

    context = contentContext(request, project)
    context.update({
        'importAverages': path_files + 'importAverages.png',
        'useProtocols': path_files + 'useProtocols.png',
        'protForm': path_files + 'protForm.png',
        'summary': path_files + 'summary.png',
        'showj': path_files + 'showj.png',
        'alignVol': path_files + 'alignVol.png',
        'download': path_files + 'download.png',
        'formUrl': 'my_form',
        'mode': 'service',
        'daysLeft': daysLeft,
    })

    return render_to_response('service_content.html', context)
Пример #8
0
def movies_content(request):
    projectName = request.GET.get('p', None)
    path_files = getAbsoluteURL('resources_movies/img/')
    command = getSyncCommand(request)

    manager = getServiceManager(MOVIES_SERVICE)
    project = manager.loadProject(projectName,
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts,
                                  chdir=False)
    daysLeft = prettyDelta(project.getLeftTime())

    context = contentContext(request, project, serviceName=MOVIES_SERVICE)
    context.update({
        # MODE
        'formUrl': 'mov_form',
        'mode': MODE_SERVICE,
        # IMAGES
        'importMovies': path_files + 'importMovies.png',
        'movieAlignment': path_files + 'movieAlignment.png',
        'protMovieAlign': path_files + 'protMovieAlign.png',
        'summary': path_files + 'summary.png',
        'showj': path_files + 'showj.png',
        'download': path_files + 'download.png',
        'command': command,
        'daysLeft': daysLeft
    })

    return render_to_response('movies_content.html', context)
Пример #9
0
def service_content(request):

    projectName = request.GET.get('p', None)
    path_files = getAbsoluteURL('resources_myfirstmap/img/')
    
    # Get info about when the project was created
    manager = getServiceManager(MYFIRSTMAP_SERVICE)
    project = manager.loadProject(projectName, 
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts,
                                  chdir=False)
    
    daysLeft = prettyDelta(project.getLeftTime())
    
    context = contentContext(request, project, serviceName=MYFIRSTMAP_SERVICE)
    context.update({'importAverages': path_files + 'importAverages.png',
                    'useProtocols': path_files + 'useProtocols.png',
                    'protForm': path_files + 'protForm.png',
                    'summary': path_files + 'summary.png',
                    'showj': path_files + 'showj.png',
                    'alignVol': path_files + 'alignVol.png',
                    'download': path_files + 'download.png',
                    'formUrl': 'my_form',
                    'mode': MODE_SERVICE,
                    'daysLeft': daysLeft
                    })
    
    return render_to_response('service_content.html', context)
Пример #10
0
def create_resmap_project(request):
    if request.is_ajax():
        import os
        from pyworkflow.em.protocol import ProtImportVolumes
        from pyworkflow.em.packages.resmap.protocol_resmap import ProtResMap

        # Create a new project
        projectName = request.GET.get(PROJECT_NAME)

        # Filename to use as test data
        testDataKey = request.GET.get('testData')

        manager = getServiceManager(MYRESMAP_SERVICE)
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName,
                                        runsView=1,
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols,
                                        chdir=False)

        project.getSettings().setLifeTime(336)  # 14 days * 24 hours
        project.saveSettings()

        projectPath = manager.getProjectPath(projectName)

        # 1. Import maps
        if testDataKey:
            attr = getAttrTestFile(testDataKey)
            source = attr['file']
            dest = os.path.join(projectPath, 'Uploads', basename(source))
            pwutils.createLink(source, dest)

            label_import = "import volumes (" + testDataKey + ")"
            protImport = project.newProtocol(ProtImportVolumes,
                                             objLabel=label_import)

            protImport.filesPath.set(dest)
            protImport.samplingRate.set(attr['samplingRate'])

            project.launchProtocol(protImport, wait=True, chdir=False)
        else:
            protImport = project.newProtocol(ProtImportVolumes,
                                             objLabel='import volumes')
            project.saveProtocol(protImport)

        # 2. ResMap
        protResMap = project.newProtocol(ProtResMap)
        protResMap.setObjLabel('resmap - local resolution')
        protResMap.inputVolume.set(protImport)
        protResMap.inputVolume.setExtended('outputVolume')
        loadProtocolConf(protResMap)
        project.saveProtocol(protResMap)

    return HttpResponse(content_type='application/javascript')
Пример #11
0
def create_resmap_project(request):
    if request.is_ajax():
        import os
        from pyworkflow.object import Pointer
        from pyworkflow.em.protocol import ProtImportVolumes
        from pyworkflow.em.packages.resmap.protocol_resmap import ProtResMap
        
        # Create a new project
        projectName = request.GET.get('projectName')
        
        # Filename to use as test data 
        testDataKey = request.GET.get('testData')
        
        manager = getServiceManager('myresmap')
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName, runsView=1, 
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols
                                        ) 
         
        project.getSettings().setLifeTime(14)
        project.saveSettings()
         
        projectPath = manager.getProjectPath(projectName)
        
        # 1. Import movies
        if testDataKey :
            attr = getAttrTestFile(testDataKey)
            source = attr['path'] + attr['file']
            dest = os.path.join(projectPath,'Uploads', attr['file'])
            pwutils.createLink(source, dest)        
        
            label_import = "import volumes ("+ testDataKey +")" 
            protImport = project.newProtocol(ProtImportVolumes, objLabel=label_import)

            protImport.filesPath.set(dest)
            protImport.samplingRate.set(attr['samplingRate'])
            
            project.launchProtocol(protImport, wait=True)
        else:
            protImport = project.newProtocol(ProtImportVolumes, objLabel='import volumes')
            project.saveProtocol(protImport)
            
        
        # 2. ResMap 
        protResMap = project.newProtocol(ProtResMap)
        protResMap.setObjLabel('resmap - local resolution')
        protResMap.inputVolume.set(protImport)
        protResMap.inputVolume.setExtendedAttribute('outputVolume')
        project.saveProtocol(protResMap)
        
    return HttpResponse(mimetype='application/javascript')
Пример #12
0
def particleValidation_content(request):
    projectName = request.GET.get('p', None)
    path_files = getAbsoluteURL('resources_mypval/img/')

    # Get info about when the project was created
    manager = getServiceManager(MYPVAL_SERVICE)
    project = manager.loadProject(projectName,
                                  protocolsConf=manager.protocols,
                                  hostsConf=manager.hosts,
                                  chdir=False)

    daysLeft = prettyDelta(project.getLeftTime())

    context = contentContext(request, project, serviceName=MYPVAL_SERVICE)

    # Resources for the help - guide, to be done.
    context.update({
        'formUrl': MYPVAL_FORM_URL,
        'mode': MODE_SERVICE,
        'daysLeft': daysLeft
    })

    return render_to_response('pval_content.html', context)
Пример #13
0
def create_movies_project(request):
    
    if request.is_ajax():
        
        import os
        from pyworkflow.object import Pointer
        from pyworkflow.em.protocol import ProtImportMovies
        from pyworkflow.em.packages.xmipp3 import ProtMovieAlignment
        
        # Create a new project
        projectName = request.GET.get('projectName')
        
        # Filename to use as test data 
        testDataKey = request.GET.get('testData')
        
        manager = getServiceManager('movies')
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName, runsView=1, 
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols
                                        )   
        
        project.getSettings().setLifeTime(14)
        project.saveSettings()
        
#         copyFile(customMenu, project.getPath('.config', 'protocols.conf'))
        
        # Create symbolic link for uploads
        projectPath = manager.getProjectPath(projectName)
        dest = os.path.join(projectPath,'Uploads')
        # @todo: this path to uploads dir should be configurable outside the code...
        source = "/services/scipion/data/uploads/"+ projectName
        pwutils.path.makePath(source)
        pwutils.createLink(source, dest)
        
        # 1. Import movies
        if testDataKey :
            attr = getAttrTestFile(testDataKey)
            path_test = attr['path']

            
            for f in os.listdir(path_test):           
                # Create a symbolic link for each file
                file_path = os.path.join(path_test, f)
                source_file = os.path.join(source, f)
                pwutils.createAbsLink(file_path, source_file)
            
            label_import = "import movies ("+ testDataKey +")" 
            protImport = project.newProtocol(ProtImportMovies, objLabel=label_import)

            protImport.filesPath.set(attr["filesPath"])
            protImport.voltage.set(attr['voltage'])
            protImport.sphericalAberration.set(attr['sphericalAberration'])
            protImport.amplitudeContrast.set(attr['amplitudeContrast'])
            protImport.magnification.set(attr['magnification'])
            protImport.samplingRate.set(attr['samplingRate'])
            
            project.launchProtocol(protImport, wait=True)
        else:
            protImport = project.newProtocol(ProtImportMovies, objLabel='import movies')
            project.saveProtocol(protImport)
        
        # 2. Movie Alignment 
        protMovAlign = project.newProtocol(ProtMovieAlignment)
        protMovAlign.setObjLabel('xmipp - movie alignment')
        protMovAlign.inputMovies.set(protImport)
        protMovAlign.inputMovies.setExtended('outputMovies')
        project.saveProtocol(protMovAlign)
        
    return HttpResponse(mimetype='application/javascript')
Пример #14
0
def create_particleValidation_project(request):
    if request.is_ajax():
        from pyworkflow.em.protocol import ProtImportVolumes
        from pyworkflow.em.protocol import ProtImportParticles

        # Create a new project
        projectName = request.GET.get(PROJECT_NAME)

        # Filename to use as test data
        testDataKey = request.GET.get('testData')

        manager = getServiceManager(MYPVAL_SERVICE)
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName,
                                        runsView=1,
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols,
                                        chdir=False)

        project.getSettings().setLifeTime(336)  # 14 days * 24 hours
        project.saveSettings()

        projectPath = manager.getProjectPath(projectName)

        # If we need to import test data...
        if testDataKey:

            # Get test data attributes
            attr = getAttrTestFile(testDataKey, projectPath)

            # 1. Import volumes
            source = attr['volume']
            dest = os.path.join(projectPath, 'Uploads', basename(source))
            pwutils.createLink(source, dest)

            label_import = "import volumes (" + testDataKey + ")"
            protImportVol = project.newProtocol(ProtImportVolumes,
                                                objLabel=label_import)

            protImportVol.filesPath.set(dest)
            protImportVol.samplingRate.set(attr['samplingRate'])
            project.launchProtocol(protImportVol, wait=True, chdir=False)

            # 2. Import particles
            binary = linkTestData(attr['particles'], projectPath)
            metaFile = linkTestData(attr['metaFile'], projectPath)

            label_import = "import particles (" + testDataKey + ")"
            protImportParticles = project.newProtocol(ProtImportParticles,
                                                      objLabel=label_import)
            protImportParticles.filesPath.set(binary)

            # Set import particle attributes
            protImportParticles.importFrom.set(attr["importFrom"])

            # RELION Datasets
            if attr["importFrom"] == ProtImportParticles.IMPORT_FROM_RELION:
                protImportParticles.starFile.set(metaFile)
            else:
                protImportParticles.sqliteFile.set(metaFile)

            protImportParticles.voltage.set(attr["microscopeVoltage"])
            protImportParticles.sphericalAberration.set(
                attr["sphericalAberration"])
            protImportParticles.amplitudeContrast.set(
                attr["amplitudeContrast"])
            protImportParticles.magnification.set(attr["magnificationRate"])
            protImportParticles.samplingRate.set(attr["particlesSamplingRate"])

            project.launchProtocol(protImportParticles, wait=True, chdir=False)

            inputVolumeProtocol = protImportVol
            inputVolumeExtended = 'outputVolume'

            inputParticlesProtocol = protImportParticles
            inputParticlesExtended = 'outputParticles'

        else:

            # Empty import volumes protocol
            protImportVol = project.newProtocol(ProtImportVolumes,
                                                objLabel='import volume')
            project.saveProtocol(protImportVol)

            # Empty import particles protocol
            protImportParticles = project.newProtocol(
                ProtImportParticles, objLabel='import particles')
            project.saveProtocol(protImportParticles)

        inputVolumeProtocol = protImportVol
        inputVolumeExtended = 'outputVolume'

        inputParticlesProtocol = protImportParticles
        inputParticlesExtended = 'outputParticles'

        # 3a. Validate non tilt
        protNonTilt = project.newProtocol(XmippProtValidateNonTilt)
        protNonTilt.setObjLabel('alignment reliability (validate non tilt)')

        # link Input volumes
        protNonTilt.inputVolumes.set(inputVolumeProtocol)
        protNonTilt.inputVolumes.setExtended(inputVolumeExtended)

        # Input particles
        protNonTilt.inputParticles.set(inputParticlesProtocol)
        protNonTilt.inputParticles.setExtended(inputParticlesExtended)

        # Attributes
        if testDataKey:
            protNonTilt.symmetryGroup.set(attr['symmetry'])

        # Load additional configuration
        loadProtocolConf(protNonTilt)
        project.saveProtocol(protNonTilt)

        # 3b. Validation overfitting
        protValidation = project.newProtocol(XmippProtValidateOverfitting)
        protValidation.setObjLabel('BSOFT/xmipp3 - validate overfitting')

        # link Input volumes
        protValidation.input3DReference.set(inputVolumeProtocol)
        protValidation.input3DReference.setExtended(inputVolumeExtended)

        # Input particles
        protValidation.inputParticles.set(inputParticlesProtocol)
        protValidation.inputParticles.setExtended(inputParticlesExtended)

        # Attributes
        if testDataKey:
            protValidation.symmetryGroup.set(attr['symmetry'])
            protValidation.numberOfParticles.set(attr['numberOfParticles'])

        # Load additional configuration
        loadProtocolConf(protValidation)
        project.saveProtocol(protValidation)

    return HttpResponse(content_type='application/javascript')
Пример #15
0
def create_service_project(request):
    if request.is_ajax():
        import os
        from pyworkflow.object import Pointer
        from pyworkflow.em.protocol import ProtUnionSet, ProtImportAverages
        from pyworkflow.em.packages.xmipp3 import XmippProtRansac, XmippProtReconstructSignificant, XmippProtAlignVolumeForWeb
        from pyworkflow.em.packages.eman2 import EmanProtInitModel
        from pyworkflow.em.packages.simple import ProtPrime
        
        # Create a new project
        projectName = request.GET.get('projectName')
        
        # Filename to use as test data 
        testDataKey = request.GET.get('testData')
        
        #customMenu = os.path.join(os.path.dirname(os.environ['SCIPION_PROTOCOLS']), 'menu_initvolume.conf')
        
        manager = getServiceManager('myfirstmap')
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName, runsView=1, 
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols
                                        ) 
        
        project.getSettings().setLifeTime(14)
        project.saveSettings()
        #copyFile(customMenu, project.getPath('.config', 'protocols.conf'))
        
        # 1. Import averages
        
        # If using test data execute the import averages run
        # options are set in 'project_utils.js'
        dsMDA = DataSet.getDataSet('initial_volume')
        
        if testDataKey :
            fn = dsMDA.getFile(testDataKey)
            newFn = join(project.uploadPath, basename(fn))
            copyFile(fn, newFn)
            
            label_import = 'import averages ('+ testDataKey +')'
            protImport = project.newProtocol(ProtImportAverages, objLabel=label_import)
            protImport.filesPath.set(newFn)
            protImport.samplingRate.set(1.)
            project.launchProtocol(protImport, wait=True)
        else:
            protImport = project.newProtocol(ProtImportAverages, objLabel='import averages')
            project.saveProtocol(protImport)
            
        
        # 2a. Ransac 
        protRansac = project.newProtocol(XmippProtRansac)
        protRansac.setObjLabel('xmipp - ransac')
        protRansac.inputSet.set(protImport)
        protRansac.inputSet.setExtended('outputAverages')
        if testDataKey :
            setProtocolParams(protRansac, testDataKey)
        project.saveProtocol(protRansac)
        
        # 2b. Eman 
        protEmanInitVol = project.newProtocol(EmanProtInitModel)
        protEmanInitVol.setObjLabel('eman - initial vol')
        protEmanInitVol.inputSet.set(protImport)
        protEmanInitVol.inputSet.setExtended('outputAverages')
        if testDataKey :
            setProtocolParams(protEmanInitVol, testDataKey)
        project.saveProtocol(protEmanInitVol)
        
        # 2c. Significant 
        protSignificant = project.newProtocol(XmippProtReconstructSignificant)
        protSignificant.setObjLabel('xmipp - significant')
        protSignificant.inputSet.set(protImport)
        protSignificant.inputSet.setExtended('outputAverages')
        if testDataKey :
            setProtocolParams(protSignificant, testDataKey)
        project.saveProtocol(protSignificant)
        
        # 3. Join result volumes
        p1 = Pointer()
        p1.set(protRansac)
        p1.setExtended('outputVolumes')
        
        p2 = Pointer()
        p2.set(protEmanInitVol)
        p2.setExtended('outputVolumes')
        
        p3 = Pointer()
        p3.set(protSignificant)
        p3.setExtended('outputVolume')
        
        protJoin = project.newProtocol(XmippProtAlignVolumeForWeb)
        protJoin.setObjLabel('align volumes')
        protJoin.inputVolumes.append(p1)
        protJoin.inputVolumes.append(p2)
        protJoin.inputVolumes.append(p3)
#         protJoin.inputVolumes.append(p4)
        project.saveProtocol(protJoin)
        
        protValidate = project.newProtocol(XmippProtValidateNonTilt)
        protValidate.setObjLabel('validate nontilt')
        protValidate.inputVolumes.set(protJoin)
        protValidate.inputVolumes.setExtended('outputVolumes')
        protValidate.inputParticles.set(protImport)
        protValidate.inputParticles.setExtended('outputAverages')
        protValidate.numberOfThreads.set(8)
        if testDataKey :
            setProtocolParams(protValidate, testDataKey)
#         protJoin.inputVolumes.append(p4)
        project.saveProtocol(protValidate)
        
        
    return HttpResponse(mimetype='application/javascript')
Пример #16
0
def create_service_project(request):
    if request.is_ajax():
        import os
        from pyworkflow.object import Pointer
        from pyworkflow.em.protocol import ProtUnionSet, ProtImportAverages
        from pyworkflow.em.packages.xmipp3 import XmippProtRansac, XmippProtReconstructSignificant, XmippProtAlignVolumeForWeb
        from pyworkflow.em.packages.eman2 import EmanProtInitModel
        from pyworkflow.em.packages.simple import ProtPrime

        # Create a new project
        projectName = request.GET.get('projectName')

        # Filename to use as test data
        testDataKey = request.GET.get('testData')

        #customMenu = os.path.join(os.path.dirname(os.environ['SCIPION_PROTOCOLS']), 'menu_initvolume.conf')

        manager = getServiceManager('myfirstmap')
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName,
                                        runsView=1,
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols)

        project.getSettings().setLifeTime(336)  # 14 days * 24 hours
        project.saveSettings()
        #copyFile(customMenu, project.getPath('.config', 'protocols.conf'))

        # 1. Import averages

        # If using test data execute the import averages run
        # options are set in 'project_utils.js'
        dsMDA = DataSet.getDataSet('initial_volume')

        if testDataKey:
            fn = dsMDA.getFile(testDataKey)
            newFn = join(project.uploadPath, basename(fn))
            copyFile(fn, newFn)

            label_import = 'import averages (' + testDataKey + ')'
            protImport = project.newProtocol(ProtImportAverages,
                                             objLabel=label_import)
            protImport.filesPath.set(newFn)
            protImport.samplingRate.set(1.)
            project.launchProtocol(protImport, wait=True)
        else:
            protImport = project.newProtocol(ProtImportAverages,
                                             objLabel='import averages')
            project.saveProtocol(protImport)

        # 2a. Ransac
        protRansac = project.newProtocol(XmippProtRansac)
        protRansac.setObjLabel('xmipp - ransac')
        protRansac.inputSet.set(protImport)
        protRansac.inputSet.setExtended('outputAverages')
        if testDataKey:
            setProtocolParams(protRansac, testDataKey)
        project.saveProtocol(protRansac)

        # 2b. Eman
        protEmanInitVol = project.newProtocol(EmanProtInitModel)
        protEmanInitVol.setObjLabel('eman - initial vol')
        protEmanInitVol.inputSet.set(protImport)
        protEmanInitVol.inputSet.setExtended('outputAverages')
        if testDataKey:
            setProtocolParams(protEmanInitVol, testDataKey)
        project.saveProtocol(protEmanInitVol)

        # 2c. Significant
        protSignificant = project.newProtocol(XmippProtReconstructSignificant)
        protSignificant.setObjLabel('xmipp - significant')
        protSignificant.inputSet.set(protImport)
        protSignificant.inputSet.setExtended('outputAverages')
        if testDataKey:
            setProtocolParams(protSignificant, testDataKey)
        project.saveProtocol(protSignificant)

        # 3. Join result volumes
        p1 = Pointer()
        p1.set(protRansac)
        p1.setExtended('outputVolumes')

        p2 = Pointer()
        p2.set(protEmanInitVol)
        p2.setExtended('outputVolumes')

        p3 = Pointer()
        p3.set(protSignificant)
        p3.setExtended('outputVolume')

        protJoin = project.newProtocol(XmippProtAlignVolumeForWeb)
        protJoin.setObjLabel('align volumes')
        protJoin.inputVolumes.append(p1)
        protJoin.inputVolumes.append(p2)
        protJoin.inputVolumes.append(p3)
        #         protJoin.inputVolumes.append(p4)
        project.saveProtocol(protJoin)


#         protValidate = project.newProtocol(XmippProtValidateNonTilt)
#         protValidate.setObjLabel('validate nontilt')
#         protValidate.inputVolumes.set(protJoin)
#         protValidate.inputVolumes.setExtended('outputVolumes')
#         protValidate.inputParticles.set(protImport)
#         protValidate.inputParticles.setExtended('outputAverages')
#         protValidate.numberOfThreads.set(8)
#         if testDataKey :
#             setProtocolParams(protValidate, testDataKey)
# #         protJoin.inputVolumes.append(p4)
#         project.saveProtocol(protValidate)

    return HttpResponse(mimetype='application/javascript')
Пример #17
0
def create_movies_project(request):

    if request.is_ajax():

        import os
        from pyworkflow.object import Pointer
        from pyworkflow.em.protocol import ProtImportMovies
        from pyworkflow.em.packages.xmipp3 import ProtMovieAlignment

        # Create a new project
        projectName = request.GET.get('projectName')

        # Filename to use as test data
        testDataKey = request.GET.get('testData')

        manager = getServiceManager('movies')
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName,
                                        runsView=1,
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols)

        project.getSettings().setLifeTime(336)  # 14 days * 24 hours
        project.saveSettings()

        #         copyFile(customMenu, project.getPath('.config', 'protocols.conf'))

        # Create symbolic link for uploads
        projectPath = manager.getProjectPath(projectName)
        dest = os.path.join(projectPath, 'Uploads')
        os.rmdir(dest)  #in movies uploads is created as a link
        # @todo: this path to uploads dir should be configurable outside the code...
        source = "/services/scipion/data/uploads/" + projectName
        pwutils.path.makePath(source)
        pwutils.createLink(source, dest)

        # 1. Import movies
        if testDataKey:
            attr = getAttrTestFile(testDataKey)
            path_test = attr['path']

            for f in os.listdir(path_test):
                # Create a symbolic link for each file
                file_path = os.path.join(path_test, f)
                source_file = os.path.join(source, f)
                pwutils.createAbsLink(file_path, source_file)

            label_import = "import movies (" + testDataKey + ")"
            protImport = project.newProtocol(ProtImportMovies,
                                             objLabel=label_import)

            protImport.filesPath.set(attr["filesPath"])
            protImport.voltage.set(attr['voltage'])
            protImport.sphericalAberration.set(attr['sphericalAberration'])
            protImport.amplitudeContrast.set(attr['amplitudeContrast'])
            protImport.magnification.set(attr['magnification'])
            protImport.samplingRate.set(attr['samplingRate'])

            project.launchProtocol(protImport, wait=True)
        else:
            protImport = project.newProtocol(ProtImportMovies,
                                             objLabel='import movies')
            project.saveProtocol(protImport)

        # 2. Movie Alignment
        protMovAlign = project.newProtocol(ProtMovieAlignment)
        protMovAlign.setObjLabel('xmipp - movie alignment')
        protMovAlign.inputMovies.set(protImport)
        protMovAlign.inputMovies.setExtended('outputMovies')
        project.saveProtocol(protMovAlign)

    return HttpResponse(mimetype='application/javascript')
Пример #18
0
def create_service_project(request):
    if request.is_ajax():
        
        # Create a new project
        projectName = getVarFromRequest(request, PROJECT_NAME)
        
        # Filename to use as test data 
        testDataKey = request.GET.get('testData')
        
        manager = getServiceManager(MYFIRSTMAP_SERVICE)
        writeCustomMenu(manager.protocols)
        project = manager.createProject(projectName, runsView=1, 
                                        hostsConf=manager.hosts,
                                        protocolsConf=manager.protocols,
                                        chdir=False)
        
        project.getSettings().setLifeTime(336) # 14 days * 24 hours
        project.saveSettings()
        #copyFile(customMenu, project.getPath('.config', 'protocols.conf'))
        
        # 1. Import averages
        
        # If using test data execute the import averages run
        # options are set in 'project_utils.js'
        dsMDA = DataSet.getDataSet('initial_volume')
        
        if testDataKey :
            fn = dsMDA.getFile(testDataKey)
            newFn = getImageFullPath(project.path, join(project.uploadPath, basename(fn)))
            copyFile(fn, newFn)
            
            label_import = 'import averages ('+ testDataKey +')'
            protImport = project.newProtocol(ProtImportAverages, objLabel=label_import)
            protImport.filesPath.set(newFn)
            protImport.samplingRate.set(1.)
            project.launchProtocol(protImport, wait=True, chdir=False)
        else:
            protImport = project.newProtocol(ProtImportAverages, objLabel='import averages')
            project.saveProtocol(protImport)
        
        # 2a. Ransac 
        protRansac = project.newProtocol(XmippProtRansac)
        protRansac.setObjLabel('xmipp - ransac')
        protRansac.inputSet.set(protImport)
        protRansac.inputSet.setExtended('outputAverages')
        setProtocolParams(protRansac, testDataKey)
        project.saveProtocol(protRansac)
        
        # 2b. Eman 
        protEmanInitVol = project.newProtocol(EmanProtInitModel)
        protEmanInitVol.setObjLabel('eman - initial vol')
        protEmanInitVol.inputSet.set(protImport)
        protEmanInitVol.inputSet.setExtended('outputAverages')
        setProtocolParams(protEmanInitVol, testDataKey)
        project.saveProtocol(protEmanInitVol)
        
        # 2c. Significant 
        protSignificant = project.newProtocol(XmippProtReconstructSignificant)
        protSignificant.setObjLabel('xmipp - significant')
        protSignificant.inputSet.set(protImport)
        protSignificant.inputSet.setExtended('outputAverages')
        setProtocolParams(protSignificant, testDataKey)
        project.saveProtocol(protSignificant)
        
        # 3. Join result volumes
        p1 = Pointer()
        p1.set(protRansac)
        p1.setExtended('outputVolumes')
        
        p2 = Pointer()
        p2.set(protEmanInitVol)
        p2.setExtended('outputVolumes')
        
        p3 = Pointer()
        p3.set(protSignificant)
        p3.setExtended('outputVolume')
        
        protJoin = project.newProtocol(XmippProtAlignVolumeForWeb)
        protJoin.setObjLabel('align volumes')
        protJoin.inputVolumes.append(p1)
        protJoin.inputVolumes.append(p2)
        protJoin.inputVolumes.append(p3)

        project.saveProtocol(protJoin)
        
#         protValidate = project.newProtocol(XmippProtValidateNonTilt)
#         protValidate.setObjLabel('validate nontilt')
#         protValidate.inputVolumes.set(protJoin)
#         protValidate.inputVolumes.setExtended('outputVolumes')
#         protValidate.inputParticles.set(protImport)
#         protValidate.inputParticles.setExtended('outputAverages')
#         protValidate.numberOfThreads.set(8)
#         if testDataKey :
#             setProtocolParams(protValidate, testDataKey)
# #         protJoin.inputVolumes.append(p4)
#         project.saveProtocol(protValidate)
        
        
    return HttpResponse(content_type='application/javascript')