当前位置: 首页>>代码示例>>Python>>正文


Python utils.cleanPath函数代码示例

本文整理汇总了Python中pyworkflow.utils.cleanPath函数的典型用法代码示例。如果您正苦于以下问题:Python cleanPath函数的具体用法?Python cleanPath怎么用?Python cleanPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了cleanPath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _restimateCTF

    def _restimateCTF(self, ctfId):
        """ Run ctffind3 with required parameters """

        ctfModel = self.recalculateSet[ctfId]
        mic = ctfModel.getMicrograph()
        micFn = mic.getFileName()
        micDir = self._getMicrographDir(mic)
        
        out = self._getCtfOutPath(micDir)
        psdFile = self._getPsdPath(micDir)
        
        pwutils.cleanPath(out)
        micFnMrc = self._getTmpPath(pwutils.replaceBaseExt(micFn, "mrc"))
        em.ImageHandler().convert(micFn, micFnMrc, em.DT_FLOAT)

        # Update _params dictionary
        self._prepareRecalCommand(ctfModel)
        self._params['micFn'] = micFnMrc
        self._params['micDir'] = micDir
        self._params['ctffindOut'] = out
        self._params['ctffindPSD'] = psdFile
        
        pwutils.cleanPath(psdFile)
        try:
            self.runJob(self._program, self._args % self._params)
        except Exception, ex:
            print >> sys.stderr, "ctffind has failed with micrograph %s" % micFnMrc
开发者ID:azazellochg,项目名称:scipion,代码行数:27,代码来源:protocol_ctffind.py

示例2: show

    def show(self, form):
        prot = form.protocol
        micSet = prot.getInputMicrographs()

        if not micSet:
            print 'must specify input micrographs'
            return

        project = prot.getProject()
        micfn = micSet.getFileName()

        # Prepare a temporary folder to convert some input files
        # and put some of the intermediate result files
        coordsDir = project.getTmpPath(micSet.getName())
        pwutils.cleanPath(coordsDir)
        pwutils.makePath(coordsDir)
        prot.convertInputs(coordsDir)

        pickerConfig = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerConfig, "w")

        pickScript = pw.join('em', 'packages', 'igbmc', 'run_gempicker.py')

        pickCmd = prot._getPickArgs(threshold=False, workingDir=coordsDir)[0]
        convertCmd = pw.join('apps', 'pw_convert.py')

        args = {
                "pickScript": pickScript,
                "pickCmd": pickCmd,
                "convertCmd": convertCmd,
                'coordsDir': coordsDir,
                'micsSqlite': micSet.getFileName(),
                'thresholdLow': prot.thresholdLow,
                'thresholdHigh': prot.thresholdHigh,
                "useGPU": prot.useGPU
          }

        f.write("""
        parameters = thresholdLow,thresholdHigh
        thresholdLow.value =  %(thresholdLow)s
        thresholdLow.label = Threshold Low
        thresholdLow.help = Low value cut-off
        thresholdHigh.value =  %(thresholdHigh)s
        thresholdHigh.label = Threshold High
        thresholdHigh.help = High value cut-off
        autopickCommand = %(pickScript)s %%(micrograph) %(coordsDir)s %(useGPU)s %(pickCmd)s --thresh=%%(thresholdLow) --threshHigh=%%(thresholdHigh)
        convertCommand = %(convertCmd)s --coordinates --from gempicker --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
        """ % args)

        f.close()

        process = CoordinatesObjectView(project, micfn, coordsDir, prot,
                                        mode=CoordinatesObjectView.MODE_AUTOMATIC,
                                        pickerProps=pickerConfig).show()
        process.wait()
        myprops = pwutils.readProperties(pickerConfig)

        if myprops['applyChanges'] == 'true':
            form.setVar('thresholdLow', myprops['thresholdLow.value'])
            form.setVar('thresholdHigh', myprops['thresholdHigh.value'])
开发者ID:I2PC,项目名称:scipion,代码行数:60,代码来源:wizard.py

示例3: runProjectionMatching

def runProjectionMatching(self, iterN, refN, args, **kwargs):
    """ Loop over all CTF groups and launch a projection matching for each one.
    Note: Iterate ctf groups in reverse order to have same order as 
          in add_to docfiles from angular_class_average. #FIXME: check why reverse order is needed
    """
    projMatchRootName = self._getFileName('projMatchRootNames', iter=iterN, ref=refN)
    refname = self._getFileName('projectLibraryStk', iter=iterN, ref=refN)
    
    numberOfCtfGroups = self.numberOfCtfGroups.get()
