示例#1
0
    def show(self, form):
        autopickProt = form.protocol
        micSet = autopickProt.getInputMicrographs()
        if not micSet:
            print 'must specify input micrographs'
            return
        project = autopickProt.getProject()
        micfn = micSet.getFileName()
        coordsDir = project.getTmpPath(micSet.getName())
        cleanPath(coordsDir)
        makePath(coordsDir)

        pickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerProps, "w")
        params = ['boxSize', 'lowerThreshold', 'higherThreshold', 'gaussWidth']
        args = {
            "params": ','.join(params),
            "preprocess": "%s sxprocess.py" % pw.getScipionScript(),
            "picker": "%s e2boxer.py" % pw.getScipionScript(),
            "convert": pw.join('apps', 'pw_convert.py'),
            'coordsDir': coordsDir,
            'micsSqlite': micSet.getFileName(),
            "boxSize": autopickProt.boxSize,
            "lowerThreshold": autopickProt.lowerThreshold,
            "higherThreshold": autopickProt.higherThreshold,
            "gaussWidth": autopickProt.gaussWidth,
            "extraParams": autopickProt.extraParams
        }

        f.write("""
        parameters = %(params)s
        boxSize.value = %(boxSize)s
        boxSize.label = Box Size
        boxSize.help = some help
        lowerThreshold.value =  %(lowerThreshold)s
        lowerThreshold.label = Lower Threshold
        lowerThreshold.help = some help
        higherThreshold.help = some help
        higherThreshold.value =  %(higherThreshold)s
        higherThreshold.label = Higher Threshold
        gaussWidth.help = some help
        gaussWidth.value =  %(gaussWidth)s
        gaussWidth.label = Gauss Width
        runDir = %(coordsDir)s
        preprocessCommand = %(preprocess)s demoparms --makedb=thr_low=%%(lowerThreshold):thr_hi=%%(higherThreshold):boxsize=%%(boxSize):gauss_width=%%(gaussWidth):%(extraParams)s
        autopickCommand = %(picker)s --gauss_autoboxer=demoparms --write_dbbox --boxsize=%%(boxSize) --norm=normalize.ramp.normvar %%(micrograph) 
        convertCommand = %(convert)s --coordinates --from eman2 --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
        """ % args)
        f.close()
        process = CoordinatesObjectView(project,
                                        micfn,
                                        coordsDir,
                                        autopickProt,
                                        pickerProps=pickerProps).show()
        process.wait()
        myprops = readProperties(pickerProps)

        if myprops['applyChanges'] == 'true':
            for param in params:
                form.setVar(param, myprops[param + '.value'])
示例#2
0
def _launchLocal(protocol, wait, stdin=None, stdout=None, stderr=None):
    # Check first if we need to launch with MPI or not

    # zocalo_job_path = protocol.getProject().path

    protStrId = protocol.strId()
    python = pw.SCIPION_PYTHON
    scipion = pw.getScipionScript()
    command = '%s %s runprotocol pw_protocol_run.py "%s" "%s" %s' % (
        python, scipion, protocol.getProject().path, protocol.getDbPath(),
        protStrId)
    hostConfig = protocol.getHostConfig()
    useQueue = protocol.useQueue()

    # our_params = ['runprotocol', 'pw_protocol_run.py', protocol.getProject().path, protocol.getDbPath(), protStrId]
    # our_command = process.buildRunCommand(scipion, our_params, -1, hostConfig=hostConfig, env=python)

    # print('+++++++++New Command++++++++++')
    # print(our_command)

    # Check if need to submit to queue
    if useQueue:
        submitDict = dict(hostConfig.getQueuesDefault())
        submitDict.update(protocol.getSubmitDict())
        submitDict['JOB_COMMAND'] = command
        jobId = _submit(hostConfig, submitDict)
    else:
        jobId = _run(command, wait, stdin, stdout, stderr)

    return jobId
