Esempio n. 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'])
Esempio n. 2
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)
        # Get current values of the properties
        #         micfn = os.path.join(coordsDir, 'micrographs.xmd')
        #         writeSetOfMicrographs(micSet, micfn)
        dogpickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(dogpickerProps, "w")

        args = {
            "dogpicker":
            os.path.join(os.environ['DOGPICKER_HOME'], "ApDogPicker.py"),
            "convert":
            os.path.join(os.environ['SCIPION_HOME'],
                         os.path.join('pyworkflow', 'apps', 'pw_convert.py')),
            'coordsDir':
            coordsDir,
            'micsSqlite':
            micSet.getFileName(),
            "diameter":
            autopickProt.diameter,
            "threshold":
            autopickProt.threshold,
            "apix":
            micSet.getSamplingRate()
        }

        f.write("""
        parameters = diameter,threshold
        diameter.value = %(diameter)s
        diameter.label = Diameter
        diameter.help = some help
        threshold.value =  %(threshold)s
        threshold.label = Threshold
        threshold.help = some help
        autopickCommand = %(dogpicker)s  --thresh=%%(threshold) --diam=%%(diameter) --apix=%(apix)s  --image=%%(micrograph) --outfile=%(coordsDir)s/%%(micrographName).txt 
        convertCommand = %(convert)s --coordinates --from dogpicker --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
        """ % args)
        f.close()
        process = CoordinatesObjectView(project,
                                        micfn,
                                        coordsDir,
                                        autopickProt,
                                        pickerProps=dogpickerProps).show()
        process.wait()
        myprops = readProperties(dogpickerProps)
        form.setVar('diameter', myprops['diameter.value'])
        form.setVar('threshold', myprops['threshold.value'])
Esempio n. 3
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" : os.path.join(os.environ['SCIPION_HOME'], "scipion sxprocess.py"),
          "picker" : os.path.join(os.environ['SCIPION_HOME'], "scipion e2boxer.py"),
          "convert" : os.path.join(os.environ['SCIPION_HOME'], os.path.join('pyworkflow','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)
        for param in params:
            form.setVar(param, myprops[param + '.value'])
Esempio n. 4
0
    def show(self, form):
        autopickProt = form.protocol
        autopickFomProt = autopickProt.getInputAutopick()
        project = autopickProt.getProject()
        micSet = autopickFomProt.getInputMicrographs()
        micfn = micSet.getFileName()
        coordsDir = project.getTmpPath(micSet.getName())
        cleanPath(coordsDir)
        makePath(coordsDir)
        pickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerProps, "w")
        args = {
          "picker" : "%s relion_autopick" % pw.getScipionScript(),
          "convert" : pw.join('apps', 'pw_convert.py'),
          'coordsDir':coordsDir,
          'micsSqlite': micSet.getFileName(),
          "diameter": autopickFomProt.particleDiameter,
          "threshold": autopickProt.pickingThreshold,
          "apix": micSet.getSamplingRate(),
          'ang': autopickFomProt.angularSampling,
          'lowpass':autopickFomProt.lowpassFilterRefs,
          'ref': 'input_references.star',
          'min_distance': autopickProt.interParticleDistance,
          'protDir': autopickFomProt.getWorkingDir()
          }

        autopickCommand = '%(picker)s --i extra/%%(micrographName).star --o autopick --particle_diameter %(diameter)s --angpix %(apix)s --ref %(ref)s --ang %(ang)s --lowpass %(lowpass)s --threshold %%(threshold) --min_distance %%(ipd) --read_fom_maps'%args
        if autopickFomProt.refsHaveInvertedContrast:
            autopickCommand += ' --invert'
        
        if autopickFomProt.refsCtfCorrected:
            autopickCommand += ' --ctf'
        args['autopickCommand'] = autopickCommand
        f.write("""
        parameters = ipd,threshold
        ipd.value = %(min_distance)s
        ipd.label = Minimum inter-particles distance
        ipd.help = some help
        threshold.value =  %(threshold)s
        threshold.label = Threshold
        threshold.help = some help
        runDir = %(protDir)s
        autopickCommand = %(autopickCommand)s 
        convertCommand = %(convert)s --coordinates --from relion --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s --extra %(protDir)s/extra
        """ % args)
        f.close()
        process = CoordinatesObjectView(autopickProt.getProject(), micfn, coordsDir, autopickFomProt, pickerProps=pickerProps).show()
        process.wait()
        myprops = readProperties(pickerProps)

        if myprops['applyChanges'] == 'true':
            form.setVar('pickingThreshold', myprops['threshold.value'])
            form.setVar('interParticleDistance', myprops['ipd.value'])
Esempio n. 5
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)
        # Get current values of the properties
