コード例 #1
0
ファイル: dataimport.py プロジェクト: EyeSeeTea/scipion-web
    def importCoordinates(self, fileName, addCoordinate):
        if exists(fileName):
            ext = getExt(fileName)
            
            if ext == ".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 particleSize")
                size = md.getValue(MDL_PICKING_PARTICLE_SIZE, md.firstObject())
                if size is None:
                    print ">>> WARNING: Error parsing coordinate file: %s" % fileName
                    print "             Skipping this file."
                else:
                    half = size / 2
                    for objId in md:
                        x = md.getValue(MDL_XCOOR, objId)
                        y = md.getValue(MDL_YCOOR, objId)
                        coord = Coordinate()
                        coord.setPosition(x+half, y+half)
                        addCoordinate(coord)
            else:
                raise Exception('Unknown extension "%s" to import Eman coordinates' % ext)
コード例 #2
0
ファイル: dataimport.py プロジェクト: josegutab/scipion
    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"
コード例 #3
0
    def getBoxSize(self, coordFile):
        """ Try to infer the box size from the given coordinate file.
        In the case of .box files, the size is the 3rd column
        In the case of .json files, we will look for file
        e2boxercache/base.json
        """
        if coordFile.endswith('.box'):
            md = MetaData()
            md.readPlain(coordFile, "xcoor ycoor particleSize")
            return md.getValue(MDL_PICKING_PARTICLE_SIZE, md.firstObject())

        elif coordFile.endswith('.json'):
            infoDir = pwutils.dirname(coordFile)
            # Still go one level up of info dir
            jsonBase = pwutils.join(pwutils.dirname(infoDir), 'e2boxercache',
                                    'base.json')
            jsonBase2 = pwutils.join(infoDir, 'project.json')
            if pwutils.exists(jsonBase):
                jsonDict = loadJson(jsonBase)
                if jsonDict.has_key('box_size'):
                    return int(jsonDict["box_size"])
            elif pwutils.exists(jsonBase2):
                jsonDict = loadJson(jsonBase2)
                if jsonDict.has_key('global.boxsize'):
                    return int(jsonDict["global.boxsize"])

        return None
コード例 #4
0
def readCoordinates(mic, fileName, coordsSet):
    if exists(fileName):
        md = MetaData()
        md.readPlain(fileName, 'xcoor ycoor')
        for objId in md:
            x = md.getValue(MDL_XCOOR, objId)
            y = md.getValue(MDL_YCOOR, objId)
            coord = Coordinate()
            coord.setPosition(x, y)
            coord.setMicrograph(mic)
            coordsSet.append(coord)
コード例 #5
0
ファイル: convert.py プロジェクト: coocoky/scipion
def readCoordinates(mic, fileName, coordsSet):
    if exists(fileName):
         md = MetaData()
         md.readPlain(fileName, 'xcoor ycoor')
         for objId in md:
            x = md.getValue(MDL_XCOOR, objId)
            y = md.getValue(MDL_YCOOR, objId)
            coord = Coordinate()
            coord.setPosition(x, y)
            coord.setMicrograph(mic)
            coordsSet.append(coord)
コード例 #6
0
ファイル: dataimport.py プロジェクト: I2PC/scipion
 def importCoordinates(self, fileName, addCoordinate):
     print "In importCoordinates Appion with filename=%s" % fileName
     if exists(fileName):
         md = MetaData()
         md.readPlain(fileName, 'xcoor ycoor')
         for objId in md:
             x = md.getValue(MDL_XCOOR, objId)
             y = md.getValue(MDL_YCOOR, objId)
             coord = Coordinate()
             coord.setPosition(x, y)
             addCoordinate(coord)
コード例 #7
0
 def importCoordinates(self, fileName, addCoordinate):
     print "In importCoordinates Appion with filename=%s" % fileName
     if exists(fileName):
         md = MetaData()
         md.readPlain(fileName, 'xcoor ycoor')
         for objId in md:
             x = md.getValue(MDL_XCOOR, objId)
             y = md.getValue(MDL_YCOOR, objId)
             coord = Coordinate()
             coord.setPosition(x, y)
             addCoordinate(coord)
コード例 #8
0
ファイル: dataimport.py プロジェクト: azazellochg/scipion
 def getBoxSize(self, coordFile):
     """ Try to infer the box size from the given coordinate file.
     In the case of .box files, the size is the 3rd column
     In the case of .json files, we will look for file e2boxercache/base.json
     """
     if coordFile.endswith('.box'):
         md = MetaData()
         md.readPlain(coordFile, "xcoor ycoor particleSize")
         return md.getValue(MDL_PICKING_PARTICLE_SIZE, md.firstObject())
     
     elif coordFile.endswith('.json'):
         infoDir = dirname(coordFile)
         # Still go one level up of info dir
         jsonBase = join(dirname(infoDir), 'e2boxercache', 'base.json')
         if exists(jsonBase):
             jsonDict = loadJson(jsonBase)
             if jsonDict.has_key('box_size'):
                 return int(jsonDict["box_size"])
             
     return None