示例#1
0
	def createParamsFromGoodAligner(self,alignerid):
		q = appiondata.ApTomoAlignerParamsData()
		alignerdata = q.direct_query(alignerid)
		self.params['goodcycle'] = alignerdata['refine_cycle']['cycle']
		alignrundata = alignerdata['alignrun']
		if self.params['runname'] is None:
			self.params['runname'] = alignrundata['name']
		else:
			if self.params['runname'] != alignrundata['name']:
				apDisplay.printError("Alignment run name can not be changed between cycles")
		if self.params['description'] is None:
				self.params['description'] = alignrundata['description']
		q = appiondata.ApTiltsInAlignRunData(alignrun=alignrundata)
		results = q.query()
		if results:
			if len(results) == 1:
				tiltdata = results[0]['tiltseries']
				self.params['tiltseries'] = tiltdata
				self.params['tiltseriesnumber'] = tiltdata['number']
				self.params['othertiltseries'] = None
			else:
				runpathdata = alignrundata['path']
				for tiltdata in results:
					pathdata = tiltdata['path']
					if pathdata.dbid == runpathdata.dbid:
						self.params['tiltseries'] = tiltdata
						self.params['tiltseriesnumber'] = tiltdata['number']
					else:
						self.params['othertiltseries'] = tiltdata
						self.params['othertilt'] = tiltdata['number']
def insertTiltsInAlignRun(alignrundata, tiltdata, settingsdata, primary=True):
    q = appiondata.ApTiltsInAlignRunData()
    q['alignrun'] = alignrundata
    q['tiltseries'] = tiltdata
    q['settings'] = settingsdata
    q['primary_tiltseries'] = primary
    return publish(q)
def getTiltListFromAligner(alignerid):
    alignerdata = getAlignerdata(alignerid)
    q = appiondata.ApTiltsInAlignRunData(alignrun=alignerdata['alignrun'])
    results = q.query()
    for i, result in enumerate(results):
        if result['primary_tiltseries']:
            primkey = i
            break
    tiltdatalist = [
        results[primkey]['tiltseries'],
    ]
    del results[primkey]
    for r in results:
        tiltdatalist.append(r['tiltseries'])
    return tiltdatalist
def getAlignersFromTiltSeries(tiltseriesdata, alignrunname=''):
    q = appiondata.ApTiltsInAlignRunData(tiltseries=tiltseriesdata)
    if alignrunname:
        runq = appiondata.ApTomoAlignmentRunData(name=alignrunname)
        q['alignrun'] = runq
    results = q.query()
    if results:
        allaligners = []
        allalignerids = []
        for tilt_in_run in results:
            alignerq = appiondata.ApTomoAlignerParamsData(
                alignrun=tilt_in_run['alignrun'])
            aligners = alignerq.query()
            for aligner in aligners:
                if aligner.dbid not in allalignerids:
                    allaligners.append(aligner)
                    allalignerids.append(aligner.dbid)
        return allaligners
    return []
def commitToJensenDatabase(session_time, fulltomodata, stackdir, processdir,
                           stackname, description):
    if not upload_to_Jensen_database:
        return

    raptordatabase = 0
    apDisplay.printMsg("Uploding to Jensen tomography database")

    alignrun = fulltomodata['alignrun']
    tiltseries = fulltomodata['tiltseries']

    nn = len(stackname)
    mrcbase = processdir + '/align/' + stackname[0:-3]
    mrcpath = mrcbase + '_full.rec'
    if not os.path.exists(mrcpath):
        mrcpath = mrcbase + '_part.rec'
        if not os.path.exists(mrcpath):
            mrcpath = ''
    if mrcpath == '':
        apDisplay.printWarning('No output full or part mrc found.')
        raptordatabase = 1
    else:
        print '!!!0', ' mrcpath=', mrcpath
        print '!!!1', ' stackdir=', stackdir, ' stackname=', stackname, ' processdir=', processdir, ' description=', description
        imagelist = apTomo.getImageList([tiltseries])
        defocus = imagelist[0]['preset']['defocus']
        magnification = imagelist[0]['preset']['magnification']
        q = appiondata.ApTiltsInAlignRunData(alignrun=alignrun)
        r = q.query()
        tomosettings = r[0]['settings']
        tilt_min = tomosettings['tilt min']
        tilt_max = tomosettings['tilt max']
        tilt_step = tomosettings['tilt step']
        dose = tomosettings['dose']
        print '!!!2', ' defocus=', defocus, ' magnification=', magnification, ' tilt_min=', tilt_min, ' tilt_max=', tilt_max, ' tilt_step=', tilt_step, ' dose=', dose
        #sessiondata = tiltdatalist[0]['session']
        session_id = tiltseries.dbid
        print '!!!3', ' session_id=', session_id, ' session_time=', session_time

    return raptordatabase
def insertTiltsInAlign(alignrun):
    q = appiondata.ApTiltsInAlignRunData()
    q['alignrun'] = alignrun
    q['tiltseries'] = alignrun['tiltseries']
    q['primary_tiltseries'] = True
    q.insert()