示例#3
0
文件: text.py 项目: liz18/scipion
    def openPath(self, path):
        "Try to open the selected path"
        path = expandPattern(path)

        # If the path is a dir, open it with scipion browser dir <path>
        if os.path.isdir(path):
            dpath = (path if os.path.isabs(path)
                     else os.path.join(os.getcwd(), path))
            subprocess.Popen([pw.getScipionScript(), 'view', dpath])
            return

        # If it is a file, interpret it correctly and open it with DataView
        dirname = os.path.dirname(path)
        fname = os.path.basename(path)
        if '@' in fname:
            path = os.path.join(dirname, fname.split('@', 1)[-1])
        else:
            path = os.path.join(dirname, fname)

        if os.path.exists(path):
            import xmippLib
            fn = xmippLib.FileName(path)
            if fn.isImage() or fn.isMetaData():
                from pyworkflow.em.viewers import DataView
                DataView(path).show()
            else:
                _open_cmd(path)
        else:
            # This is probably one special reference, like sci-open:... that
            # can be interpreted with our handlers.
            tag = path.split(':', 1)[0] if ':' in path else None
            if tag in self.handlers:
                self.handlers[tag](path.split(':', 1)[-1])
            else:
                print "Can't find %s" % path
示例#4
0
文件: text.py 项目: I2PC/scipion
    def openPath(self, path):
        "Try to open the selected path"
        path = expandPattern(path)

        # If the path is a dir, open it with scipion browser dir <path>
        if os.path.isdir(path):
            dpath = (path if os.path.isabs(path)
                     else os.path.join(os.getcwd(), path))
            subprocess.Popen([pw.getScipionScript(), 'view', dpath])
            return

        # If it is a file, interpret it correctly and open it with DataView
        dirname = os.path.dirname(path)
        fname = os.path.basename(path)
        if '@' in fname:
            path = os.path.join(dirname, fname.split('@', 1)[-1])
        else:
            path = os.path.join(dirname, fname)

        if os.path.exists(path):
            import xmipp
            fn = xmipp.FileName(path)
            if fn.isImage() or fn.isMetaData():
                from pyworkflow.em.viewer import DataView
                DataView(path).show()
            else:
                _open_cmd(path)
        else:
            # This is probably one special reference, like sci-open:... that
            # can be interpreted with our handlers.
            tag = path.split(':', 1)[0] if ':' in path else None
            if tag in self.handlers:
                self.handlers[tag](path.split(':', 1)[-1])
            else:
                print "Can't find %s" % path
示例#5
0
文件: launch.py 项目: liz18/scipion
def schedule(protocol, wait=False):
    """ Use this function to schedule protocols that are not ready to
    run yet. Right now it only make sense to schedule jobs locally.
    """
    cmd = '%s %s runprotocol pw_schedule_run.py' % (pw.PYTHON,
                                                    pw.getScipionScript())
    cmd += ' "%s" "%s" %s' % (protocol.getProject().path, protocol.getDbPath(),
                              protocol.strId())
    jobId = _run(cmd, wait)
    protocol.setJobId(jobId)

    return jobId
示例#6
0
    def _createScipionProject(self):

        dataPath = self.getConfValue(DEPOSITION_PATTERN)
        projectName = self.getConfValue(PROJECT_NAME)
        projectPath = os.path.join(self.getConfValue(PROJECTS_PATH),
                                   projectName)

        print("")
        print("Deposition Pattern: %s" % dataPath)
        print("Project Name: %s" % projectName)
        print("Project Path: %s" % projectPath)

        # Launch the simulation
        if self.getConfValue(SIMULATION):
            rawData = self.getConfValue(RAWDATA_SIM)

            gainGlob = os.path.join(rawData, self.getConfValue(GAIN_PAT))
            gainPath = gainGlob[0] if len(gainGlob) > 0 else ''
            rawDataPath = os.path.join(rawData, self.getConfValue(PATTERN))

            subprocess.Popen('%s python %s "%s" %s %d %s &' %
                             (pw.getScipionScript(), 'simulate_acquisition.py',
                              rawDataPath, self.getConfValue(DEPOSITION_DIR),
                              self.getConfValue(TIMEOUT), gainPath),
                             shell=True)
            time.sleep(1)

        # Check if there are something to process
        count = 1
        while not len(pwutils.glob(dataPath)):
            if count == 6:
                self.windows.close()

            string = ("No file found in %s.\n"
                      "Make sure that the acquisition has been started.\n\n" %
                      dataPath)
            if count < 5:
                str2 = "Retrying... (%s/5)" % count
            else:
                str2 = "Last try..."
            try:
                self.windows.showInfo(string + str2)
            except:  # When 'Cancel' is press
                sys.exit(0)
            time.sleep(3)
            count += 1

        preprocessWorkflow(self.configDict)

        os.system('touch /tmp/scipion/project_%s' % projectName)
        if self.getConfValue(WAIT2PICK, False):
            os.system('touch /tmp/scipion/wait2pick_%s' % projectName)
