Пример #1
0
    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'])
Пример #2
0
def createProjectFromWorkflow(workflow, projectName, argsList):
    scipion = SCIPION_EP
    scriptsPath = pw.join('project', 'scripts')

    # Clean the project name as pyworkflow will do
    projectName = Project.cleanProjectName(projectName)

    # Create the project
    print("Creating project %s" % projectName)
    createProjectScript = os.path.join(scriptsPath, 'create.py')
    os.system("python -m %s  python %s %s %s" %
              (scipion, createProjectScript, projectName, workflow))
    # Wait 2 seconds to avoid activity
    time.sleep(2)

    if scheduleProject(argsList):

        # Schedule the project
        scheduleProjectScript = os.path.join(scriptsPath, 'schedule.py')
        print("Scheduling project %s" % projectName)
        subprocess.Popen([
            "python", "-m", scipion, "python", scheduleProjectScript,
            projectName
        ])
        # Wait 5 seconds to avoid activity
        time.sleep(5)

    if launchGUI(argsList):

        print("Showing project %s" % projectName)
        # Launch scipion
        subprocess.Popen(["python", "-m", scipion, MODE_PROJECT, projectName])
Пример #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": "%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'])
Пример #4
0
    def __init__(self, volfile, sendEnd=True,**kwargs):
        if volfile.endswith('.mrc'):
            volfile += ':mrc'

        self.kwargs = kwargs
        if volfile is None:
            raise ValueError(volfile)
        if '@' in volfile:
            [index, file] = volfile.split('@'); 
        else :
            file = volfile
        if ':' in file:
            file = file[0: file.rfind(':')]
        if not os.path.exists(file):
            raise Exception("File %s does not exists"%file)

        self.volfile = volfile
        self.voxelSize = self.kwargs.get('voxelSize', None)
        # ChimeraServer is the basic server. There are other
        # than inherit from it.
        serverName=self.kwargs.get('ChimeraServer','ChimeraServer')
        self.address = ''
        self.port = getFreePort()

        serverfile = pw.join('em', 'chimera_server.py')
        command = CommandView("chimera --script '%s %s %s' &" %
                              (serverfile, self.port,serverName),
                             env=getChimeraEnviron(),).show()
        self.authkey = 'test'
        self.client = Client((self.address, self.port), authkey=self.authkey)
        self.initVolumeData()
        self.openVolumeOnServer(self.vol,sendEnd)
        self.initListenThread()
Пример #5
0
    def __init__(self, volfile, sendEnd=True,**kwargs):
        if volfile.endswith('.mrc'):
            volfile += ':mrc'

        self.kwargs = kwargs
        if volfile is None:
            raise ValueError(volfile)
        if '@' in volfile:
            [index, file] = volfile.split('@'); 
        else :
            file = volfile
        if ':' in file:
            file = file[0: file.rfind(':')]
        if not os.path.exists(file):
            raise Exception("File %s does not exists"%file)

        self.volfile = volfile
        self.voxelSize = self.kwargs.get('voxelSize', None)
        # ChimeraServer is the basic server. There are other
        # than inherit from it.
        serverName=self.kwargs.get('ChimeraServer','ChimeraServer')
        self.address = ''
        self.port = getFreePort()

        serverfile = pw.join('em', 'chimera_server.py')
        command = CommandView("chimera --script '%s %s %s' &" %
                              (serverfile, self.port,serverName),
                             env=getChimeraEnviron(),).show()
        self.authkey = 'test'
        self.client = Client((self.address, self.port), authkey=self.authkey)
        self.initVolumeData()
        self.openVolumeOnServer(self.vol,sendEnd)
        self.initListenThread()
Пример #6
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":
            pw.join('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()
        # Check if the wizard changes were accepted or just canceled

        myprops = readProperties(dogpickerProps)

        if myprops['applyChanges'] == 'true':
            form.setVar('diameter', myprops['diameter.value'])
            form.setVar('threshold', myprops['threshold.value'])
Пример #7
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" : pw.join('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,
                                        mode=CoordinatesObjectView.MODE_AUTOMATIC,
                                        pickerProps=dogpickerProps).show()
        process.wait()
        # Check if the wizard changes were accepted or just canceled

        myprops = readProperties(dogpickerProps)

        if myprops['applyChanges'] == 'true':
            form.setVar('diameter', myprops['diameter.value'])
            form.setVar('threshold', myprops['threshold.value'])
Пример #8
0
def createEmanProcess(script='e2converter.py', args=None, direc="."):
    """ Open a new Process with all EMAN environment (python...etc)
    that will server as an adaptor to use EMAN library
    """
    program = pw.join('em', 'packages', 'eman2', script)        
    cmd = getEmanCommand(program, args)
    