#     ctfGroupName = self._getPath(self.ctfGroupDirectory, '%(ctfGroupRootName)s')
    #remove output metadata
    cleanPath(projMatchRootName)
    
    for ctfN in reversed(list(self.allCtfGroups())):
        self._log.info('CTF group: %d/%d' % (ctfN, numberOfCtfGroups))
        ctfArgs = ' -i %(inputdocfile)s -o %(outputname)s --ref %(refname)s'        
        
        inputdocfile = self._getBlockFileName(ctfBlockName, ctfN, self.docFileInputAngles[iterN-1])
        outputname = self._getBlockFileName(ctfBlockName, ctfN, projMatchRootName)
        baseTxtFile = removeExt(refname)
        neighbFile = baseTxtFile + '_sampling.xmd'
        cleanPath(neighbFile)
        neighbFileb = baseTxtFile + '_group' + str(ctfN).zfill(self.FILENAMENUMBERLENGTH) + '_sampling.xmd'
        copyFile(neighbFileb, neighbFile)
        print "copied file ", neighbFileb, "to", neighbFile
        if self.doCTFCorrection and self._referenceIsCtfCorrected[iterN]:
            ctfArgs += ' --ctf %s' % self._getBlockFileName('', ctfN, self._getFileName('stackCTFs'))
    
        progArgs = ctfArgs % locals() + args
        self.runJob('xmipp_angular_projection_matching', progArgs, **kwargs)
开发者ID:denisfortun,项目名称:scipion,代码行数:30,代码来源:projmatch_steps.py

示例4: scipion_split_particle_stacks

def scipion_split_particle_stacks(inputStar, inputStack, output, filename_prefix, deleteStack):
    """ Read a STAR file with particles and write as individual images.
    If a stack of images is given, use these instead of the images from the STAR file.
    Also write a new STAR file pointing to these images.
    This function requires that the script is run within Scipion Python environment. """

    import pyworkflow.utils as pwutils
    from pyworkflow.em import ImageHandler
    ih = ImageHandler()
    md = MetaData(inputStar)
    md.addLabels('rlnOriginalName')

    # Initialize progress bar
    progressbar = ProgressBar(width=60, total=len(md))

    for i, particle in enumerate(md, start=1):
        outputImageName = '%s/%s_%06d.mrc' % (output, filename_prefix, i)

        if inputStack:
            ih.convert((i, inputStack), outputImageName )
            particle.rlnOriginalName = '%s/%[email protected]%s' %(output, i, inputStack)
        else:
            ih.convert(particle.rlnImageName, outputImageName)
            particle.rlnOriginalName = particle.rlnImageName

        particle.rlnImageName = outputImageName

        progressbar.notify()

    print("\n")
    md.write("%s/%s.star" % (output, filename_prefix))

    if inputStack and deleteStack:
        pwutils.cleanPath(inputStack)
开发者ID:OPIC-Oxford,项目名称:localrec,代码行数:34,代码来源:localized_reconstruction.py

示例5: extractMicrographStep

    def extractMicrographStep(self, micKey, *args):
        """ Step function that will be common for all extraction protocols.
        It will take an id and will grab the micrograph from a micDict map.
        The micrograph will be passed as input to the _extractMicrograph
        function.
        """
        # Retrieve the corresponding micrograph with this key and the
        # associated list of coordinates
        mic = self.micDict[micKey]

        micDoneFn = self._getMicDone(mic)
        micFn = mic.getFileName()

        if self.isContinued() and os.path.exists(micDoneFn):
            self.info("Skipping micrograph: %s, seems to be done" % micFn)
            return

        coordList = self.coordDict[mic.getObjId()]
        self._convertCoordinates(mic, coordList)

        # Clean old finished files
        pwutils.cleanPath(micDoneFn)

        self.info("Extracting micrograph: %s " % micFn)
        self._extractMicrograph(mic, *args)

        # Mark this mic as finished
        open(micDoneFn, 'w').close()
开发者ID:I2PC,项目名称:scipion,代码行数:28,代码来源:protocol_particles.py