示例#7
0
文件: launch.py 项目: I2PC/scipion
def schedule(protocol, wait=False):
    """ Use this function to schedule protocols that are not ready to
    run yet. Right now it only make sense to schedule jobs locally.
    """
    protStrId = protocol.strId()
    python = pw.SCIPION_PYTHON
    scipion = pw.getScipionScript()
    cmd = '%s %s runprotocol pw_schedule_run.py' % (python, scipion)
    cmd += ' "%s" "%s" %s' % (protocol.getProject().path,
                              protocol.getDbPath(),
                              protStrId)
    jobId = _run(cmd, wait)
    protocol.setJobId(jobId)

    return jobId
示例#8
0
文件: tests.py 项目: liz18/scipion
    def getDataSet(cls, name):
        """
        This method is called every time the dataset want to be retrieved
        """
        assert name in cls._datasetDict, "Dataset: %s dataset doesn't exist." % name

        ds = cls._datasetDict[name]
        folder = ds.folder
        url = '' if ds.url is None else ' -u ' + ds.url

        if not pw.utils.envVarOn('SCIPION_TEST_NOSYNC'):
            command = ("%s %s testdata --download %s %s" %
                       (pw.PYTHON, pw.getScipionScript(), folder, url))
            print(">>>> %s" % command)
            os.system(command)
        return cls._datasetDict[name]
示例#9
0
文件: launch.py 项目: liz18/scipion
def _launchLocal(protocol, wait, stdin=None, stdout=None, stderr=None):
    # Check first if we need to launch with MPI or not
    command = ('%s %s runprotocol pw_protocol_run.py "%s" "%s" %s' %
               (pw.PYTHON, pw.getScipionScript(), protocol.getProject().path,
                protocol.getDbPath(), protocol.strId()))
    hostConfig = protocol.getHostConfig()
    useQueue = protocol.useQueue()
    # Check if need to submit to queue
    if useQueue and (protocol.getSubmitDict()["QUEUE_FOR_JOBS"] == "N"):
        submitDict = dict(hostConfig.getQueuesDefault())
        submitDict.update(protocol.getSubmitDict())
        submitDict['JOB_COMMAND'] = command
        jobId = _submit(hostConfig, submitDict)
    else:
        jobId = _run(command, wait, stdin, stdout, stderr)

    return jobId
示例#10
0
def _launchLocal(protocol, wait, stdin=None, stdout=None, stderr=None):
    # Check first if we need to launch with MPI or not
    protStrId = protocol.strId()
    python = pw.SCIPION_PYTHON
    scipion = pw.getScipionScript()
    command = '%s %s runprotocol pw_protocol_run.py "%s" "%s" %s' % (
        python, scipion, protocol.getProject().path, protocol.getDbPath(),
        protStrId)
    hostConfig = protocol.getHostConfig()
    useQueue = protocol.useQueue()
    # Check if need to submit to queue
    if useQueue:
        submitDict = dict(hostConfig.getQueuesDefault())
        submitDict.update(protocol.getSubmitDict())
        submitDict['JOB_COMMAND'] = command
        jobId = _submit(hostConfig, submitDict)
    else:
        jobId = _run(command, wait, stdin, stdout, stderr)

    return jobId
示例#11
0
文件: launch.py 项目: I2PC/scipion
def _launchLocal(protocol, wait, stdin=None, stdout=None, stderr=None):
    # Check first if we need to launch with MPI or not
    protStrId = protocol.strId()
    python = pw.SCIPION_PYTHON
    scipion = pw.getScipionScript()
    command = '%s %s runprotocol pw_protocol_run.py "%s" "%s" %s' % (python, scipion,
                                                                     protocol.getProject().path, 
                                                                     protocol.getDbPath(), 
                                                                     protStrId)
    hostConfig = protocol.getHostConfig()
    useQueue = protocol.useQueue()
    # Check if need to submit to queue    
    if useQueue:        
        submitDict = dict(hostConfig.getQueuesDefault())
        submitDict.update(protocol.getSubmitDict())
        submitDict['JOB_COMMAND'] = command
        jobId = _submit(hostConfig, submitDict)
    else:
        jobId = _run(command, wait, stdin, stdout, stderr)

    return jobId
