Esempio n. 1
0
    def runObjectCommand(self, cmd, inputStrId, objStrId):
        try:
            objId = int(objStrId)
            project = self.project

            if os.path.isfile(inputStrId) and os.path.exists(inputStrId):
                from pwem.utils import loadSetFromDb
                inputObj = loadSetFromDb(inputStrId)
            else:
                inputId = int(inputStrId)
                inputObj = project.mapper.selectById(inputId)

            func = self._OBJECT_COMMANDS.get(cmd, None)

            if func is None:
                print("Error, command '%s' not found. " % cmd)
            else:

                def myfunc():
                    func(inputObj, objId)
                    inputObj.close()

                self.enqueue(myfunc)

        except Exception as ex:
            print("There was an error executing object command !!!:")
            print(ex)
Esempio n. 2
0
    def createSetObject(self):
        _dbName, self._dbPrefix = self.sqliteFile.get().split(',')
        self._dbName = self._getPath('subset.sqlite')
        os.rename(_dbName, self._dbName)

        if self._dbPrefix.endswith('_'):
            self._dbPrefix = self._dbPrefix[:-1]

        from pwem.utils import loadSetFromDb

        # Ignoring self._dbPrefix here, since we want to load
        # the top-level set in the sqlite file
        setObj = loadSetFromDb(self._dbName)
        return setObj
Esempio n. 3
0
    def createSetObject(self):
        """ Moves the sqlite with the enable/disable status to its own
        path to keep it and names it subset.sqlite"""
        _dbName, self._dbPrefix = self.sqliteFile.get().split(',')
        self._dbName = self._getPath('subset.sqlite')
        os.rename(_dbName, self._dbName)

        if self._dbPrefix.endswith('_'):
            self._dbPrefix = self._dbPrefix[:-1]

        from pwem.utils import loadSetFromDb

        # Ignoring self._dbPrefix here, since we want to load
        # the top-level set in the sqlite file
        setObj = loadSetFromDb(self._dbName)
        return setObj
Esempio n. 4
0
def main():

    parser = argparse.ArgumentParser(prog=CONVERT_ENTRY_POINT,
                                     usage="pwem command to convert metadata "
                                     "coordinates from several em formats "
                                     "(eman, relion, gautomatch "
                                     "and bsoft) to xmipp metadata")
    parser.add_argument('--coordinates',
                        help='Convert coordinates',
                        action="store_true")
    parser.add_argument('--fromType', help='Convert from input type')
    parser.add_argument('--toType', help='Convert to output type')
    parser.add_argument('--input', help='Input file or folder', required=True)
    parser.add_argument('--output', help='Output file or folder')
    parser.add_argument('--extra', help='To add extra parameters')

    args = parser.parse_args()
    fromType = args.fromType
    toType = args.toType
    input = args.input
    output = args.output

    if args.coordinates:
        micSet = loadSetFromDb(input)
        outputDir = output
        coordsfn = os.path.join(outputDir, 'coordinates.sqlite')
        cleanPath(coordsfn)
        coordSet = SetOfCoordinates(filename=coordsfn)
        coordSet.setMicrographs(micSet)

        if fromType == 'eman2':
            if toType == 'xmipp':
                readSetOfCoordinates = pwutils.Config.getDomain(
                ).importFromPlugin('eman2.convert',
                                   'readSetOfCoordinates',
                                   doRaise=True)
        elif fromType == 'dogpicker':
            if toType == 'xmipp':
                readSetOfCoordinates = pwutils.Config.getDomain(
                ).importFromPlugin('appion.convert',
                                   'readSetOfCoordinates',
                                   doRaise=True)
        elif fromType == 'relion':
            if toType == 'xmipp':

                def readSetOfCoordinates(outputDir, micSet, coordSet):
                    readSetOfCoordinates = pwutils.Config.getDomain(
                    ).importFromPlugin('relion.convert',
                                       'readSetOfCoordinates',
                                       doRaise=True)
                    inputCoords = args.extra
                    starFiles = [
                        os.path.join(inputCoords,
                                     "mic_%06d_autopick.star" % mic.getObjId())
                        for mic in micSet
                    ]
                    readSetOfCoordinates(coordSet, starFiles)
        elif fromType == 'gautomatch':
            if toType == 'xmipp':
                readSetOfCoordinates = pwutils.Config.getDomain(
                ).importFromPlugin('gautomatch.convert',
                                   'readSetOfCoordinates',
                                   doRaise=True)
        else:
            raise Exception('Unknown coordinates type: %s' % fromType)

        readSetOfCoordinates(outputDir, micSet, coordSet)
        writeSetOfCoordinatesWithState = pwutils.Config.getDomain(
        ).importFromPlugin('xmipp3.convert',
                           'writeSetOfCoordinatesWithState',
                           doRaise=True)
        writeSetOfCoordinatesWithState(outputDir, coordSet, state='Automatic')