#    gcmd = greenStr(cmd)
    print "** Running: '%s'" % cmd
    proc = subprocess.Popen(cmd, shell=True, env=getEnviron(), 
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE, cwd=direc)
    
    return proc
Пример #9
0
def createEmanProcess(script='e2converter.py', args=None, direc="."):
    """ Open a new Process with all EMAN environment (python...etc)
    that will server as an adaptor to use EMAN library
    """
    program = pw.join('em', 'packages', 'eman2', script)        
    cmd = getEmanCommand(program, args)
    
#    gcmd = greenStr(cmd)
    print "** Running: '%s'" % cmd
    proc = subprocess.Popen(cmd, shell=True, env=getEnviron(), 
                            stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE, cwd=direc)
    
    return proc
Пример #10
0
def _launchLocal(protocol, wait, stdin=None, stdout=None, stderr=None):
    # Check first if we need to launch with MPI or not
    command = (
        '%s %s "%s" "%s" %s' %
        (pw.PYTHON, pw.join(pw.APPS, 'pw_protocol_run.py'),
         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
    def a_testEmanConvert(self):
        project = self.loadProject("TestXmippWorkflow")

        particleList = project.mapper.selectByClass('SetOfParticles')
        
        eman2.loadEnvironment()
        
        program = pw.join('em', 'packages', 'eman2', 'e2converter.py')
        
        cmd = eman2.getEmanCommand(program, 'myimage.hdf')
        
        gcmd = greenStr(cmd)
        print "** Running: '%s'" % gcmd
        proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
        
        p = particleList[0]
        for i, img in enumerate(p):
            loc = img.getLocation()
            index = loc.getIndex()
            fn = loc.getFileName()
            print >> proc.stdin, index, fn
        p.wait()
Пример #12
0
    def a_testEmanConvert(self):
        project = self.loadProject("TestXmippWorkflow")

        particleList = project.mapper.selectByClass('SetOfParticles')
        
        eman2.loadEnvironment()
        
        program = pw.join('em', 'packages', 'eman2', 'e2converter.py')
        
        cmd = eman2.getEmanCommand(program, 'myimage.hdf')
        
        gcmd = greenStr(cmd)
        print "** Running: '%s'" % gcmd
        proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE)
        
        p = particleList[0]
        for i, img in enumerate(p):
            loc = img.getLocation()
            index = loc.getIndex()
            fn = loc.getFileName()
            print >> proc.stdin, index, fn
        p.wait()
Пример #13
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)
Пример #14
0
 def openProject(self, projName):
     from subprocess import Popen
     script = pw.join('apps', 'pw_project.py')
     Popen([os.environ['SCIPION_PYTHON'], script, projName])
Пример #15
0
    def show(self, form):
        prot = form.protocol
        micSet = prot.getInputMicrographs()

        gpus = prot.getGpuList()

        if not gpus:
            form.showWarning("You should select at least one GPU.")
            return

        if not micSet:
            form.showWarning("You should select input micrographs "
                             "before opening the wizard.")
            return

        project = prot.getProject()

        if prot.micrographsSelection == 0:  # all micrographs
            micFn = micSet.getFileName()
        else:
            # Create a subset based on defocus values
            ctfs = prot.ctfRelations.get()
            if ctfs is None:
                form.showWarning("You should select CTFs if using a defocus "
                                 "subset. ")
                return
            micSubset = prot._createSetOfMicrographs(suffix='subset')
            for mic in getSubsetByDefocus(ctfs, micSet,
                                          prot.micrographsNumber.get()):
                micSubset.append(mic)
            micSubset.write()
            micSubset.close()
            micFn = micSubset.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)
        refStack = os.path.join(coordsDir, 'references.mrcs')
        prot.convertReferences(refStack)

        # Get current values of the properties