#         micfn = os.path.join(coordsDir, 'micrographs.xmd')
#         writeSetOfMicrographs(micSet, micfn)
        dogpickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(dogpickerProps, "w")

        args = {
          "dogpicker" : os.path.join(os.environ['DOGPICKER_HOME'], "ApDogPicker.py"),
          "convert" : os.path.join(os.environ['SCIPION_HOME'], os.path.join('pyworkflow','apps', 'pw_convert.py')),
          'coordsDir':coordsDir,
          'micsSqlite': micSet.getFileName(),
          "diameter": autopickProt.diameter,
          "threshold": autopickProt.threshold,
          "apix": micSet.getSamplingRate()
          }


        f.write("""
        parameters = diameter,threshold
        diameter.value = %(diameter)s
        diameter.label = Diameter
        diameter.help = some help
        threshold.value =  %(threshold)s
        threshold.label = Threshold
        threshold.help = some help
        autopickCommand = %(dogpicker)s  --thresh=%%(threshold) --diam=%%(diameter) --apix=%(apix)s  --image=%%(micrograph) --outfile=%(coordsDir)s/%%(micrographName).txt 
        convertCommand = %(convert)s --coordinates --from dogpicker --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
        """ % args)
        f.close()
        process = CoordinatesObjectView(project, micfn, coordsDir, autopickProt, pickerProps=dogpickerProps).show()
        process.wait()
        myprops = readProperties(dogpickerProps)
        form.setVar('diameter', myprops['diameter.value'])
        form.setVar('threshold', myprops['threshold.value'])
