def getImportClass(self): """ Return the class in charge of importing the files. """ filesPath = self.filesPath.get() importFrom = self.importFrom.get() if importFrom == self.IMPORT_FROM_AUTO: importFrom = self.getFormat() if importFrom == self.IMPORT_FROM_XMIPP3: XmippImport = importFromPlugin('xmipp3.convert', 'XmippImport', doRaise=True) return XmippImport(self, filesPath) elif importFrom == self.IMPORT_FROM_GRIGORIEFF: GrigorieffLabImportCTF = importFromPlugin('grigoriefflab.convert', 'GrigorieffLabImportCTF', doRaise=True) return GrigorieffLabImportCTF(self) elif importFrom == self.IMPORT_FROM_GCTF: GctfImportCTF = importFromPlugin('gctf.convert', 'GctfImportCTF', doRaise=True) return GctfImportCTF(self) elif importFrom == self.IMPORT_FROM_EMAN2: EmanImport = importFromPlugin('eman2.convert', 'EmanImport', doRaise=True) return EmanImport(self, None) elif importFrom == self.IMPORT_FROM_SCIPION: from dataimport import ScipionImport return ScipionImport(self, self.filesPath.get('').strip()) else: return None
def runJavaIJapp(memory, appName, args, env=None): xmipp3 = importFromPlugin('xmipp3') env = env or {} getEnviron = importFromPlugin('xmipp3', 'Plugin').getEnviron env.update(getEnviron(xmippFirst=False)) args = getJavaIJappArguments(memory, appName, args) print 'java %s' % args #return subprocess.Popen('java ' + args, shell=True, env=env) cmd = ['java'] + shlex.split(args) return subprocess.Popen(cmd, env=env)
def getImportClass(self): """ Return the class in charge of importing the files. """ if self.importFrom == self.IMPORT_FROM_EMX: EmxImport = importFromPlugin( 'emxlib.convert', 'EmxImport', errorMsg='Emx is needed to import .emx files', doRaise=True) self.importFilePath = abspath(self.emxFile.get('').strip()) return EmxImport(self, self.importFilePath, self.alignTypeList[self.alignType.get()]) elif self.importFrom == self.IMPORT_FROM_XMIPP3: XmippImport = importFromPlugin( 'xmipp3.convert', 'XmippImport', 'Xmipp is needed to import .xmd files', doRaise=True) self.importFilePath = self.mdFile.get('').strip() return XmippImport(self, self.mdFile.get()) elif self.importFrom == self.IMPORT_FROM_RELION: RelionImport = importFromPlugin( 'relion.convert', 'RelionImport', errorMsg='Relion is needed to import .star files', doRaise=True) self.importFilePath = self.starFile.get('').strip() return RelionImport(self, self.starFile.get()) elif self.importFrom == self.IMPORT_FROM_SCIPION: from dataimport import ScipionImport self.importFilePath = self.sqliteFile.get('').strip() return ScipionImport(self, self.importFilePath) elif self.importFrom == self.IMPORT_FROM_FREALIGN: self.importFilePath = self.parFile.get('').strip() GrigorieffLabImportParticles = importFromPlugin( 'grigoriefflab.convert', 'GrigorieffLabImportParticles', errorMsg='GrigorieffLab is needed to import .stk files', doRaise=True) return GrigorieffLabImportParticles(self, self.parFile.get(), self.stackFile.get()) elif self.importFrom == self.IMPORT_FROM_EMAN: self.importFilePath = self.lstFile.get('').strip() EmanImport = importFromPlugin('eman2.convert', 'EmanImport', doRaise=True) return EmanImport(self, self.lstFile.get()) else: self.importFilePath = '' return None
def convert(self, inputObj, outputObj, dataType=None, transform=None): """ Convert from one image to another. inputObj and outputObj can be: tuple, string, or Image subclass (see self._convertToLocation) transform: if not None, apply this transformation """ inputLoc = self._convertToLocation(inputObj) outputLoc = self._convertToLocation(outputObj) if outputLoc[1].lower().endswith('.img'): # FIXME Since now we can not read dm4 format in Scipion natively # we are opening an Eman2 process to read the dm4 file convertImage = pwutils.importFromPlugin('eman2.convert', 'convertImage') convertImage(inputLoc, outputLoc) else: # Read from input self._img.read(inputLoc) if dataType is not None: self._img.convert2DataType(dataType) if transform is not None: self._img.applyTransforMatScipion(transform.getMatrixAsList()) # Write to output self._img.write(outputLoc)
def getDimensions(self, locationObj): """ It will return a tuple with the images dimensions. The tuple will contains: (x, y, z, n) where x, y, z are image dimensions (z=1 for 2D) and n is the number of elements if stack. """ if self.existsLocation(locationObj): location = self._convertToLocation(locationObj) fn = location[1] ext = pwutils.getExt(fn).lower() if ext == '.png' or ext == '.jpg': im = PIL.Image.open(fn) x, y = im.size # (width,height) tuple return x, y, 1, 1 elif ext == '.img': # FIXME Since now we can not read dm4 format in Scipion natively # or recent .img format # we are opening an Eman2 process to read the dm4 file getImageDimensions = pwutils.importFromPlugin( 'eman2.convert', 'getImageDimensions') return getImageDimensions(fn) # we are ignoring index here else: self._img.read(location, xmippLib.HEADER) return self._img.getDimensions() else: return None, None, None, None
def registerCoords(self, coordsDir): """ This method is usually inherited by all Pickers and it is used from the Java picking GUI to register a new SetOfCoordinates when the user click on +Particles button. """ suffix = self.__getOutputSuffix() outputName = self.OUTPUT_PREFIX + suffix readSetOfCoordinates = pwutils.importFromPlugin( 'xmipp3.convert', 'readSetOfCoordinates') inputset = self.getInputMicrographs() # micrographs are the input set if protocol is not finished outputset = self._createSetOfCoordinates(inputset, suffix=suffix) readSetOfCoordinates(coordsDir, outputset.getMicrographs(), outputset) summary = self.getSummary(outputset) outputset.setObjComment(summary) outputs = {outputName: outputset} self._defineOutputs(**outputs) # Using a pointer to define the relations is more robust to scheduling # and id changes between the protocol run.db and the main project # database. The pointer defined below points to the outputset object self._defineSourceRelation(self.getInputMicrographsPointer(), Pointer(value=self, extended=outputName)) self._store()
def sleepStep(self, secs=5, forceFail=False, tag=''): if forceFail: self.runJob('echo', " 'Failing for testing purposes...'; exit 1") else: getEnviron = importFromPlugin('xmipp3', 'getEnviron') self.runJob('xmipp_work_test', "--time %d --tag '%s'" % (secs, tag), env=getEnviron())
def __runEman2Program(cls, program, args): """ Internal workaround to launch an EMAN2 program. """ eman2 = pwutils.importFromPlugin('eman2') from pyworkflow.utils.process import runJob runJob(None, eman2.Plugin.getProgram(program), args, env=eman2.Plugin.getEnviron())
def runProgram(program, params): env = None if program.startswith('xmipp'): xmipp3 = importFromPlugin('xmipp3', 'Plugin') env = xmipp3.getEnviron() if program.startswith('relion'): relion = importFromPlugin('relion', 'Plugin') env = relion.getEnviron() elif (program.startswith('e2') or program.startswith('sx')): eman2 = importFromPlugin('eman2', 'Plugin') env = eman2.getEnviron() elif program.startswith('b'): bsoft = importFromPlugin('bsoft', 'Plugin') env = bsoft.getEnviron() pwutils.runJob(None, program, params, env=env)
def _readAngles(self, micsFn, suffix=''): # Read Angles from input micrographs anglesSet = self._createSetOfAngles(suffix=suffix) readAnglesFromMicrographs = importFromPlugin( 'xmipp3.convert', 'readAnglesFromMicrographs') readAnglesFromMicrographs(micsFn, anglesSet) anglesSet.write() return anglesSet
def convertStack(self, inputFn, outputFn, firstImg=None, lastImg=None, inFormat=None, outFormat=None): """ Convert an input stack file into another. It is possible to only use a subset of frames to be written in the output stack. If outFormat/inFomat=None then there will be inferred from extension.If firstFrame/lastFrame are not None, the output stack will be a subset of input stack. If it are none, the conversion is over the whole stack. If the input format is ".dm4" or ".img" only is allowed the conversion of the whole stack. """ # inputLower = inputFn.lower() outputLower = outputFn.lower() if outputLower.endswith('.img'): if (firstImg and lastImg) is None: # FIXME Since now we can not read dm4 format in Scipion natively # or writing recent .img format # we are opening an Eman2 process to read the dm4 file convertImage = pwutils.importFromPlugin( 'eman2.convert', 'convertImage') convertImage(inputFn, outputFn) else: ext = os.path.splitext(outputFn)[1] raise Exception("if convert from %s, firstImg and lastImg " "must be None" % ext) # elif inputLower.endswith('.tif'): # # FIXME: It seems that we have some flip problem with compressed # # tif files, we need to check that # if outputLower.endswith('.mrc'): # self.runJob('tif2mrc', '%s %s' % (inputFn, outputFn)) # else: # raise Exception("Conversion from tif to %s is not " # "implemented yet. " % pwutils.getExt(outputFn)) else: # get input dim (x, y, z, n) = xmippLib.getImageSize(inputFn) location = self._convertToLocation(inputFn) self._img.read(location, xmippLib.HEADER) dataType = self.getSupportedDataType(self._img.getDataType(), outputLower) if (firstImg and lastImg) is None: n = max(z, n) firstImg = 1 lastImg = n else: n = lastImg - firstImg + 1 # Create empty output stack file to reserve desired space xmippLib.createEmptyFile(outputFn, x, y, 1, n, dataType) for i, j in izip(range(firstImg, lastImg + 1), range(1, n + 1)): self.convert((i, inputFn), (j, outputFn))
def __init__(self, project, ctfSet, other='', **kwargs): first = ctfSet.getFirstItem() def existingLabels(labelList): return ' '.join([l for l in labelList if first.hasAttributeExt(l)]) psdLabels = existingLabels(self.PSD_LABELS) extraLabels = existingLabels(self.EXTRA_LABELS) labels = 'id enabled %s _defocusU _defocusV ' % psdLabels labels += '_defocusAngle _defocusRatio ' labels += '_phaseShift _resolution _fitQuality %s ' % extraLabels labels += ' _micObj._filename' viewParams = { showj.MODE: showj.MODE_MD, showj.ORDER: labels, showj.VISIBLE: labels, showj.ZOOM: 50 } if psdLabels: viewParams[showj.RENDER] = psdLabels if ctfSet.isStreamOpen(): viewParams['dont_recalc_ctf'] = '' def _anyAttrStartsBy(obj, prefix): """ Return True if any of the attributes of this object starts by the provided prefix. """ return any( attrName.startswith(prefix) for attrName, _ in obj.getAttributesToStore()) if _anyAttrStartsBy(first, '_ctffind4_ctfResolution'): gviewer = importFromPlugin('grigoriefflab.viewers', '') viewParams[showj.OBJCMDS] = "'%s'" % gviewer.OBJCMD_CTFFIND4 elif _anyAttrStartsBy(first, '_gctf'): OBJCMD_GCTF = importFromPlugin('gctf.viewers', 'OBJCMD_GCTF') viewParams[showj.OBJCMDS] = "'%s'" % OBJCMD_GCTF inputId = ctfSet.getObjId() or ctfSet.getFileName() ObjectView.__init__(self, project, inputId, ctfSet.getFileName(), other, viewParams, **kwargs)
def getImportClass(self): """ Return the class in charge of importing the files. """ if self.importFrom == self.IMPORT_FROM_EMX: EmxImport = pwutils.importFromPlugin('emxlib.convert', 'EmxImport') self.importFilePath = self.emxFile.get('').strip() return EmxImport(self, self.importFilePath) elif self.importFrom == self.IMPORT_FROM_XMIPP3: XmippImport = pwutils.importFromPlugin('xmipp3.convert', 'XmippImport') self.importFilePath = self.mdFile.get('').strip() return XmippImport(self, self.mdFile.get()) elif self.importFrom == self.IMPORT_FROM_SCIPION: from dataimport import ScipionImport self.importFilePath = self.sqliteFile.get('').strip() return ScipionImport(self, self.importFilePath) else: self.importFilePath = '' return None
def getImportClass(self): """ Return the class in charge of importing the files. """ importFrom = self.importFrom.get() if importFrom == self.IMPORT_FROM_XMIPP: XmippImport = importFromPlugin( 'xmipp3.convert', 'XmippImport', 'Xmipp is needed to import .xmd files', doRaise=True) return XmippImport(self, None) else: # import from EMAN EmanImport = importFromPlugin( 'eman2.convert', 'EmanImport', errorMsg='Eman is needed to import .json or ' '.box files', doRaise=True) return EmanImport(self, None)
def readSetOfCoordinates(outputDir, micSet, coordSet): readSetOfCoordinates = importFromPlugin( 'relion.convert', 'readSetOfCoordinates', doRaise=True) inputCoords = args.extra starFiles = [ os.path.join( inputCoords, pwutils.removeBaseExt(mic.getFileName()) + '_autopick.star') for mic in micSet ] readSetOfCoordinates(coordSet, starFiles)
def getImportClass(self): """ Return the class in charge of importing the files. """ filesPath = self.filesPath.get() importFrom = self.getImportFrom() if importFrom == self.IMPORT_FROM_XMIPP: XmippImport = importFromPlugin( 'xmipp3.convert', 'XmippImport', 'Xmipp is needed to import .xmd files', doRaise=True) return XmippImport(self, filesPath) elif importFrom == self.IMPORT_FROM_RELION: RelionImport = importFromPlugin( 'relion.convert', 'RelionImport', errorMsg='Relion is needed to import .star files', doRaise=True) return RelionImport(self, filesPath) elif importFrom == self.IMPORT_FROM_EMAN: EmanImport = importFromPlugin( 'eman2.convert', 'EmanImport', errorMsg='Eman is needed to import .json or ' '.box files', doRaise=True) return EmanImport(self, None) elif importFrom == self.IMPORT_FROM_DOGPICKER: DogpickerImport = importFromPlugin( 'appion.convert', 'DogpickerImport', errorMsg='appion plugin is needed to import ' 'dogpicker files', doRaise=True) return DogpickerImport(self) else: self.importFilePath = '' return None
def _getMovieGainProtocol(self): XmippProtMovieGain = pwutils.importFromPlugin('xmipp3.protocols', 'XmippProtMovieGain') if XmippProtMovieGain is None: return None for protPointer in self.inputProtocols: prot = protPointer.get() if prot.getClassName() == XmippProtMovieGain.__name__: return prot return None
def test_RefineEman(self): print("Importing micrograph pairs") protImportMicsPairs = self.newProtocol(pwem.ProtImportMicrographsTiltPairs, patternUntilted=self.micsUFn, patternTilted=self.micsTFn, samplingRate=1.88, voltage=200, sphericalAberration=2.0) self.launchProtocol(protImportMicsPairs) self.assertIsNotNone(protImportMicsPairs.outputMicrographsTiltPair, "There was a problem with the import of mic pairs") print("Importing coordinate pairs") protImportCoords = self.newProtocol(pwem.ProtImportCoordinatesPairs, importFrom=2, # from eman patternUntilted=self.patternU, patternTilted=self.patternT, boxSize=256) protImportCoords.inputMicrographsTiltedPair.set(protImportMicsPairs.outputMicrographsTiltPair) self.launchProtocol(protImportCoords) self.assertIsNotNone(protImportCoords.outputCoordinatesTiltPair, "There was a problem with the import of coord pairs") print("Extracting particle pairs") XmippProtExtractParticlesPairs = importFromPlugin('xmipp3.protocols', 'XmippProtExtractParticlesPairs') protExtractPairs = self.newProtocol(XmippProtExtractParticlesPairs, downFactor=2.0, boxSize=128, doInvert=True) protExtractPairs.inputCoordinatesTiltedPairs.set(protImportCoords.outputCoordinatesTiltPair) self.launchProtocol(protExtractPairs) self.assertIsNotNone(protExtractPairs.outputParticlesTiltPair, "There was a problem with particle pair extraction") print("Run Eman Tilt Validate") protValidate = self.newProtocol(EmanProtTiltValidate, symmetry="c4", maxtilt=60.0, delta=2.0, shrink=2, quaternion=True, simcmpType=2, # frc simcmpParams='maxres=60', simalignType=7, # rotate_translate simralignType=1, # refine numberOfThreads=4) protValidate.inputTiltPair.set(protExtractPairs.outputParticlesTiltPair) protValidate.inputVolume.set(self.protImportVol.outputVolume) protValidate._createFilenameTemplates() outputAngles = protValidate._getFileName('outputAngles') self.launchProtocol(protValidate) self.assertIsNotNone(outputAngles, "Missing some output files!")
def test_nma2(self): #------------------------------------------------ # Case 2. Import Vol -> Pdb -> NMA #------------------------------------------------ # Import the set of particles # (in this order just to be in the middle in the tree) protImportParts = self.newProtocol( ProtImportParticles, filesPath=self.ds.getFile('particles'), samplingRate=1.0) self.launchProtocol(protImportParts) # Import a Volume protImportVol = self.newProtocol(ProtImportVolumes, filesPath=self.ds.getFile('vol'), samplingRate=1.0) self.launchProtocol(protImportVol) # Convert the Volume to Pdb NMA_MASK_THRE = importFromPlugin( 'xmipp3.protocols.pdb.protocol_pseudoatoms_base', 'NMA_MASK_THRE') protConvertVol = self.newProtocol(FlexProtConvertToPseudoAtoms) protConvertVol.inputStructure.set(protImportVol.outputVolume) protConvertVol.maskMode.set(NMA_MASK_THRE) protConvertVol.maskThreshold.set(0.2) protConvertVol.pseudoAtomRadius.set(2.5) self.launchProtocol(protConvertVol) # Launch NMA with Pseudoatoms protNMA2 = self.newProtocol(FlexProtNMA, cutoffMode=NMA_CUTOFF_ABS) protNMA2.inputStructure.set(protConvertVol.outputPdb) self.launchProtocol(protNMA2) # Launch NMA alignment, but just reading result from a previous metadata protAlignment = self.newProtocol( FlexProtAlignmentNMA, modeList='7-9', copyDeformations=self.ds.getFile('gold/pseudo_run1_images.xmd')) protAlignment.inputModes.set(protNMA2.outputModes) protAlignment.inputParticles.set(protImportParts.outputParticles) self.launchProtocol(protAlignment) # Launch Dimred after NMA alignment protDimRed = self.newProtocol( FlexProtDimredNMA, dimredMethod=0, # PCA reducedDim=2) protDimRed.inputNMA.set(protAlignment) self.launchProtocol(protDimRed)
def createOutputStep(self): micTiltPairs = self.getInputMicrographs() # Get the converted input micrographs in Xmipp format writeSetOfMicrographsPairs = importFromPlugin( 'xmipp3.convert', 'writeSetOfMicrographsPairs') writeSetOfMicrographsPairs(micTiltPairs.getUntilted(), micTiltPairs.getTilted(), self.micsFn) uCoordSet, tCoordSet, anglesSet = self.readCoordinates() # Create CoordinatesTiltPair object coordsSet = self._createCoordinatesTiltPair(micTiltPairs, uCoordSet, tCoordSet, anglesSet, suffix='') self._defineOutputs(outputCoordinatesTiltPair=coordsSet) self._defineSourceRelation(self.inputMicrographsTiltedPair, coordsSet)
def createRandomMicStep(self, mic): time.sleep(self.creationInterval.get()) getEnviron = importFromPlugin('xmipp3', 'Plugin').getEnviron # create image img = xmippLib.Image() img.setDataType(xmippLib.DT_FLOAT) img.resize(self.xDim, self.yDim) img.initRandom(0., 1., xmippLib.XMIPP_RND_UNIFORM) baseFn = self._getExtraPath(self._singleImageFn) img.write(baseFn) md1 = xmippLib.MetaData() md1.setColumnFormat(False) idctf = md1.addObject() baseFnCtf = self._getTmpPath("ctf_%d.param" % mic) baseFnImageCTF = self._getExtraPath("imageCTF_%d.xmp" % mic) md1.setValue(xmippLib.MDL_CTF_SAMPLING_RATE, 1., idctf) md1.setValue(xmippLib.MDL_CTF_VOLTAGE, 200., idctf) defocus = 20000 + 10000 * random.random() udefocus = defocus + 1000 * random.random() vdefocus = defocus + 1000 * random.random() if udefocus < vdefocus: aux = vdefocus vdefocus = udefocus udefocus = aux md1.setValue(xmippLib.MDL_CTF_DEFOCUSU, udefocus, idctf) md1.setValue(xmippLib.MDL_CTF_DEFOCUSV, vdefocus, idctf) md1.setValue(xmippLib.MDL_CTF_DEFOCUS_ANGLE, 180.0 * random.random(), idctf) md1.setValue(xmippLib.MDL_CTF_CS, 2., idctf) md1.setValue(xmippLib.MDL_CTF_Q0, 0.07, idctf) md1.setValue(xmippLib.MDL_CTF_K, 1., idctf) md1.write(baseFnCtf) # apply ctf args = " -i %s" % baseFn args += " -o %s" % baseFnImageCTF args += " -f ctf %s" % baseFnCtf args += " --sampling %f" % self.samplingRate self.runJob("xmipp_transform_filter", args, env=getEnviron()) self.dictObj[baseFnImageCTF] = True self._checkProcessedData()
def _readCoordinates(self, coordsDir, suffix=''): micTiltPairs = self.inputMicrographsTiltedPair.get() uSuffix = 'Untilted' + suffix tSuffix = 'Tilted' + suffix uSet = micTiltPairs.getUntilted() tSet = micTiltPairs.getTilted() # Create Untilted and Tilted SetOfCoordinates readSetOfCoordinates = importFromPlugin('xmipp3.convert', 'readSetOfCoordinates') uCoordSet = self._createSetOfCoordinates(uSet, suffix=uSuffix) readSetOfCoordinates(coordsDir, uSet, uCoordSet) uCoordSet.write() tCoordSet = self._createSetOfCoordinates(tSet, suffix=tSuffix) readSetOfCoordinates(coordsDir, tSet, tCoordSet) tCoordSet.write() boxSize = self._getBoxSize() if boxSize: uCoordSet.setBoxSize(boxSize) tCoordSet.setBoxSize(boxSize) return uCoordSet, tCoordSet
def _compareMicPairs(self, micFn, uSet, tSet): # compare micFn input file and input micsSet micMd = md.MetaData(micFn) micFnDict = {} inputMicsDict = {} XmippMdRow = importFromPlugin('xmipp3', 'XmippMdRow') for objId in micMd: row = XmippMdRow() row.readFromMd(micMd, objId) micUFn = removeBaseExt(row.getValue(md.MDL_MICROGRAPH)) micTFn = removeBaseExt(row.getValue(md.MDL_MICROGRAPH_TILTED)) micFnDict[micUFn] = micTFn for micU, micT in izip(uSet, tSet): inputMicsDict[removeBaseExt(micU.getFileName())] = removeBaseExt( micT.getFileName()) for micKey in inputMicsDict: if micKey not in micFnDict: return False return True
def getPreferredViewers(className): """ Find and import the preferred viewers for this class. """ preferredViewerNames = Config.VIEWERS.get(className, []) if not isinstance(preferredViewerNames, list): preferredViewerNames = [preferredViewerNames] preferredViewers = [] # we will try to import them and store here for prefViewerStr in preferredViewerNames: try: (prefViewerModule, prefViewerClassName) = prefViewerStr.rsplit('.', 1) prefViewer = importFromPlugin(prefViewerModule, prefViewerClassName, doRaise=True) preferredViewers.append(prefViewer) except Exception as e: print("Couldn't load \"%s\" as preferred viewer.\n" "There might be a typo in your VIEWERS " "variable or an error in the viewer's plugin installation" % prefViewerStr) print(e) return preferredViewers
# ************************************************************************** import unittest, sys from pyworkflow.em import * from pyworkflow.tests import * import pyworkflow.utils as pwutils from test_workflow import TestWorkflow from pyworkflow.em.protocol import ProtImportCoordinates try: from xmipp3 import * from xmipp3.protocols import * except: pwutils.pluginNotFound('xmipp', doRaise=True) OTHER = pwutils.importFromPlugin('xmipp3.constants', 'OTHER', doRaise=True) class TestXmippWorkflow(TestWorkflow): @classmethod def setUpClass(cls): setupTestProject(cls) cls.dataset = DataSet.getDataSet('xmipp_tutorial') cls.allCrdsDir = cls.dataset.getFile('posAllDir') cls.micsFn = cls.dataset.getFile('allMics') cls.vol1 = cls.dataset.getFile('vol1') def testXmippWorkflow(self): #First, import a set of micrographs protImport = self.newProtocol(ProtImportMicrographs, filesPath=self.micsFn,
# * e-mail address '*****@*****.**' # ***************************************************************************/ import time import os from pyworkflow.em.data import SetOfCTF from pyworkflow.tests import BaseTest, setupTestProject from pyworkflow.em.protocol import ProtCreateStreamData, ProtMonitorSystem from pyworkflow.em.protocol.monitors.pynvml import nvmlInit, NVMLError from pyworkflow.protocol import getProtocolFromDb from pyworkflow.em.protocol.protocol_create_stream_data import \ SET_OF_RANDOM_MICROGRAPHS from pyworkflow.utils import importFromPlugin XmippProtCTFMicrographs = importFromPlugin( 'xmipp3.protocols.protocol_ctf_micrographs', 'XmippProtCTFMicrographs', doRaise=True) ProtCTFFind = importFromPlugin('grigoriefflab.protocols', 'ProtCTFFind', doRaise=True) ProtGctf = importFromPlugin('gctf.protocols', 'ProtGctf', doRaise=True) # Load the number of movies for the simulation, by default equal 5, but # can be modified in the environment MICS = os.environ.get('SCIPION_TEST_MICS', 6) CTF_SQLITE = "ctfs.sqlite" class TestCtfStreaming(BaseTest): @classmethod def setUpClass(cls):
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # * 02111-1307 USA # * # * All comments concerning this program package may be sent to the # * e-mail address '*****@*****.**' # * # ************************************************************************** from pyworkflow.tests import * from test_workflow import TestWorkflow from pyworkflow.utils import importFromPlugin from pyworkflow.em import ProtImportMicrographsTiltPairs, ProtImportMicrographs, \ ProtImportCoordinates XmippProtAssignmentTiltPair = importFromPlugin('xmipp3.protocols', 'XmippProtAssignmentTiltPair', doRaise=True) # update this test when RCT workflow are implemented class TestXmippAssignmentTiltPairsWorkflow(TestWorkflow): @classmethod def setUpClass(cls): setupTestProject(cls) cls.dataset = DataSet.getDataSet('rct') cls.allCrdsDir = cls.dataset.getFile('positions') cls.micsUFn = cls.dataset.getFile('untilted') cls.micsTFn = cls.dataset.getFile('tilted') def test1(self): #First, import a set of micrographs
# ***************************************************************************/ import time import os from glob import glob import threading import pyworkflow.utils as pwutils from pyworkflow.utils import importFromPlugin from pyworkflow.tests import BaseTest, setupTestProject, DataSet from pyworkflow.em import ImageHandler from pyworkflow.em.protocol import (ProtImportMovies, ProtMonitorSummary, ProtImportMicrographs, ProtImportAverages) XmippProtOFAlignment = importFromPlugin('xmipp3.protocols', 'XmippProtOFAlignment', doRaise=True) ProtCTFFind = importFromPlugin('grigoriefflab.protocols', 'ProtCTFFind', doRaise=True) ProtRelionExtractParticles = importFromPlugin('relion.protocols', 'ProtRelionExtractParticles', doRaise=True) ProtRelion2Autopick = importFromPlugin('relion.protocols', 'ProtRelion2Autopick') # Load the number of movies for the simulation, by default equal 5, but # can be modified in the environement def _getVar(varSuffix, varType, default=None): return varType(
# * All comments concerning this program package may be sent to the # * e-mail address '*****@*****.**' # * # ************************************************************************** import os from itertools import izip from math import ceil import pyworkflow.utils as pwutils import pyworkflow.em as em from pyworkflow.em.data import MovieAlignment from pyworkflow.em.protocol import ProtAlignMovies import pyworkflow.protocol.params as params from pyworkflow.gui.plotter import Plotter writeShiftsMovieAlignment = pwutils.importFromPlugin('xmipp3.convert', 'writeShiftsMovieAlignment') from grigoriefflab import Plugin from grigoriefflab.convert import readShiftsMovieAlignment from grigoriefflab.constants import UNBLUR class ProtUnblur(ProtAlignMovies): """ Unblur is used to align the frames of movies recorded on an electron microscope to reduce image blurring due to beam-induced motion. """ _label = 'unblur' CONVERT_TO_MRC = 'mrc' CORRECT_GAIN = True @classmethod def validateInstallation(cls):
# * You should have received a copy of the GNU General Public License # * along with this program; if not, write to the Free Software # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # * 02111-1307 USA # * # * All comments concerning this program package may be sent to the # * e-mail address '*****@*****.**' # * # ***************************************************************************/ from pyworkflow.tests import BaseTest, DataSet, setupTestProject from pyworkflow.em.protocol import ProtImportMicrographs, ProtCreateStreamData from pyworkflow.utils import importFromPlugin ProtCTFFind = importFromPlugin('grigoriefflab.protocols', 'ProtCTFFind', doRaise=True) XmippProtCTFMicrographs = importFromPlugin('xmipp3.protocols', 'XmippProtCTFMicrographs', doRaise=True) XmippProtCTFConsensus = importFromPlugin('xmipp3.protocols', 'XmippProtCTFConsensus', doRaise=True) class TestCtfConsensus(BaseTest): """ Check if the Xmipp-CTFconsensus rejects CTFs (and the coorrespondig mics) when two CTF estimations give different results, and accept when the two estimations give similar results. """ @classmethod