示例6: nestedFlatDb

 def nestedFlatDb(self): 
     fn = 'classes_flat.sqlite'
     cleanPath(fn)
     
     images = SetOfImages()
     images.setSamplingRate(1.2)
     classes2DSet = SetOfClasses2D(filename=fn)
     classes2DSet.setImages(images)
 
     for ref in range(1, 11):
         print "class: ", ref
         class2D = Class2D()
         class2D.setObjId(ref)
         print "append class to set, ref=", ref
         classes2DSet.append(class2D)
         avg = Particle()
         avg.setLocation(ref, 'averages.stk')
         print "   populating class "
         for i in range(1, 101):         
             img = Particle()
             img.setSamplingRate(5.3)
             class2D.append(img)
                 
         print "   writing class "
         class2D.write()
         print "   append avg"
         averages.append(avg)
     
     classes2DSet.write()
开发者ID:coocoky,项目名称:scipion,代码行数:29,代码来源:test_workflow_existing.py

示例7: exportData

def exportData(emxDir, inputSet, ctfSet=None,
               xmlFile='data.emx', binaryFile=None,
               doConvert=True):
    """ Export micrographs, coordinates or particles to  EMX format. """
    pwutils.cleanPath(emxDir)
    pwutils.makePath(emxDir) 
    emxData = emxlib.EmxData()
    micSet=None
    
    if isinstance(inputSet, SetOfMicrographs):
        _micrographsToEmx(emxData, inputSet, emxDir, ctfSet, writeData=True)
        
    elif isinstance(inputSet, SetOfCoordinates):
        micSet = inputSet.getMicrographs()
        _micrographsToEmx(emxData, micSet, emxDir, ctfSet)

        _particlesToEmx(emxData, inputSet, micSet, writeImages=False)
#        _particlesToEmx(emxData, inputSet, None, micSet, doConvert=doConvert)
        
    elif isinstance(inputSet, SetOfParticles):
        if inputSet.hasCoordinates():
            micSet = inputSet.getCoordinates().getMicrographs()
            _micrographsToEmx(emxData, micSet, emxDir, writeData=False)

        kwargs = {'writeImages': True}
        
        if binaryFile is None:
            kwargs['imagesPrefix'] = emxDir
        else:
            kwargs['imagesStack'] = join(emxDir, binaryFile)
            
        _particlesToEmx(emxData, inputSet, micSet, **kwargs)

    fnXml = join(emxDir, xmlFile)
    emxData.write(fnXml)
开发者ID:azazellochg,项目名称:scipion,代码行数:35,代码来源:convert.py

示例8: decompress

 def decompress(program, args, ext, nExt):
     movieFolder = self._getTmpPath()
     movieName = basename(movie.getFileName())
     movieTmpLink = join(movieFolder, movieName)
     pwutils.cleanPath(movieTmpLink)
     pwutils.createAbsLink(os.path.abspath(movieFn), movieTmpLink)
     self.runJob(program, args % movieName, cwd=movieFolder)
     dimMovie.setFileName(movieTmpLink.replace(ext, nExt))
开发者ID:I2PC,项目名称:scipion,代码行数:8,代码来源:micrographs.py

示例9: writeVolumesSqlite

def writeVolumesSqlite(volsXml, volsSqlite, **kwargs):
    """ Convert a volume list from PyTom xml format to Scipion sqlite file.
    If the volSqlite exists, it will be deleted.
    """
    pwutils.cleanPath(volsSqlite)
    volSet = em.SetOfVolumes(filename=volsSqlite)    
    readSetOfVolumes(volsXml, volSet, **kwargs)
    volSet.write()
开发者ID:josegutab,项目名称:scipion,代码行数:8,代码来源:convert.py