Esempio n. 6
0
    def show(self, form):
        autopickProt = form.protocol
        autopickFomProt = autopickProt.getInputAutopick()
        # Get current values of the properties
        #         _, values = self._getInputProtocol(self._targets, autopickProt)
        #         threshold, distance = values
        #         autopickFomProt.setStepsExecutor() # allow to use runJob
        #         autopickFomProt.autopickStep(threshold, distance, '--read_fom_maps')
        #         print "Writing Xmipp coordinate files."
        #         micFn, coordsDir = autopickFomProt.writeXmippCoords()
        project = autopickProt.getProject()
        micSet = autopickFomProt.getInputMicrographs()
        micfn = micSet.getFileName()
        coordsDir = project.getTmpPath(micSet.getName())
        cleanPath(coordsDir)
        makePath(coordsDir)
        pickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerProps, "w")

        args = {
            "picker":
            os.path.join(os.environ['SCIPION_HOME'],
                         "scipion relion_autopick"),
            "convert":
            os.path.join(os.environ['SCIPION_HOME'],
                         os.path.join('pyworkflow', 'apps', 'pw_convert.py')),
            'coordsDir':
            coordsDir,
            'micsSqlite':
            micSet.getFileName(),
            "diameter":
            autopickFomProt.particleDiameter,
            "threshold":
            autopickProt.pickingThreshold,
            "apix":
            micSet.getSamplingRate(),
            'ang':
            autopickFomProt.angularSampling,
            'lowpass':
            autopickFomProt.lowpassFilterRefs,
            'ref':
            'input_references.star',
            'min_distance':
            autopickProt.interParticleDistance,
            'protDir':
            autopickFomProt.getWorkingDir()
        }

        autopickCommand = '%(picker)s --i extra/%%(micrographName).star --o autopick --particle_diameter %(diameter)s --angpix %(apix)s --ref %(ref)s --ang %(ang)s --lowpass %(lowpass)s --threshold %%(threshold) --min_distance %%(ipd) --read_fom_maps' % args
        if autopickFomProt.refsHaveInvertedContrast:
            autopickCommand += ' --invert'

        if autopickFomProt.refsCtfCorrected:
            autopickCommand += ' --ctf'
        args['autopickCommand'] = autopickCommand
        f.write("""
        parameters = ipd,threshold
        ipd.value = %(min_distance)s
        ipd.label = Minimum inter-particles distance
        ipd.help = some help
        threshold.value =  %(threshold)s
        threshold.label = Threshold
        threshold.help = some help
        runDir = %(protDir)s
        autopickCommand = %(autopickCommand)s 
        convertCommand = %(convert)s --coordinates --from relion --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s --extra %(protDir)s/extra
        """ % args)
        f.close()
        process = CoordinatesObjectView(autopickProt.getProject(),
                                        micfn,
                                        coordsDir,
                                        autopickFomProt,
                                        pickerProps=pickerProps).show()
        process.wait()
        myprops = readProperties(pickerProps)
        form.setVar('pickingThreshold', myprops['threshold.value'])
        form.setVar('interParticleDistance', myprops['ipd.value'])
Esempio n. 7
0
    def show(self, form):
        autopickProt = form.protocol

        if not autopickProt.hasAttribute('outputCoordinates'):
            form.showWarning("You should run the procotol in 'Optimize' mode "
                               "at least once before opening the wizard.")
            return

        project = autopickProt.getProject()
        micSet = autopickProt.outputMicrographs
        micfn = micSet.getFileName()
        coordsDir = project.getTmpPath(micSet.getName())
        cleanPath(coordsDir)
        makePath(coordsDir)

        cmd = '%s relion_autopick ' % pw.getScipionScript()
        cmd += '--i extra/%(micrographName).star '
        cmd += '--threshold %(threshold) --min_distance %(ipd) '
        cmd += ' --max_stddev_noise %(maxStddevNoise) '
        cmd += ' --read_fom_maps'
        cmd += autopickProt.getAutopickParams()

        convertCmd = pw.join('apps', 'pw_convert.py')
        convertCmd += ' --coordinates --from relion --to xmipp '
        convertCmd += ' --input %s' % micSet.getFileName()
        convertCmd += ' --output %s' % coordsDir
        convertCmd += ' --extra %s' % autopickProt._getExtraPath()

        args = {
            "threshold": autopickProt.pickingThreshold,
            'min_distance': autopickProt.interParticleDistance,
            'autopickCommand': cmd,
            'convertCmd': convertCmd,
            'protDir': autopickProt.getWorkingDir(),
            'maxStddevNoise': autopickProt.maxStddevNoise
        }

        pickerProps = os.path.join(coordsDir, 'picker.conf')

        f = open(pickerProps, "w")
        f.write("""
        parameters = ipd,threshold,maxStddevNoise
        ipd.value = %(min_distance)s
        ipd.label = Inter-particles distance
        ipd.help = Minimum distance (in Angstroms) between particles
        threshold.value =  %(threshold)s
        threshold.label = Threshold
        threshold.help = some help
        maxStddevNoise.value = %(maxStddevNoise)s
        maxStddevNoise.label = Max. stddev noise
        maxStddevNoise.help = Prevent picking in carbon areas, useful values probably between 1.0 and 1.2, use -1 to switch it off
        runDir = %(protDir)s
        autopickCommand = %(autopickCommand)s
        convertCommand = %(convertCmd)s
        """ % args)
        f.close()
        process = CoordinatesObjectView(autopickProt.getProject(), micfn,
                                        coordsDir, autopickProt,
                                        pickerProps=pickerProps).show()
        process.wait()
        myprops = readProperties(pickerProps)

        # Check if the wizard changes were accepted or just canceled
        if myprops['applyChanges'] == 'true':
            form.setVar('pickingThreshold', myprops['threshold.value'])
            form.setVar('interParticleDistance', myprops['ipd.value'])
            form.setVar('maxStddevNoise', myprops['maxStddevNoise.value'])
            # Change the run type now to 'Compute' after using the wizard
            # and (supposedly) optimized parameters
            form.setVar('runType', RUN_COMPUTE)
            # Mark the wizard was used
            setattr(autopickProt, 'wizardExecuted', True)