示例#12
0
    def createProjectFromWorkflow(self, workflow):

        projectName = self._getValue(PROJECT_NAME)

        scipion = pw.getScipionScript()
        scriptsPath = pw.join('project', 'scripts')

        # Download the required data
        # pwutils.runCommand(scipion +
        #                     " testdata --download jmbFalconMovies")

        # Create the project
        createProjectScript = os.path.join(scriptsPath, 'create.py')
        pwutils.runCommand(scipion + " python " + createProjectScript + " " +
                           projectName + " " + workflow)

        # Schedule the project
        scheduleProjectScript = os.path.join(scriptsPath, 'schedule.py')
        pwutils.runCommand(scipion + " python " + scheduleProjectScript + " " +
                           projectName)

        # Launch scipion
        pwutils.runCommand(scipion + " project " + projectName)
示例#13
0
    def _runNewItem(self, itemType, itemName):
        if self._match(itemName):
            spaces = (itemType * 2) * ' '
            scipion = pw.getScipionScript()
            cmd = "%s %s test %s" % (spaces, scipion, itemName)
            run = ((itemType == MODULE and self.mode == 'module') or
                   (itemType == CLASS and self.mode == 'classes') or
                   (itemType == TEST and self.mode == 'all'))
            if run:
                if self.log:
                    logFile = join(self.testsDir, '%s.txt' % itemName)
                    cmdFull = cmd + " > %s 2>&1" % logFile
                else:
                    logFile = ''
                    cmdFull = cmd

                print(pwutils.green(cmdFull))
                t = pwutils.Timer()
                t.tic()
                self.testCount += 1
                result = os.system(cmdFull)
                if self.log:
                    self._logTest(cmd.replace(scipion, 'scipion'),
                                  t.getToc(), result, logFile)
    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()
    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()
示例#16
0
    def show(self, form):
        autopickProt = form.protocol
        micSet = autopickProt.getInputMicrographs()
        if not micSet:
            print('must specify input micrographs')
            return

        # ensuring a valid boxSize
        if autopickProt.boxSize.get() is None:
            autopickProt.boxSize.set(100)

        project = autopickProt.getProject()
        coordsDir = project.getTmpPath(micSet.getName())

        cleanPath(coordsDir)
        makePath(coordsDir)

        micMdFn = os.path.join(coordsDir, "micrographs.xmd")
        writeSetOfMicrographs(micSet, micMdFn)

        pickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerProps, "w")
        params = ['boxSize', 'lowerThreshold', 'higherThreshold', 'gaussWidth']
        program = eman2.Plugin.getBoxerCommand(boxerVersion='old')

        extraParams = "invert_contrast=%s:use_variance=%s:%s" % (
            autopickProt.doInvert,
            autopickProt.useVarImg,
            autopickProt.extraParams)

        args = {
            "params": ','.join(params),
            "preprocess": "%s %s" % (pw.getScipionScript(),
                                     eman2.Plugin.getProgram('sxprocess.py')),
            "picker": "%s %s" % (pw.getScipionScript(), program),
            "convert": pw.join('apps', 'pw_convert.py'),
            'coordsDir': coordsDir,
            'micsSqlite': micSet.getFileName(),
            "boxSize": autopickProt.boxSize,
            "lowerThreshold": autopickProt.lowerThreshold,
            "higherThreshold": autopickProt.higherThreshold,
            "gaussWidth": autopickProt.gaussWidth,
            "extraParams": extraParams
        }

        f.write("""
        parameters = %(params)s
        boxSize.value = %(boxSize)s
        boxSize.label = Box Size
        boxSize.help = Box size in pixels
        lowerThreshold.value =  %(lowerThreshold)s
        lowerThreshold.label = Lower Threshold
        lowerThreshold.help = Lower Threshold
        higherThreshold.help = Higher Threshold
        higherThreshold.value =  %(higherThreshold)s
        higherThreshold.label = Higher Threshold
        gaussWidth.help = Width of the Gaussian kernel used
        gaussWidth.value =  %(gaussWidth)s
        gaussWidth.label = Gauss Width
        runDir = %(coordsDir)s
        preprocessCommand = %(preprocess)s demoparms --makedb=thr_low=%%(lowerThreshold):thr_hi=%%(higherThreshold):boxsize=%%(boxSize):gauss_width=%%(gaussWidth):%(extraParams)s
        autopickCommand = %(picker)s --gauss_autoboxer=demoparms --write_dbbox --boxsize=%%(boxSize) --norm=normalize.ramp.normvar %%(micrograph) 
        convertCommand = %(convert)s --coordinates --from eman2 --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
        """ % args)
        f.close()
        process = CoordinatesObjectView(project, micMdFn, coordsDir, autopickProt,
                                        mode=CoordinatesObjectView.MODE_AUTOMATIC,
                                        pickerProps=pickerProps).show()
        process.wait()
        myprops = readProperties(pickerProps)

        if myprops['applyChanges'] == 'true':
            for param in params:
                form.setVar(param, myprops[param + '.value'])
