Ejemplo n.º 1
0
 def visualizeReferences(self):
     refs = self.getFilename('iter_refs', iter=lastIteration(self))
     if xmippExists(refs):
         try:
             runShowJ(refs, extraParams="--mode metadata --render first")
         except Exception, e:
             showError("Error launching java app", str(e), self.master)
Ejemplo n.º 2
0
    def launchProjSubPlots(self, selectedPlots):
        ''' Launch some plots for a Projection Matching protocol run '''
        import numpy as np
        _log = self.Log

        xplotter=None
        self._plot_count = 0
        
        def doPlot(plotName):
            return plotName in selectedPlots
        
        file_name_tmp = join(self.CtfGroupDirectoryName, self.CtfGroupRootName) +'Info.xmd'
        file_name = join(self.PrevRun.WorkingDir, file_name_tmp)
                         
        if exists(file_name):
            auxMD = MetaData("numberGroups@"+file_name)
            self.NumberOfCtfGroups = auxMD.getValue(MDL_COUNT,auxMD.firstObject())
        else:
            self.NumberOfCtfGroups = 1
            
        
        if doPlot('DisplayReference'):
            for indexCtf in range(1, self.NumberOfCtfGroups+1): 
                file_name = self.getFilename('SubtractedStack', ctf=indexCtf)+'ref'
                    
                if exists(file_name):
                    try:
                        runShowJ(file_name)
                    except Exception, e:
                        showError("Error launching java app", str(e), self.master)
Ejemplo n.º 3
0
 def display2D(self,fn, extraParams=''):
     if xmippExists(fn):
         try:
             # We use os.system to load the relion labels through showj
             os.system('xmipp_showj %(fn)s %(extraParams)s --dont_wrap &' % locals())
             #runShowJ(fn, extraParams=extraParams + ' --dont_wrap')
         except Exception, e:
             showError("Error launching java app", str(e), self.master)
Ejemplo n.º 4
0
 def getFilename():
     if len(fileList) == 0:
         showError("Input error", "File list is empty", parent=gui.master)
         return None
     fn = FileName(fileList[0])  
     if not xmippExists(fn):
         showError("Input error", "Filename <%s> doesn't exists" % str(fn),parent=gui.master)
         return None
     return fn
 def _checkIterData(self):
     """ check that for last visualized iteration, the data is produced. """
     dataStar = self.getFilename('data', iter=self._visualizeLastIteration)
     if not xmippExists(dataStar):
         message = "No data available for <iteration %d>, file <%s> not found." % (self._visualizeLastIteration, dataStar)
         showError("File not Found", message, self.master)
         return False
     return True
         
          
Ejemplo n.º 6
0
 def display3D(self, filename):
     if xmippExists(filename):
         #Chimera
         if self._visualizeVolumesMode == 'chimera':
             runChimeraClient(filename)
         else:
             try:
                 runShowJ(filename, extraParams=' --dont_wrap ')
             except Exception, e:
                 showError("Error launching xmipp_showj: ", str(e), self.master)
Ejemplo n.º 7
0
def wizardHelperSetRadii(gui, inputVarName, outerVarName, innerVarName=None, unit='pixel', sampling=1.):
    fileList = gui.getVarValue(inputVarName).split()
    showInner = innerVarName is not None
    innerRadius = 0
    try:
        if showInner:
            innerRadius = int(gui.getVarValue(innerVarName))
        outerRadius = int(gui.getVarValue(outerVarName))
    except Exception, e:
        showError("Conversion error", "Error trying to parse integer value from \ninnerRadius: <%(innerVarName)s> or\n outerRadius: <%(outerVarName)s>" % locals() 
                  ,parent=gui.master)
        return
Ejemplo n.º 8
0
 def _checkIterData(self):
     """ check that for last visualized iteration, the data is produced. """
     volumes = []
     for prefix in self._getPrefixes():
         volumes.append(self.getFilename(prefix + 'volume', 
                                         iter=self._visualizeLastIteration, 
                                         ref3d=self._visualizeLastRef3D))
             
     for v in volumes:
         if not xmippExists(v):
             message = "No data available for <iteration %d> and <class %d>" % (self._visualizeLastIteration, self._visualizeLastRef3D)
             message += '\nVolume <%s> not found. ' % v
             showError("File not Found", message, self.master)
             return False
     return True