Esempio n. 8
0
    def show(self, form):
        autopickProt = form.protocol
        autopickFomProt = autopickProt.getInputAutopick()
        # Get current values of the properties
#         _, values = self._getInputProtocol(self._targets, autopickProt)
#         threshold, distance = values
#         autopickFomProt.setStepsExecutor() # allow to use runJob
#         autopickFomProt.autopickStep(threshold, distance, '--read_fom_maps')
#         print "Writing Xmipp coordinate files."
#         micFn, coordsDir = autopickFomProt.writeXmippCoords()
        project = autopickProt.getProject()
        micSet = autopickFomProt.getInputMicrographs()
        micfn = micSet.getFileName()
        coordsDir = project.getTmpPath(micSet.getName())
        cleanPath(coordsDir)
        makePath(coordsDir)
        pickerProps = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerProps, "w")
        
        
        
        args = {
          "picker" : os.path.join(os.environ['SCIPION_HOME'],  "scipion relion_autopick"),
          "convert" : os.path.join(os.environ['SCIPION_HOME'], os.path.join('pyworkflow','apps', 'pw_convert.py')),
          'coordsDir':coordsDir,
          'micsSqlite': micSet.getFileName(),
          "diameter": autopickFomProt.particleDiameter,
          "threshold": autopickProt.pickingThreshold,
          "apix": micSet.getSamplingRate(),
          'ang': autopickFomProt.angularSampling,
          'lowpass':autopickFomProt.lowpassFilterRefs,
          'ref': 'input_references.star',
          'min_distance': autopickProt.interParticleDistance,
          'protDir': autopickFomProt.getWorkingDir()
          }

        autopickCommand = '%(picker)s --i extra/%%(micrographName).star --o autopick --particle_diameter %(diameter)s --angpix %(apix)s --ref %(ref)s --ang %(ang)s --lowpass %(lowpass)s --threshold %%(threshold) --min_distance %%(ipd) --read_fom_maps'%args
        if autopickFomProt.refsHaveInvertedContrast:
            autopickCommand += ' --invert'
        
        if autopickFomProt.refsCtfCorrected:
            autopickCommand += ' --ctf'
        args['autopickCommand'] = autopickCommand
        f.write("""
        parameters = ipd,threshold
        ipd.value = %(min_distance)s
        ipd.label = Minimum inter-particles distance
        ipd.help = some help
        threshold.value =  %(threshold)s
        threshold.label = Threshold
        threshold.help = some help
        runDir = %(protDir)s
        autopickCommand = %(autopickCommand)s 
        convertCommand = %(convert)s --coordinates --from relion --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s --extra %(protDir)s/extra
        """ % args)
        f.close()
        process = CoordinatesObjectView(autopickProt.getProject(), micfn, coordsDir, autopickFomProt, pickerProps=pickerProps).show()
        process.wait()
        myprops = readProperties(pickerProps)
        form.setVar('pickingThreshold', myprops['threshold.value'])
        form.setVar('interParticleDistance', myprops['ipd.value'])