示例#17
0
文件: wizard.py 项目: I2PC/scipion
    def show(self, form):
        autopickProt = form.protocol
        micSet = autopickProt.getInputMicrographs()
        if not micSet:
            print 'must specify input micrographs'
            return
        project = autopickProt.getProject()
        micfn = micSet.getFileName()
        coordsDir = project.getTmpPath(micSet.getName())

        cleanPath(coordsDir)
        makePath(coordsDir)

        from pyworkflow.em.packages.xmipp3 import writeSetOfMicrographs
        micMdFn = os.path.join(coordsDir, "micrographs.xmd")
        writeSetOfMicrographs(micSet, micMdFn)

        
        pickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerProps, "w")
        params = ['boxSize', 'lowerThreshold', 'higherThreshold', 'gaussWidth']
        args = {
          "params": ','.join(params),
          "preprocess" : "%s sxprocess.py" % pw.getScipionScript(),
          "picker" : "%s e2boxer.py" % pw.getScipionScript(),
          "convert" : pw.join('apps', 'pw_convert.py'),
          'coordsDir': coordsDir,
          'micsSqlite': micSet.getFileName(),
          "boxSize": autopickProt.boxSize,
          "lowerThreshold": autopickProt.lowerThreshold,
          "higherThreshold": autopickProt.higherThreshold,
          "gaussWidth": autopickProt.gaussWidth,
          "extraParams":autopickProt.extraParams
          }


        f.write("""
        parameters = %(params)s
        boxSize.value = %(boxSize)s
        boxSize.label = Box Size
        boxSize.help = some help
        lowerThreshold.value =  %(lowerThreshold)s
        lowerThreshold.label = Lower Threshold
        lowerThreshold.help = some help
        higherThreshold.help = some help
        higherThreshold.value =  %(higherThreshold)s
        higherThreshold.label = Higher Threshold
        gaussWidth.help = some help
        gaussWidth.value =  %(gaussWidth)s
        gaussWidth.label = Gauss Width
        runDir = %(coordsDir)s
        preprocessCommand = %(preprocess)s demoparms --makedb=thr_low=%%(lowerThreshold):thr_hi=%%(higherThreshold):boxsize=%%(boxSize):gauss_width=%%(gaussWidth):%(extraParams)s
        autopickCommand = %(picker)s --gauss_autoboxer=demoparms --write_dbbox --boxsize=%%(boxSize) --norm=normalize.ramp.normvar %%(micrograph) 
        convertCommand = %(convert)s --coordinates --from eman2 --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
        """ % args)
        f.close()
        process = CoordinatesObjectView(project, micMdFn, coordsDir, autopickProt,
                                        mode=CoordinatesObjectView.MODE_AUTOMATIC,
                                        pickerProps=pickerProps).show()
        process.wait()
        myprops = readProperties(pickerProps)

        if myprops['applyChanges'] == 'true':
            for param in params:
                form.setVar(param, myprops[param + '.value'])