Ejemplo n.º 9
0
def runExternalAppWithResponse(cmd):
    #Create a simple socket server to wait for response
    HOST = ''                 # Symbolic name meaning the local host
    PORT = 14321
    if cmd[-1]=="&":
        cmd=cmd.replace("&"," -port %d &" % PORT)
    else:
        cmd += " -port %d" % PORT
    #Launch the plugin that will send the data response over a socket
    print cmd
    os.system(cmd)
    #os.system('java SocketsTest 54321 &')
    #Create the socket server
    msg = ''
    try:
        import  socket
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        s.settimeout(5.0)
        s.bind((HOST, PORT))
        s.listen(1)
        conn = s.accept()[0]
        #Read the awake message
        data = conn.recv(256)
        if not data or data.strip() != '__STARTED__':
            raise Exception('Invalid START message received')
        else:
            conn.close() 
            s.settimeout(None) # reset timeout
            conn = s.accept()[0]
        #Read len of message (max 4 bytes)
        while True:
            data = conn.recv(1024)
            msg += data
            if not data or msg.find('__END__') !=-1: break      
        conn.close()
    except Exception, e:
        from protlib_gui_ext import showError
        showError("Error waiting for response", "No reponse, returning empty string. ERROR: " + str(e))
Ejemplo n.º 10
0
def wizardNotFound(gui, var):
    showError("Wizard not found", "The wizard <%s> for this parameter has not been found" % var.tags['wizard']
                           , parent=gui.master)
Ejemplo n.º 11
0
                    
                if exists(file_name):
                    try:
                        runShowJ(file_name)
                    except Exception, e:
                        showError("Error launching java app", str(e), self.master)

        if doPlot('DisplaySubtracted'):
            for indexCtf in range(1, self.NumberOfCtfGroups+1): 
                file_name = self.getFilename('SubtractedStack', ctf=indexCtf)
                print "DisplaySubtracted file_name: ", file_name
                if exists(file_name):
                    try:
                        runShowJ(file_name)
                    except Exception, e:
                        showError("Error launching java app", str(e), self.master)

        if xplotter:
            xplotter.show()


    def createFilenameTemplates(self):  
        
        extraParams = {'ReferenceVolumeName': 'reference_volume.vol',
        'ProjSubDir': "ProjSub",
         'LocalCurrentAngles': 'sub_current_angles.doc',
         'LocalCurrentAnglesCtfGroups': 'sub_current_angles_ctfgroups.doc',
        'CtfGroupDirectory': "CtfGroups",
        'CtfGroupRootName': "ctf",
        'CtfGroupRecRootName':'rec_ctfg',
        'VolsDir': 'Vols',
Ejemplo n.º 12
0
#            
#        if xplotter:
#            xplotter.show()
                
    def display3D(self, filename):
        if xmippExists(filename):
            #Chimera
            if self._visualizeVolumesMode == 'chimera':
                runChimeraClient(filename)
            else:
                try:
                    runShowJ(filename, extraParams=' --dont_wrap ')
                except Exception, e:
                    showError("Error launching xmipp_showj: ", str(e), self.master)
        else:
            showError("Can not visualize volume file <%s>\nit does not exists." % filename, self.master)

    def display2D(self,fn, extraParams=''):
        if xmippExists(fn):
            try:
                # We use os.system to load the relion labels through showj
                os.system('xmipp_showj %(fn)s %(extraParams)s --dont_wrap &' % locals())
                #runShowJ(fn, extraParams=extraParams + ' --dont_wrap')
            except Exception, e:
                showError("Error launching java app", str(e), self.master)
        else:
            showError("Can not visualize file <%s>\nit does not exists." % fn, self.master)

    def imagesAssignedToClass2(self,firstIter, lastIteration):
            inputMetadatas = []
            for it in range (firstIter,lastIteration+1): #always list all iterations