Ejemplo n.º 1
0
    def verifyNumberOfCompletedRefinements(self,
                                           multiModelRefinementRun=False):
        """ 
                queries te database to determine how many iterations of individual refinements have been completed:
                returns a list of completed iterations in a dictionary of completed refinements
                """

        refine_complete = {}
        if multiModelRefinementRun is False:
            iterdata = appiondata.ApRefineIterData()
            iterdata['refineRun'] = self.refinerunq
            itercompletedata = iterdata.query()
            iter_complete = []
            for iter in itercompletedata:
                iter_complete.append(iter['iteration'])
            iter_complete.sort()
            refine_complete[
                self.refinerunq['reference_number']] = iter_complete
        else:
            refinedata = appiondata.ApRefineRunData()
            refinedata['multiModelRefineRun'] = self.multimodelq
            refinecompletedata = refinedata.query()
            for i, refine in enumerate(refinecompletedata):
                iterdata = appiondata.ApRefineIterData()
                iterdata['refineRun'] = refine
                itercompletedata = iterdata.query()
                iter_complete = []
                for iter in itercompletedata:
                    iter_complete.append(iter['iteration'])
                iter_complete.sort()
                refine_complete[refine['reference_number']] = iter_complete
        return refine_complete
def getReconRunIdFromNamePath(runname, path):
    reconrunq = appiondata.ApRefineRunData()
    reconrunq['runname'] = runname
    reconrunq['path'] = appiondata.ApPathData(path=os.path.abspath(path))
    reconrundatas = reconrunq.query(results=1)
    if not reconrundatas:
        return None
    return reconrundatas[0].dbid
Ejemplo n.º 3
0
    def insertRefinementRunData(self, iteration, reference_number=1):
        ''' fills in database entry object for ApRefineRunData table '''

        ### fill in ApMultiModelRefineRunData object, if valid
        if self.multiModelRefinementRun is True:
            multimodelq = appiondata.ApMultiModelRefineRunData()
            multimodelq['runname'] = self.params['runname']
            multimodelq[
                'REF|projectdata|projects|project'] = apProject.getProjectIdFromStackId(
                    self.runparams['stackid'])
            multimodelq['session'] = apStack.getSessionDataFromStackId(
                self.runparams['stackid'])
            multimodelq['num_refinements'] = self.runparams[
                'NumberOfReferences']
            self.multimodelq = multimodelq

        ### fill in ApRefineRunData object
        runq = appiondata.ApRefineRunData()
        runq['runname'] = self.params['runname']
        runq['stack'] = self.stackdata
        runq['reference_number'] = reference_number
        earlyresult = runq.query(results=1)  # check unique run
        if earlyresult:
            apDisplay.printWarning(
                "Run already exists in the database.\nIdentical data will not be reinserted"
            )
        paramdescription = self.params['description']
        if not paramdescription:
            paramdescription = None
        runq['job'] = self.params['jobinfo']
        if len(self.modeldata) > 1:
            runq['initialModel'] = self.modeldata[reference_number - 1]
        else:
            runq['initialModel'] = self.modeldata[0]
        runq['package'] = self.package
        runq['path'] = appiondata.ApPathData(
            path=os.path.abspath(self.resultspath))
        runq['description'] = paramdescription
        runq['num_iter'] = self.runparams['numiter']
        if self.multiModelRefinementRun is True:
            runq['multiModelRefineRun'] = self.multimodelq

        result = runq.query(results=1)

        # save run entry in the parameters
        if result:
            self.refinerunq = result[0]
        elif self.params['commit'] is True:
            apDisplay.printMsg(
                "Refinement Run was not found, setting to inserted values")
            self.refinerunq = runq
        else:
            apDisplay.printWarning(
                "Refinement Run was not found, setting to 'None'")
            self.refinerunq = None

        return
def getReconRunsIds():
    reconrunids = []
    reconrunq = appiondata.ApRefineRunData()
    reconrundatas = reconrunq.query()
    if not reconrundatas:
        return reconrunids
    for reconrundata in reconrundatas:
        reconrunids.append(reconrundata.dbid)
    return reconrunids
Ejemplo n.º 5
0
	def getRunData(self):
		### setup refinement run
		jobdata = apDatabase.getJobDataFromPathAndType(self.params['rundir'], "runfrealign")
		runq = appiondata.ApRefineRunData()
		runq['runname'] = self.params['runname']
		runq['package'] = "Frealign"
		runq['description'] = self.params['description']
		runq['hidden'] = False
		runq['num_iter'] = self.numiter
		runq['stack'] = apStack.getOnlyStackData(self.params['stackid'])
		runq['initialModel'] = apModel.getModelFromId(self.params['modelid'])
		runq['path'] = appiondata.ApPathData(path=os.path.abspath(self.params['rundir']))
		runq['job'] = jobdata
		return runq
Ejemplo n.º 6
0
    def insertRefinementRun(self):
        runq = appiondata.ApRefineRunData()
        #first two must be unique
        runq['runname'] = self.params['runname']
        runq['stack'] = self.params['stack']

        #Recon upload can be continued
        earlyresult = runq.query(results=1)
        if earlyresult:
            apDisplay.printWarning(
                "Run already exists in the database.\nIdentical data will not be reinserted"
            )
        # empty <> than None for Sinedon query
        paramdescription = self.params['description']
        if not paramdescription:
            paramdescription = None

        runq['job'] = self.params['jobinfo']
        runq['initialModel'] = self.params['model']
        runq['package'] = self.params['package']
        runq['path'] = appiondata.ApPathData(
            path=os.path.abspath(self.params['rundir']))
        runq['description'] = paramdescription
        runq['initialModel'] = self.params['model']
        runq['num_iter'] = len(self.iterationdatas)

        result = runq.query(results=1)

        if earlyresult and not result:
            if self.params['commit'] is True:
                apDisplay.printError("Refinement Run parameters have changed")
            else:
                apDisplay.printWarning(
                    "Refinement Run parameters have changed")

        # get stack apix
        self.params['apix'] = apStack.getStackPixelSizeFromStackId(
            self.params['stack'].dbid)

        apDisplay.printMsg("inserting Refinement Run into database")
        if self.params['commit'] is True:
            runq.insert()
        else:
            apDisplay.printWarning("not committing results to database")

        #if we insert runq then this returns no results !!!
        # this is a workaround (annoying & bad)
        runq = appiondata.ApRefineRunData()
        runq['runname'] = self.params['runname']
        runq['stack'] = self.params['stack']
        runq['job'] = self.params['jobinfo']
        runq['initialModel'] = self.params['model']
        runq['package'] = self.params['package']
        runq['path'] = appiondata.ApPathData(
            path=os.path.abspath(self.params['rundir']))
        runq['description'] = paramdescription
        runq['package'] = self.params['package']
        runq['initialModel'] = self.params['model']

        result = runq.query(results=1)

        # save run entry in the parameters
        if result:
            self.params['refineRun'] = result[0]
        elif self.params['commit'] is True:
            apDisplay.printWarning(
                "Refinement Run was not found, setting to inserted values")
            self.params['refineRun'] = runq
        else:
            apDisplay.printWarning(
                "Refinement Run was not found, setting to 'None'")
            self.params['refineRun'] = None
        return True