Exemplo n.º 1
0
    def getDefaultBoxSize(self):
        """ This function is used by the wizard to estimate the box size. """
        boxSize = None
        ci = self.getImportClass()
        if hasattr(ci, 'getBoxSize'):
            boxSize = ci.getBoxSize([f for f, _ in self.iterFiles()][0])
            if boxSize is not None and self.scale != 1.:
                boxSize = int(boxSize * self.scale.get())
        
        return boxSize
    
        boxSize = 100
        importFrom = self.getImportFrom()
        scale = self.scale.get()

        if importFrom == ProtImportCoordinates.IMPORT_FROM_XMIPP:
            configfile = join(self.filesPath.get(), 'config.xmd')
            existsConfig = exists(configfile)
            if existsConfig:
                md = xmipp.MetaData('properties@' + configfile)
                configobj = md.firstObject()
                boxSize = md.getValue(xmipp.MDL_PICKING_PARTICLE_SIZE, configobj)
        if importFrom == ProtImportCoordinates.IMPORT_FROM_EMAN:
            # Read the boxSize from the e2boxercache/base.json
            jsonFnbase = join(self.filesPath.get(), 'e2boxercache', 'base.json')
            from pyworkflow.em.packages.eman2 import loadJson
            jsonBoxDict = loadJson(jsonFnbase)
            boxSize = int(jsonBoxDict["box_size"])
        boxSize = (int)(boxSize * scale)
        return boxSize
Exemplo n.º 2
0
    def getDefaultBoxSize(self):
        """ This function is used by the wizard to estimate the box size. """
        boxSize = None
        ci = self.getImportClass()
        if hasattr(ci, 'getBoxSize'):
            boxSize = ci.getBoxSize([f for f, _ in self.iterFiles()][0])
            if boxSize is not None and self.scale != 1.:
                boxSize = int(boxSize * self.scale.get())

        return boxSize

        boxSize = 100
        importFrom = self.getImportFrom()
        scale = self.scale.get()

        if importFrom == ProtImportCoordinates.IMPORT_FROM_XMIPP:
            configfile = join(self.filesPath.get(), 'config.xmd')
            existsConfig = exists(configfile)
            if existsConfig:
                md = xmipp.MetaData('properties@' + configfile)
                configobj = md.firstObject()
                boxSize = md.getValue(xmipp.MDL_PICKING_PARTICLE_SIZE,
                                      configobj)
        if importFrom == ProtImportCoordinates.IMPORT_FROM_EMAN:
            # Read the boxSize from the e2boxercache/base.json
            jsonFnbase = join(self.filesPath.get(), 'e2boxercache',
                              'base.json')
            from pyworkflow.em.packages.eman2 import loadJson
            jsonBoxDict = loadJson(jsonFnbase)
            boxSize = int(jsonBoxDict["box_size"])
        boxSize = (int)(boxSize * scale)
        return boxSize
Exemplo n.º 3
0
    def importCoordinates(self, fileName, addCoordinate):

        if exists(fileName):
            ext = getExt(fileName)
            if ext == ".json":
                print "importando un json"
                jsonPosDict = loadJson(fileName)

                if jsonPosDict.has_key("boxes"):
                    boxes = jsonPosDict["boxes"]

                    for box in boxes:
                        x, y = box[:2]
                        coord = Coordinate()
                        coord.setPosition(x, y)
                        addCoordinate(coord)
            elif ext == ".box":
                md = MetaData()
                md.readPlain(fileName, 'xcoor ycoor xSize ySize')
                for objId in md:
                    x = md.getValue(MDL_XCOOR, objId)
                    y = md.getValue(MDL_YCOOR, objId)
                    coord = Coordinate()
                    coord.setPosition(x, y)
                    addCoordinate(coord)
            else:
                print "importando un queseyo"
Exemplo n.º 4
0
def readCoordinates(mic, fileName, coordsSet):
     if exists(fileName):
            jsonPosDict = loadJson(fileName)

            if jsonPosDict.has_key("boxes"):
                boxes = jsonPosDict["boxes"]

                for box in boxes:
                    x, y = box[:2]
                    coord = Coordinate()
                    coord.setPosition(x, y)
                    coord.setMicrograph(mic)
                    coordsSet.append(coord)
Exemplo n.º 5
0
def readSetOfCoordinates(workDir, micSet, coordSet):
    """ Read from Eman .json files.
    It is expected a file named: base.json under the workDir.
    Params:
        workDir: where the Eman boxer output files are located.
        micSet: the SetOfMicrographs to associate the .json, which 
            name should be the same of the micrographs.
        coordSet: the SetOfCoordinates that will be populated.
    """
    # Read the boxSize from the e2boxercache/base.json
    jsonFnbase = join(workDir, 'e2boxercache', 'base.json')
    jsonBoxDict = loadJson(jsonFnbase)
    size = int(jsonBoxDict["box_size"])
    jsonFninfo = join(workDir, 'info/')
    
    for mic in micSet:
        micPosFn = ''.join(glob.glob(jsonFninfo + '*' + removeBaseExt(mic.getFileName()) + '_info.json'))
        readCoordinates(mic, micPosFn, coordSet)
    coordSet.setBoxSize(size)
Exemplo n.º 6
0
    def getDefaultBoxSize(self):
        import xmipp
        boxSize = 100
        importFrom = self.getImportFrom()
        scale = self.scale.get()

        if importFrom == ProtImportCoordinates.IMPORT_FROM_XMIPP:
            configfile = join(self.filesPath.get(), 'config.xmd')
            existsConfig = exists(configfile)
            if existsConfig:
                md = xmipp.MetaData('properties@' + configfile)
                configobj = md.firstObject()
                boxSize = md.getValue(xmipp.MDL_PICKING_PARTICLE_SIZE, configobj)
        if importFrom == ProtImportCoordinates.IMPORT_FROM_EMAN:
            # Read the boxSize from the e2boxercache/base.json
            jsonFnbase = join(self.filesPath.get(), 'e2boxercache', 'base.json')
            from pyworkflow.em.packages.eman2 import loadJson
            jsonBoxDict = loadJson(jsonFnbase)
            boxSize = int(jsonBoxDict["box_size"])
        boxSize = (int)(boxSize * scale)
        return boxSize