def interpretRequestParameters(parameters): """ interpretRequestParameters """ from pytom.basic.structures import ParticleList, SampleInformation, Reference, Mask, Wedge from pytom.alignment.preprocessing import Preprocessing from pytom.frontend.serverpages.serverMessages import FileMessage particleList = ParticleList('.') if 'plXML' in parameters: particleList.fromXMLFile(parameters['plXML']) elif 'plDIR' in parameters: particleList = ParticleList(parameters['plDIR']) particleList.loadDirectory() else: raise RuntimeError('ParticleList parameter missing in request!') sampleInfo = SampleInformation() if 'pixSize' in parameters: sampleInfo.setPixelSize(parameters['pixSize']) else: raise RuntimeError('Pixelsize parameter missing in request!') if 'partDia' in parameters: sampleInfo.setParticleDiameter(parameters['partDia']) else: raise RuntimeError('Particle diameter missing in request!') if 'wa1' in parameters: wedgeAngle1 = float(parameters['wa1']) else: raise RuntimeError('Wedge angle 1 parameter missing in request!') if 'wa2' in parameters: wedgeAngle2 = float(parameters['wa2']) else: raise RuntimeError('Wedge angle 2 parameter missing in request!') wedgeInfo = Wedge([wedgeAngle1, wedgeAngle2]) if 'mask' in parameters: mask = Mask(parameters['mask']) else: raise RuntimeError('Mask parameter missing in request!') if not 'lowestF' in parameters: raise RuntimeError('Lowest frequency parameter missing in request!') if not 'highestF' in parameters: raise RuntimeError('Highest frequency parameter missing in request!') if not 'filtSm' in parameters: raise RuntimeError('Filter smooth parameter missing in request!') preprocessing = Preprocessing(float(parameters['lowestF']), float(parameters['highestF']), float(parameters['filtSm'])) score = None if 'score' in parameters: if parameters['score'] == 'xcf': from pytom.score.score import xcfScore as scoreClass elif parameters['score'] == 'nxcf': from pytom.score.score import nxcfScore as scoreClass elif parameters['score'] == 'flcf': from pytom.score.score import FLCFScore as scoreClass score = scoreClass() else: raise RuntimeError('Score parameter missing in request!') if 'binning' in parameters: binning = int(parameters['binning']) else: raise RuntimeError('Scaling parameter missing in request!') if 'classes' in parameters: numberClasses = float(parameters['classes']) else: raise RuntimeError('Number classes parameter missing in request!') if 'conv' in parameters: convergence = float(parameters['conv']) else: raise RuntimeError('Convergence parameter missing in request!') if 'dest' in parameters: destination = parameters['dest'] else: raise RuntimeError('Destination parameter missing in request!') sampleInfo = SampleInformation() if 'pixSize' in parameters: sampleInfo.setPixelSize(float(parameters['pixSize'])) else: raise RuntimeError('Pixelsize parameter missing in request!') if 'partDia' in parameters: sampleInfo.setParticleDiameter(float(parameters['partDia'])) else: raise RuntimeError('Particle diameter missing in request!') temperature = None if 'temp' in parameters: temperature = parameters['temp'] if 'stemp' in parameters: startTemperature = float(parameters['stemp']) else: raise RuntimeError( 'Start temperature parameter missing in request!') if 'astep' in parameters: annealingStep = float(parameters['astep']) else: raise RuntimeError('Annealing step parameter missing in request!') from pytom.cluster.mcoACStructures import SigmaTemperature if temperature == 'sigma': temperature = SigmaTemperature(startTemperature, annealingStep) else: raise RuntimeError('Temperature missing in request!') criterion = None if 'crit' in parameters: from pytom.cluster.mcoACStructures import MetropolisCriterion, ThresholdAcceptance criterion = parameters['crit'] if criterion == 'metropolis': criterion = MetropolisCriterion() elif criterion == 'threshold': criterion = ThresholdAcceptance() else: raise RuntimeError('Criterion missing in request!') if 'refin' in parameters: localSearchIncrement = float(parameters['refin']) else: raise RuntimeError('Number of refinement rounds missing in request!') from pytom.cluster.mcoACStructures import MCOACJob job = MCOACJob(particleList, destination, mask, score, preprocessing, wedgeInfo, binning, sampleInfo, numberClasses, temperature, criterion, convergence, localSearchIncrement, symmetry=None) jobXMLFile = '' if 'jobFile' in parameters: jobXMLFile = parameters['jobFile'] job.toXMLFile(jobXMLFile) jobRunFile = jobXMLFile[0:-3] createRunscripts(jobRunFile + 'sh', jobXMLFile) return FileMessage('MCOACJob', jobXMLFile, 'created')
def interpretRequestParameters(parameters): """ interpretRequestParameters """ from pytom.basic.structures import ParticleList, SampleInformation, Reference, Mask, Wedge from pytom.alignment.preprocessing import Preprocessing from pytom.frontend.serverpages.serverMessages import FileMessage particleList = ParticleList() if 'plXML' in parameters: particleList.fromXMLFile(parameters['plXML']) elif 'plDIR' in parameters: particleList = ParticleList(parameters['plDIR']) particleList.loadDirectory() else: raise RuntimeError('ParticleList parameter missing in request!') sampleInfo = SampleInformation() if 'pixSize' in parameters: sampleInfo.setPixelSize(parameters['pixSize']) else: raise RuntimeError('Pixelsize parameter missing in request!') if 'partDia' in parameters: sampleInfo.setParticleDiameter(parameters['partDia']) else: raise RuntimeError('Particle diameter missing in request!') if 'wa1' in parameters: wedgeAngle1 = float(parameters['wa1']) else: raise RuntimeError('Wedge angle 1 parameter missing in request!') if 'wa2' in parameters: wedgeAngle2 = float(parameters['wa2']) else: raise RuntimeError('Wedge angle 2 parameter missing in request!') wedgeInfo = Wedge([wedgeAngle1, wedgeAngle2]) if 'mask' in parameters: mask = Mask(parameters['mask']) else: raise RuntimeError('Mask parameter missing in request!') if not 'lowestF' in parameters: raise RuntimeError('Lowest frequency parameter missing in request!') if not 'highestF' in parameters: raise RuntimeError('Highest frequency parameter missing in request!') if not 'filtSm' in parameters: raise RuntimeError('Filter smooth parameter missing in request!') preprocessing = Preprocessing(float(parameters['lowestF']), float(parameters['highestF']), float(parameters['filtSm'])) score = None if 'score' in parameters: if parameters['score'] == 'xcf': from pytom.score.score import xcfScore as scoreClass elif parameters['score'] == 'nxcf': from pytom.score.score import nxcfScore as scoreClass elif parameters['score'] == 'flcf': from pytom.score.score import FLCFScore as scoreClass score = scoreClass() else: raise RuntimeError('Score parameter missing in request!') if 'iter' in parameters: iterations = int(parameters['iter']) else: raise RuntimeError('Number of iterations missing in request!') if 'binning' in parameters: binning = int(parameters['binning']) else: raise RuntimeError('Scaling parameter missing in request!') if 'classes' in parameters: numberClasses = float(parameters['classes']) else: raise RuntimeError('Number classes parameter missing in request!') if 'conv' in parameters: convergence = float(parameters['conv']) else: raise RuntimeError('Convergence parameter missing in request!') if 'dest' in parameters: destination = parameters['dest'] else: raise RuntimeError('Destination parameter missing in request!') sampleInfo = SampleInformation() if 'pixSize' in parameters: sampleInfo.setPixelSize(float(parameters['pixSize'])) else: raise RuntimeError('Pixelsize parameter missing in request!') if 'partDia' in parameters: sampleInfo.setParticleDiameter(float(parameters['partDia'])) else: raise RuntimeError('Particle diameter missing in request!') from pytom.cluster.mcoEXMXStructures import MCOEXMXJob job = MCOEXMXJob(particleList, iterations, destination, mask, score, preprocessing, wedgeInfo, binning, sampleInfo, numberClasses, convergence, symmetry=None) jobXMLFile = '' if 'jobFile' in parameters: jobXMLFile = parameters['jobFile'] job.toXMLFile(jobXMLFile) jobRunFile = jobXMLFile[0:-3] createRunscripts(jobRunFile + 'sh', jobXMLFile) return FileMessage('MCOEXMXJob', jobXMLFile, 'created')
def interpretRequestParameters(parameters): """ interpretRequestParameters """ from pytom.basic.structures import ParticleList, SampleInformation, Reference, Mask, Wedge, PointSymmetry from pytom.alignment.preprocessing import Preprocessing from pytom.frontend.serverpages.serverMessages import FileMessage particleList = ParticleList('.') if 'plXML' in parameters: particleList.fromXMLFile(parameters['plXML']) elif 'plDIR' in parameters: particleList = ParticleList(parameters['plDIR']) particleList.loadDirectory() else: raise RuntimeError('ParticleList parameter missing in request!') sampleInfo = SampleInformation() if 'pixSize' in parameters: sampleInfo.setPixelSize(parameters['pixSize']) else: raise RuntimeError('Pixelsize parameter missing in request!') if 'partDia' in parameters: sampleInfo.setParticleDiameter(parameters['partDia']) else: raise RuntimeError('Particle diameter missing in request!') reference = '' if 'ref' in parameters: reference = Reference(parameters['ref']) else: raise RuntimeError('Reference parameter missing in request!') if 'mask' in parameters: mask = Mask(parameters['mask']) else: raise RuntimeError('Mask parameter missing in request!') angles = None if 'sampling' in parameters: if parameters['sampling'] == 'GLOBAL': from pytom.angles.globalSampling import GlobalSampling if 'angFile' in parameters: angles = GlobalSampling(parameters['angFile']) else: raise RuntimeError('Angle file missing in request!') else: from pytom.angles.localSampling import LocalSampling if 'angStart' in parameters: startIncrement = int(parameters['angStart']) else: raise RuntimeError('Angle start missing in request!') if 'angShells' in parameters: shells = int(parameters['angShells']) else: raise RuntimeError('Angle shells missing in request!') if 'angInc' in parameters: shellIncrement = int(parameters['angInc']) else: raise RuntimeError('Angle increment missing in request!') angles = LocalSampling(shells=shells, increment=startIncrement) else: raise RuntimeError('Sampling completely missing in request!') if not 'lowestF' in parameters: raise RuntimeError('Lowest frequency parameter missing in request!') if not 'highestF' in parameters: raise RuntimeError('Highest frequency parameter missing in request!') if not 'filtSm' in parameters: raise RuntimeError('Filter smooth parameter missing in request!') preprocessing = Preprocessing(float(parameters['lowestF']), float(parameters['highestF']), float(parameters['filtSm'])) adaptive = True if 'adapt' in parameters: fscCriterion = 0.5 resOffset = 0.1 angleFactor = 0.5 adaptive = parameters['adapt'] == 'ON' if parameters['adapt'] == 'ON': if 'adResC' in parameters: fscCriterion = float(parameters['adResC']) else: raise RuntimeError('Resolution criterion missing in request!') if 'adResOf' in parameters: resOffset = parameters['adResOf'] else: raise RuntimeError( 'Resolution offset parameter missing in request!') if 'angFac' in parameters: angleFactor = float(parameters['angFac']) else: raise RuntimeError( 'Angular factor parameter missing in request!') else: raise RuntimeError('Adaptive parameter missing in request!') score = None if 'score' in parameters: if parameters['score'] == 'xcf': from pytom.score.score import xcfScore as scoreClass elif parameters['score'] == 'nxcf': from pytom.score.score import nxcfScore as scoreClass elif parameters['score'] == 'flcf': from pytom.score.score import FLCFScore as scoreClass score = scoreClass() else: raise RuntimeError('Score parameter missing in request!') if 'pkPriRad' in parameters: radius = float(parameters['pkPriRad']) else: raise RuntimeError('Peak distance parameter missing in request!') if 'pkSmooth' in parameters: smooth = float(parameters['pkSmooth']) else: raise RuntimeError('Peak distance smooth missing in request!') score.setPeakPrior(radius=radius, smooth=smooth) if 'iter' in parameters: iterations = int(parameters['iter']) else: raise RuntimeError('Number of iterations missing in request!') if 'binning' in parameters: binning = int(parameters['binning']) else: raise RuntimeError('Scaling parameter missing in request!') if 'dest' in parameters: destination = parameters['dest'] else: raise RuntimeError('Destination parameter missing in request!') from pytom.alignment.ExMaxAlignment import ExMaxJob job = ExMaxJob(particleList, destination, reference, score, angles, mask, PointSymmetry(1), 1, iterations, preprocessing, -1, binning, sampleInfo, fscCriterion, adaptive, resOffset, angleFactor) #print job jobXMLFile = '' if 'jobFile' in parameters: jobXMLFile = parameters['jobFile'] job.toXMLFile(jobXMLFile) if jobXMLFile[-4:] == '.xml': jobRunFile = jobXMLFile[0:-4] else: jobRunFile = jobXMLFile createRunscripts(jobRunFile + '.sh', jobXMLFile) return FileMessage('AlignmentJob', jobXMLFile, 'created')