示例10: runCase

    def runCase(self, args, mpi=0, changeDir=False, 
                preruns=None, postruns=None, validate=None,
                outputs=None, random=False):
        # Retrieve the correct case number from the test name id
        # We asumme here that 'test_caseXXX' should be in the name
        caseId = unittest.TestCase.id(self)
        if not 'test_case' in caseId:
            raise Exception("'test_case' string should be in the test function name followed by a number")
        _counter = int(caseId.split('test_case')[1])

        self._testDir = self.dataset.getPath()
        self.outputDir = os.path.join('tmpLink', '%s_%02d' % (self.program, _counter))
        self.outputDirAbs = os.path.join(self._testDir, self.outputDir)
        self.goldDir = os.path.join(self._testDir, 'gold', '%s_%02d' % (self.program, _counter))
        
        # Clean and create the program output folder if not exists
        pwutils.cleanPath(self.outputDirAbs)
        pwutils.makePath(self.outputDirAbs)
        
        # Change to tests root folder (self._testDir)
        cwd = os.getcwd()
        os.chdir(self._testDir)
        
        if preruns:
            self._runCommands(preruns, 'preruns')
            
        if mpi:
            cmd = "mpirun -np %d `which %s`" % (mpi, self.program)
        else:
            cmd = self.program
        
        args = self._parseArgs(args)
        
        if changeDir:
            cmd = "cd %s ; %s %s > stdout.txt 2> stderr.txt" % (self.outputDir, cmd, args)
        else:
            cmd = "%s %s > %s/stdout.txt 2> %s/stderr.txt" % (cmd, args, self.outputDir, self.outputDir)
        print "    Command: "
        print "       ", pwutils.green(cmd)
            
        #run the test itself
        command = Command(cmd, env=self.env)
        self._command = command
        try:
            command.run(timeout=self._timeout)
        except KeyboardInterrupt:
            command.terminate()
        
        if postruns:
            self._runCommands(postruns, 'postruns')
            
        if outputs:
            self._checkOutputs(outputs,random)
            
        if validate:
            validate()
            
        os.chdir(cwd)
开发者ID:azazellochg,项目名称:scipion,代码行数:58,代码来源:base.py

示例11: close

 def close(self, e=None):
     try:
         print "Writing protocols to: ", jsonFn
         proj.getRunsGraph() # Build project runs graph
         proj.exportProtocols(proj.getRuns(), jsonFn)
         print "Deleting temporary folder: ", customUserData
         pwutils.cleanPath(customUserData)
     except Exception, ex:
         print "Error saving the workflow: ", ex
开发者ID:I2PC,项目名称:scipion,代码行数:9,代码来源:edit_workflow.py

示例12: filterStep

 def filterStep(self, args):
     """ Apply the selected filter to particles. 
     Create the set of particles.
     """
     particlesStk = self._getPath('particles.spi')
     tmpStk = particlesStk.replace('.spi', '_tmp.spi')
     self.runJob('bfilter', args + ' %s %s' % (particlesStk, tmpStk))
     pwutils.moveFile(tmpStk, particlesStk.replace('.spi', '.stk')) # just we prefer stk as stack of spider images
     pwutils.cleanPath(particlesStk)
开发者ID:I2PC,项目名称:scipion,代码行数:9,代码来源:protocol_bfilter.py

示例13: _writeXmippCoords

 def _writeXmippCoords(self, coordSet):
     micSet = self.getInputMicrographs()
     coordPath = self._getTmpPath('xmipp_coordinates')
     pwutils.cleanPath(coordPath)
     pwutils.makePath(coordPath)
     import pyworkflow.em.packages.xmipp3 as xmipp3
     micPath = micSet.getFileName()
     xmipp3.writeSetOfCoordinates(coordPath, coordSet, ismanual=False)
     return micPath, coordPath
开发者ID:I2PC,项目名称:scipion,代码行数:9,代码来源:protocol_autopick_v2.py

示例14: filterStep

 def filterStep(self, args):
     """ Apply the selected filter to particles. 
     Create the set of particles.
     """
     particlesStk = self._getPath("particles.spi")
     tmpStk = particlesStk.replace(".spi", "_tmp.spi")
     self.runJob("bfilter", args + " %s %s" % (particlesStk, tmpStk))
     pwutils.moveFile(tmpStk, particlesStk.replace(".spi", ".stk"))  # just we prefer stk as stack of spider images
     pwutils.cleanPath(particlesStk)
开发者ID:josegutab,项目名称:scipion,代码行数:9,代码来源:protocol_bfilter.py

示例15: _writeXmippCoords

 def _writeXmippCoords(self, coordSet):
     micSet = self.getInputMicrographs()
     coordPath = self._getTmpPath('xmipp_coordinates')
     pwutils.cleanPath(coordPath)
     pwutils.makePath(coordPath)
     import pyworkflow.em.packages.xmipp3 as xmipp3
     micPath = os.path.join(coordPath, 'micrographs.xmd')
     xmipp3.writeSetOfMicrographs(micSet, micPath)
     xmipp3.writeSetOfCoordinates(coordPath, coordSet)
     return micPath, coordPath
开发者ID:denisfortun,项目名称:scipion,代码行数:10,代码来源:protocol_autopick.py


注:本文中的pyworkflow.utils.cleanPath函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。