#         micFn = os.path.join(coordsDir, 'micrographs.xmd')
#         writeSetOfMicrographs(micSet, micFn)
        pickerConfig = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerConfig, "w")

        pickScript = pw.join('em', 'packages', 'gautomatch',
                             'run_gautomatch.py')

        # Let use the first selected gpu for the wizard
        pickCmd = prot.getArgs(threshold=False,
                               mindist=False) % {'GPU': gpus[0]}
        convertCmd = pw.join('apps', 'pw_convert.py')

        args = {
            "pickScript": pickScript,
            "pickCmd": pickCmd,
            "convertCmd": convertCmd,
            'coordsDir': coordsDir,
            'micsSqlite': micSet.getFileName(),
            'threshold': prot.threshold.get(),
            "mindist": prot.minDist.get(),
            "refStack": refStack
          }

        # If Gautomatch will guess advanced parameter we don't need to send
        # the min distance to the wizard.
        if prot.advanced:
            f.write("""
            parameters = threshold
            threshold.value =  %(threshold)s
            threshold.label = Threshold
            threshold.help = Particles with CCC above the threshold will be picked
            autopickCommand = %(pickScript)s %%(micrograph) %(refStack)s %(coordsDir)s %(pickCmd)s --cc_cutoff %%(threshold)
            convertCommand = %(convertCmd)s --coordinates --from gautomatch --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
            """ % args)

        else:
            f.write("""
            parameters = threshold,mindist
            threshold.value =  %(threshold)s
            threshold.label = Threshold
            threshold.help = Particles with CCC above the threshold will be picked
            mindist.value = %(mindist)s
            mindist.label = Min search distance
            mindist.help = Use value of 0.9~1.1X diameter
            autopickCommand = %(pickScript)s %%(micrograph) %(refStack)s %(coordsDir)s %(pickCmd)s --cc_cutoff %%(threshold) --min_dist %%(mindist)
            convertCommand = %(convertCmd)s --coordinates --from gautomatch --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('threshold', myprops['threshold.value'])
            if not prot.advanced:
                form.setVar('minDist', myprops['mindist.value'])
            else:
                pass  # TODO: We could even in future parse the 'guessed' params
Пример #16
0
def _getAppsProgram(prog):
    """ Get a command to launch a program under the apps folder.
    """
    return "%s %s" % (pw.PYTHON, pw.join(pw.APPS, prog))
Пример #17
0
 def openProject(self, projName):
     from subprocess import Popen
     script = pw.join('apps', 'pw_project.py')
     Popen([pw.PYTHON, script, projName])
Пример #18
0
def _getAppsProgram(prog):
    """ Get a command to launch a program under the apps folder.
    And also using a different python if configured in SCIPION_PYTHON var.
    """
    return os.environ.get("SCIPION_PYTHON", "python") + " " + pw.join("apps", prog)
Пример #19
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)

        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'])
Пример #20
0
    Usage: python -m pyworkflow.project.scripts.stop project_name
        This script will stop all running protocols of the specified project.
        e.g.
        scipion python scripts/stop.py MyProject
    """ % error)
    sys.exit(1)


n = len(sys.argv)

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

projName = sys.argv[1]

path = pw.join('gui', 'no-tkinter')
sys.path.insert(1, path)

manager = Manager()

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

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

project = Project(path=projectPath)
project.load()
Пример #21
0
def _getAppsProgram(prog):
    """ Get a command to launch a program under the apps folder.
    And also using a different python if configured in SCIPION_PYTHON var.
    """
    return os.environ.get('SCIPION_PYTHON', 'python') + ' ' + pw.join('apps', prog)
Пример #22
0
    def show(self, form):
        prot = form.protocol
        micSet = prot.getInputMicrographs()

        gpus = prot.getGpuList()

        if not gpus:
            form.showWarning("You should select at least one GPU.")
            return

        if not micSet:
            form.showWarning("You should select input micrographs "
                             "before opening the wizard.")
            return

        project = prot.getProject()

        if prot.micrographsSelection == 0:  # all micrographs
            micFn = micSet.getFileName()
        else:
            # Create a subset based on defocus values
            ctfs = prot.ctfRelations.get()
            if ctfs is None:
                form.showWarning("You should select CTFs if using a defocus "
                                 "subset. ")
                return
            micSubset = prot._createSetOfMicrographs(suffix='subset')
            for mic in getSubsetByDefocus(ctfs, micSet,
                                          prot.micrographsNumber.get()):
                micSubset.append(mic)
            micSubset.write()
            micSubset.close()
            micFn = micSubset.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)
        refStack = os.path.join(coordsDir, 'references.mrcs')
        prot.convertReferences(refStack)

        # Get current values of the properties
        #         micFn = os.path.join(coordsDir, 'micrographs.xmd')
        #         writeSetOfMicrographs(micSet, micFn)
        pickerConfig = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerConfig, "w")

        pickScript = pw.join('em', 'packages', 'gautomatch',
                             'run_gautomatch.py')

        # Let use the first selected gpu for the wizard
        pickCmd = prot.getArgs(threshold=False, mindist=False) % {
            'GPU': gpus[0]
        }
        convertCmd = pw.join('apps', 'pw_convert.py')

        args = {
            "pickScript": pickScript,
            "pickCmd": pickCmd,
            "convertCmd": convertCmd,
            'coordsDir': coordsDir,
            'micsSqlite': micSet.getFileName(),
            'threshold': prot.threshold.get(),
            "mindist": prot.minDist.get(),
            "refStack": refStack
        }

        # If Gautomatch will guess advanced parameter we don't need to send
        # the min distance to the wizard.
        if prot.advanced:
            f.write("""
            parameters = threshold
            threshold.value =  %(threshold)s
            threshold.label = Threshold
            threshold.help = Particles with CCC above the threshold will be picked
            autopickCommand = %(pickScript)s %%(micrograph) %(refStack)s %(coordsDir)s %(pickCmd)s --cc_cutoff %%(threshold)
            convertCommand = %(convertCmd)s --coordinates --from gautomatch --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
            """ % args)

        else:
            f.write("""
            parameters = threshold,mindist
            threshold.value =  %(threshold)s
            threshold.label = Threshold
            threshold.help = Particles with CCC above the threshold will be picked
            mindist.value = %(mindist)s
            mindist.label = Min search distance
            mindist.help = Use value of 0.9~1.1X diameter
            autopickCommand = %(pickScript)s %%(micrograph) %(refStack)s %(coordsDir)s %(pickCmd)s --cc_cutoff %%(threshold) --min_dist %%(mindist)
            convertCommand = %(convertCmd)s --coordinates --from gautomatch --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('threshold', myprops['threshold.value'])
            if not prot.advanced:
                form.setVar('minDist', myprops['mindist.value'])
            else:
                pass  # TODO: We could even in future parse the 'guessed' params
Пример #23
0
    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)
        refStack = os.path.join(coordsDir, 'references.mrcs')
        prot.convertReferences(refStack)

        # Get current values of the properties
        #         micfn = os.path.join(coordsDir, 'micrographs.xmd')
        #         writeSetOfMicrographs(micSet, micfn)
        pickerConfig = os.path.join(coordsDir, 'picker.conf')
        f = open(pickerConfig, "w")

        pickScript = pw.join('em', 'packages', 'gautomatch',
                             'run_gautomatch.py')

        pickCmd = prot.getArgs(threshold=False, mindist=False)
        convertCmd = pw.join('apps', 'pw_convert.py')

        args = {
            "pickScript": pickScript,
            "pickCmd": pickCmd,
            "convertCmd": convertCmd,
            'coordsDir': coordsDir,
            'micsSqlite': micSet.getFileName(),
            'threshold': prot.threshold.get(),
            "mindist": prot.minDist.get(),
            "refStack": refStack
        }

        # If Gautomatch will guess advanced parameter we don't need to send
        # the min distance to the wizard.
        if prot.advanced:
            f.write("""
            parameters = threshold
            threshold.value =  %(threshold)s
            threshold.label = Threshold
            threshold.help = Particles with CCC above the threshold will be picked
            autopickCommand = %(pickScript)s %%(micrograph) %(refStack)s %(coordsDir)s %(pickCmd)s --cc_cutoff %%(threshold)
            convertCommand = %(convertCmd)s --coordinates --from gautomatch --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
            """ % args)

        else:
            f.write("""
            parameters = threshold,mindist
            threshold.value =  %(threshold)s
            threshold.label = Threshold
            threshold.help = Particles with CCC above the threshold will be picked
            mindist.value = %(mindist)s
            mindist.label = Min search distance
            mindist.help = Use value of 0.9~1.1X diameter
            autopickCommand = %(pickScript)s %%(micrograph) %(refStack)s %(coordsDir)s %(pickCmd)s --cc_cutoff %%(threshold) --min_dist %%(mindist)
            convertCommand = %(convertCmd)s --coordinates --from gautomatch --to xmipp --input  %(micsSqlite)s --output %(coordsDir)s
            """ % args)

        f.close()

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

        if myprops['applyChanges'] == 'true':
            form.setVar('threshold', myprops['threshold.value'])
            if not prot.advanced:
                form.setVar('minDist', myprops['mindist.value'])
            else:
                pass  # TODO: We could even in future parse the 'guessed' params
Пример #24
0
    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,
                                        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'])
Пример #25
0
 def test_Process(self):
     prog = pw.join('apps', 'pw_sleep.py')
     p = Popen('xmipp_python %s 500' % prog, shell=True)
     print "pid: ", p.pid
     time.sleep(5)
     killWithChilds(p.pid)
Пример #26
0
 def openProject(self, projName):
     from subprocess import Popen
     script = pw.join('apps', 'pw_project.py')
     Popen([os.environ['SCIPION_PYTHON'], script, projName])
Пример #27
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'])