def test_msaWorkflow(self): """ Run an Import particles protocol. """ print(magentaStr("\n==> Importing data - particles:")) protImport = self.newProtocol(ProtImportParticles, importFrom=2, mdFile=self.particlesFn, samplingRate=3.5) self.launchProtocol(protImport) self.assertIsNotNone(protImport.outputParticles, "SetOfParticles has not been produced.") print(magentaStr("\n==> Testing imagic - msa:")) protMsa = self.newProtocol(ImagicProtMSA, objLabel='imagic - msa', numberOfFactors=10, numberOfIterations=5, numberOfMpi=1) protMsa.inputParticles.set(protImport.outputParticles) self.launchProtocol(protMsa) print(magentaStr("\n==> Testing imagic - msa classify:")) protMsaClassify = self.newProtocol(ImagicProtMSAClassify, objLabel='imagic - msa classify', numberOfFactors=5, numberOfClasses=4) protMsaClassify.inputMSA.set(protMsa) self.launchProtocol(protMsaClassify) self.assertIsNotNone( protMsaClassify.outputClasses, "There was a problem with the MSA-classify protocol's " "outputClasses")
def test_filterParticles(self): print "\n", greenStr(" Filter Particles ".center(75, '-')) def test(parts=self.protImport.outputParticles, **kwargs): "Launch XmippProtFilterParticles on parts and check results." print magentaStr("\n==> Input params: %s" % kwargs) prot = self.newProtocol(XmippProtFilterParticles, **kwargs) prot.inputParticles.set(parts) self.launchProtocol(prot) self.assertIsNotNone(prot.outputParticles, "There was a problem with filter particles") self.assertTrue(prot.outputParticles.equalAttributes( parts, ignore=['_mapperPath'], verbose=True)) # Compare the individual particles too. self.assertTrue(prot.outputParticles.equalItemAttributes( parts, ignore=['_filename', '_index'], verbose=True)) # Check a few different cases. test(filterSpace=FILTER_SPACE_FOURIER, lowFreq=0.1, highFreq=0.25) test(filterSpace=FILTER_SPACE_REAL, filterModeReal=xfh.FM_MEDIAN) # For wavelets, we need the input's size to be a power of 2 print magentaStr("\n==> Resizing particles to 256 pixels") protResize = self.newProtocol(XmippProtCropResizeParticles, doResize=True, resizeOption=xrh.RESIZE_DIMENSIONS, resizeDim=256) protResize.inputParticles.set(self.protImport.outputParticles) self.launchProtocol(protResize) test(parts=protResize.outputParticles, filterSpace=FILTER_SPACE_WAVELET, filterModeWavelets=xfh.FM_DAUB12, waveletMode=xfh.FM_REMOVE_SCALE)
def test_ProjMatchSpider(self): print(magentaStr("\n==> Importing data - particles:")) protImportPart = self.newProtocol( ProtImportParticles, objLabel='from scipion (to-reconstruct)', importFrom=ProtImportParticles.IMPORT_FROM_SCIPION, sqliteFile=self.dsRelion.getFile('import/case2/particles.sqlite'), magnification=10000, samplingRate=7.08) self.launchProtocol(protImportPart) self.assertIsNotNone(protImportPart.getFiles(), "There was a problem with the import") print(magentaStr("\n==> Importing data - volume:")) protImportVol = self.newProtocol(ProtImportVolumes, filesPath=self.vol, samplingRate=7.08) self.launchProtocol(protImportVol) self.assertIsNotNone(protImportVol.getFiles(), "There was a problem with the import") print(magentaStr("\n==> Testing spider - refinement:")) protRefine = self.newProtocol(SpiderProtRefinement, numberOfIterations=2, alignmentShift=2, radius=26, smallAngle=True, angStepSm=1, thetaRange=2) protRefine.inputParticles.set(protImportPart.outputParticles) protRefine.input3DReference.set(protImportVol.outputVolume) self.launchProtocol(protRefine) self.assertIsNotNone( protRefine.outputVolume, "There was a problem with Spider refinement protocol")
def setUpClass(cls): setupTestProject(cls) TestBase.setData() print(magentaStr("\n==> Importing data - micrographs:")) cls.protImport = cls.runImportMicrographBPV(cls.micFn) print(magentaStr("\n==> Running cistem - ctffind:")) cls.protCtfRun = cls.runCtffind(cls.protImport.outputMicrographs)
def setUpClass(cls): setupTestProject(cls) TestEmanBase.setData('mda') print(magentaStr("\n==> Importing data - particles:")) cls.protImport = cls.runImportParticles(cls.particlesFn, 3.5) print(magentaStr("\n==> Importing data - volume:")) cls.protImportVol = cls.runImportVolumes(cls.vol, 3.5)
def test_align(self): """ Run an Import particles protocol. """ print(magentaStr("\n==> Importing data - particles:")) protImport = self.newProtocol(ProtImportParticles, filesPath=self.particlesFn, samplingRate=3.5) self.launchProtocol(protImport) self.assertIsNotNone(protImport.outputParticles, "SetOfParticles has not been produced.") print(magentaStr("\n==> Running spider - filter particles:")) protFilter = self.newProtocol(SpiderProtFilter) protFilter.inputParticles.set(protImport) protFilter.inputParticles.setExtended('outputParticles') self.launchProtocol(protFilter) self.assertIsNotNone( protFilter.outputParticles, "There was a problem with the SpiderProtFilter outputParticles") print(magentaStr("\n==> Testing spider - align ap sr:")) self.runAlignment(protFilter, SpiderProtAlignAPSR, objLabel='align apsr') print(magentaStr("\n==> Testing spider - align pairwise:")) self.runAlignment(protFilter, SpiderProtAlignPairwise, objLabel='align pairwise') print( magentaStr( "\n==> Testing spider - align pairwise with 180 deg. rotation:" )) self.runAlignment(protFilter, SpiderProtAlignPairwise, objLabel='align pairwise - RT180', cgOption=2) # RT180
def test_tiltseries_motioncor2(self): print(magentaStr("\n==> Importing data - TiltSeries:")) protImport = self._runImportTiltSeriesM() print(magentaStr("\n==> Testing motioncor2 - patch-based:")) protMc = self.newProtocol(ProtTsMotionCorr) protMc.inputTiltSeriesM.set(protImport.outputTiltSeriesM) self.launchProtocol(protMc) self.checkTSSet(protMc.outputTiltSeries, 2, 3, checkIds=True)
def launchSet(self, **kwargs): "Launch XmippProtCropResizeVolumes and return output volumes." print magentaStr("\n==> Crop/Resize single set of volumes input params: %s" % kwargs) prot = XmippProtCropResizeVolumes(**kwargs) prot.inputVolumes.set(self.protImport1.outputVolumes) self.proj.launchProtocol(prot, wait=True) self.assertTrue(hasattr(prot, "outputVol") and prot.outputVol is not None, "There was a problem with applying resize/crop to a set of volumes") return prot.outputVol
def launch(self, **kwargs): "Launch XmippProtCropResizeParticles and return output particles." print magentaStr("\n==> Crop/Resize input params: %s" % kwargs) prot = self.newProtocol(XmippProtCropResizeParticles, **kwargs) # prot.inputParticles.set(self.protImport.outputParticles) self.launchProtocol(prot) self.assertTrue( hasattr(prot, "outputParticles") and prot.outputParticles is not None, "There was a problem applying resize/crop to the particles") return prot.outputParticles # for more tests
def launchSingle(self, **kwargs): "Launch XmippProtCropResizeVolumes and return output volume." print magentaStr("\n==> Crop/Resize single volume input params: %s" % kwargs) prot = XmippProtCropResizeVolumes(**kwargs) prot.inputVolumes.set(self.protImport2.outputVolume) self.proj.launchProtocol(prot, wait=True) self.assertTrue( hasattr(prot, "outputVol") and prot.outputVol is not None, "There was a problem with applying resize/crop to a volume") return prot.outputVol
def setUpClass(cls): setupTestProject(cls) TestGctfBase.setData() print(magentaStr("\n==> Importing data - particles (no alignment):")) cls.protImport1 = cls.runImportParticlesBPV( cls.partFn1, label='import particles (no alignment)') print(magentaStr("\n==> Importing data - particles (with alignment):")) cls.protImport2 = cls.runImportParticlesBPV( cls.partFn2, label='import particles (with alignment)') print(magentaStr("\n==> Importing data - micrographs:")) cls.protImportMics = cls.runImportMicrographBPV(cls.micFn)
def launchAndTestSingle(self, **kwargs): "Launch XmippProtFilterVolumes on single volume and check results." print magentaStr("\n==> Filter singe volume input params: %s" % kwargs) prot = XmippProtFilterVolumes(**kwargs) prot.inputVolumes.set(self.protImport2.outputVolume) self.proj.launchProtocol(prot, wait=True) self.assertTrue(hasattr(prot, "outputVol") and prot.outputVol is not None, "There was a problem with filter single volume") self.assertTrue(prot.outputVol.equalAttributes( self.protImport2.outputVolume, ignore=['_index', '_filename'], verbose=True))
def setUpClass(cls): setupTestProject(cls) Test3DFSCBase.setData() print(magentaStr("\n==> Importing data - volume:")) cls.protImportVol = cls.runImportVolumes(cls.map3D, 3.54) print(magentaStr("\n==> Importing data - volume half 1:")) cls.protImportHalf1 = cls.runImportVolumes(cls.half1, 3.54) print(magentaStr("\n==> Importing data - volume half 2:")) cls.protImportHalf2 = cls.runImportVolumes(cls.half2, 3.54) print(magentaStr("\n==> Importing data - mask:")) cls.protImportMask = cls.runImportMask(cls.mask, 3.54)
def check(set0, n1=2, n2=2): "Simple checks on subsets, coming from split sets of set0." print magentaStr("\n==> Check subset of %s" % type(set0).__name__) p_split1 = self.split(set0, n=n1, randomize=True) p_split2 = self.split(set0, n=n2, randomize=True) setFull = random.choice(list(self.outputs(p_split1))) setSub = random.choice(list(self.outputs(p_split2))) label = '%s - %s,%s ' % (set0.getClassName(), n1, n2) # Launch intersection subset p_subset = self.newProtocol(ProtSubSet) p_subset.setObjLabel(label + 'intersection') p_subset.inputFullSet.set(setFull) p_subset.inputSubSet.set(setSub) self.launchProtocol(p_subset) # Launch difference subset p_subset_diff = self.proj.copyProtocol(p_subset) p_subset_diff.setOperation.set(p_subset_diff.SET_DIFFERENCE) p_subset_diff.setObjLabel(label + 'difference') self.launchProtocol(p_subset_diff) setFullIds = setFull.getIdSet() setSubIds = setSub.getIdSet() n = len(setFull) # Check intersection outputs = [o for o in self.outputs(p_subset)] n1 = 0 if outputs: output = outputs[0] n1 = len(output) for elem in output: self.assertTrue(elem.getObjId() in setFullIds) self.assertTrue( elem.getObjId() in setSubIds, 'object id %s not in set: %s' % (elem.getObjId(), setSubIds)) # Check difference outputs = [o for o in self.outputs(p_subset_diff)] n2 = 0 if outputs: output_diff = outputs[0] n2 = len(output_diff) for elem in output_diff: self.assertTrue(elem.getObjId() in setFullIds) self.assertTrue(elem.getObjId() not in setSubIds) self.assertTrue(n >= n1) self.assertTrue(n >= n2) self.assertEqual(n, n1 + n2)
def check(set0, n=2, randomize=False): "Simple checks on split sets from set0." print magentaStr("\n==> Check split of %s" % type(set0).__name__) unsplit_set = [x.strId() for x in set0] p_split = self.split(set0, n=n, randomize=randomize) # Are all output elements of the protocol in the original set? for em_set in self.outputs(p_split): for elem in em_set: self.assertTrue(elem.strId() in unsplit_set) # Number of elements of all splitted sets equal to original number? self.assertEqual(sum(len(x) for x in self.outputs(p_split)), len(set0))
def check(set0, n1=2, n2=2): "Simple checks on subsets, coming from split sets of set0." print magentaStr("\n==> Check subset of %s" % type(set0).__name__) p_split1 = self.split(set0, n=n1, randomize=True) p_split2 = self.split(set0, n=n2, randomize=True) setFull = random.choice(list(self.outputs(p_split1))) setSub = random.choice(list(self.outputs(p_split2))) label = '%s - %s,%s ' % (set0.getClassName(), n1, n2) # Launch intersection subset p_subset = self.newProtocol(ProtSubSet) p_subset.setObjLabel(label + 'intersection') p_subset.inputFullSet.set(setFull) p_subset.inputSubSet.set(setSub) self.launchProtocol(p_subset) # Launch difference subset p_subset_diff = self.proj.copyProtocol(p_subset) p_subset_diff.setOperation.set(p_subset_diff.SET_DIFFERENCE) p_subset_diff.setObjLabel(label + 'difference') self.launchProtocol(p_subset_diff) setFullIds = setFull.getIdSet() setSubIds = setSub.getIdSet() n = len(setFull) # Check intersection outputs = [o for o in self.outputs(p_subset)] n1 = 0 if outputs: output = outputs[0] n1 = len(output) for elem in output: self.assertTrue(elem.getObjId() in setFullIds) self.assertTrue(elem.getObjId() in setSubIds, 'object id %s not in set: %s' % (elem.getObjId(), setSubIds)) # Check difference outputs = [o for o in self.outputs(p_subset_diff)] n2 = 0 if outputs: output_diff = outputs[0] n2 = len(output_diff) for elem in output_diff: self.assertTrue(elem.getObjId() in setFullIds) self.assertTrue(elem.getObjId() not in setSubIds) self.assertTrue(n >= n1) self.assertTrue(n >= n2) self.assertEqual(n, n1+n2)
def launchAndTestSingle(self, **kwargs): "Launch XmippProtFilterVolumes on single volume and check results." print magentaStr("\n==> Filter singe volume input params: %s" % kwargs) prot = XmippProtFilterVolumes(**kwargs) prot.inputVolumes.set(self.protImport2.outputVolume) self.proj.launchProtocol(prot, wait=True) self.assertTrue( hasattr(prot, "outputVol") and prot.outputVol is not None, "There was a problem with filter single volume") self.assertTrue( prot.outputVol.equalAttributes(self.protImport2.outputVolume, ignore=['_index', '_filename'], verbose=True))
def test(parts=self.protImport.outputParticles, **kwargs): "Launch XmippProtFilterParticles on parts and check results." print magentaStr("\n==> Input params: %s" % kwargs) prot = self.newProtocol(XmippProtFilterParticles, **kwargs) prot.inputParticles.set(parts) self.launchProtocol(prot) self.assertIsNotNone(prot.outputParticles, "There was a problem with filter particles") self.assertTrue(prot.outputParticles.equalAttributes( parts, ignore=['_mapperPath'], verbose=True)) # Compare the individual particles too. self.assertTrue(prot.outputParticles.equalItemAttributes( parts, ignore=['_filename', '_index'], verbose=True))
def setUpClass(cls): setupTestProject(cls) TestEmanBase.setData('igbmc_gempicker') cls.micsFn = cls.dataset.getFile('micrographs/*.mrc') cls.avgFn = cls.dataset.getFile('templates/templates_white.stk') print(magentaStr("\n==> Importing data - micrographs:")) cls.protImportMics = cls.runImportMicrograph(cls.micsFn, samplingRate=4.4, voltage=120, sphericalAberration=2.0, scannedPixelSize=None, magnification=60000) print(magentaStr("\n==> Importing data - class averages:")) cls.protImportAvg = cls.runImportAverages(cls.avgFn, 4.4)
def checkQueue(jobId, protId): """ Check if the protocol job is queued """ self.assertTrue(isJobInQueue(jobId, protId), "The job %s corresponding to " "the protocol %d has been not " "attached to the system queue" % (jobId, protId)) print(pwutils.magentaStr(" > job %s of the protocol %d found in the " "queue, wait a sec..." % (jobId, protId))) isDone = wait_until(isJobInQueue, 10*60, jobId, protId, Yes=False) self.assertTrue(isDone, "Timeout: the job has not ended...") print(pwutils.magentaStr(" ...job ended!"))
def testLocscale(self): """ Check that an output was generated and the condition is valid. In addition, returns the size of the set. """ print magentaStr("\n==> Testing locscale:") def launchTest(label, vol, ref, mask=None, mpi=4): print magentaStr("\nTest %s:" % label) pLocScale = self.proj.newProtocol(ProtLocScale, objLabel='locscale - ' + label, inputVolume=vol, refObj=ref, patchSize=16, binaryMask=mask, numberOfMpi=mpi) self.proj.launchProtocol(pLocScale, wait=True) self.assertIsNotNone(pLocScale.outputVolume, "outputVolume is None for %s test." % label) self.assertEqual(self.inputVol.getDim(), pLocScale.outputVolume.getDim(), "outputVolume has diferent size than inputVol " "for %s test" % label) self.assertEqual(self.inputVol.getSamplingRate(), pLocScale.outputVolume.getSamplingRate(), "outputVolume has diferent sampling rate than " "inputVol for %s test" % label) # default test launchTest('with MPI + noMask', vol=self.inputVol, ref=self.inputRef) # with mask test launchTest('with MPI + Mask', vol=self.inputVol, ref=self.inputRef, mask=self.mask) # with mask test launchTest('with Mask + noMPI', vol=self.inputVol, ref=self.inputRef, mask=self.mask, mpi=1) # without MPI launchTest('noMask + noMPI', vol=self.inputVol, ref=self.inputRef, mpi=1) # convert input volume launchTest('convert inputVol', vol=self.inputVol2, ref=self.inputRef) # convert reference volume launchTest('convert reference', vol=self.inputVol, ref=self.inputRef2, mask=self.mask)
def check(set0): "Simple checks on merge, coming from many split sets of set0." print magentaStr("\n==> Check merge of %s" % type(set0).__name__) p_union = self.proj.newProtocol(ProtUnionSet) setsIds = [] for i in range(random.randint(1, 5)): n = random.randint(1, len(set0) // 2) p_split = self.split(set0, n=n, randomize=True) setRandom = random.choice(list(self.outputs(p_split))) setsIds.append([x.strId() for x in setRandom]) p_union.inputSets.append(setRandom) self.proj.launchProtocol(p_union, wait=True) output = self.outputs(p_union).next() # first (and only!) output self.assertEqual(len(output), sum(len(x) for x in setsIds))
def launchAndTestSet(self, **kwargs): "Launch XmippProtFilterVolumes on set of volumes and check results." print magentaStr("\n==> Filter multiple volumes input params: %s" % kwargs) prot = XmippProtFilterVolumes(**kwargs) vIn = self.protImport1.outputVolumes # short notation prot.inputVolumes.set(vIn) self.proj.launchProtocol(prot, wait=True) self.assertTrue(hasattr(prot, "outputVol") and prot.outputVol is not None, "There was a problem with filter multiple volumes") self.assertTrue(prot.outputVol.equalAttributes( self.protImport1.outputVolumes, ignore=['_mapperPath'], verbose=True)) # Compare the individual volumes too. self.assertTrue(prot.outputVol.equalItemAttributes( self.protImport1.outputVolumes, ignore=['_index', '_filename'], verbose=True))
def setUpClass(cls): setupTestProject(cls) cls.dataset = DataSet.getDataSet('relion_tutorial') cls.particlesFn = cls.dataset.getFile('import/case2/particles.sqlite') print(magentaStr("\n==> Importing data - particles:")) cls.protImport = cls.runImportParticlesSqlite(cls.particlesFn, sampling=3.5)
def _runFils(self, graphsProt): print(magentaStr("\n==> Running fils:")) protFils = self.newProtocol(ProtPySegFils, graphsFrom=FROM_SCIPION, inGraphsProt=graphsProt, segLabelS=MEMBRANE_OUTER_SURROUNDINGS, segLabelT=MEMBRANE, gRgEud='1 30', gRgLen='1 60', gRgSin='0 2') protFils.setObjLabel('Fils') protFils = self.launchProtocol(protFils) # Check that resulting files are created as expected xmlFiles = ['mb_sources.xml', 'no_mb_targets.xml'] nVesicles = 3 filssFilePattern = 'Pertuzumab_1_defocus_25um_tomo_7_aliSIRT_EED_tid_%i_fil_mb_sources_to_no_mb_targets_net' graphsFilesPerVesicle = [ filssFilePattern + '.pkl', filssFilePattern + '.vtp', filssFilePattern + '_edges.vtp', filssFilePattern + '_edges2.vtp', filssFilePattern + '_skel.vtp' ] outputStar = 'fil_mb_sources_to_no_mb_targets_net.star' [ self.assertTrue(exists(protFils._getExtraPath(file))) for file in xmlFiles ] self.assertTrue(exists(protFils._getExtraPath(outputStar))) for i in range(nVesicles): for file in graphsFilesPerVesicle: self.assertTrue(exists(protFils._getExtraPath(file % i))) return protFils
def testMultibody(self): print(magentaStr("\n==> Testing relion - multi-body:")) relionMbody = self.newProtocol(relion.protocols.ProtRelionMultiBody, initialOffsetRange=2.0, initialOffsetStep=0.5, runFlexAnalysis=False, pooledParticles=30, skipPadding=True, doGpu=True, gpusToUse='0,1:2,3', numberOfThreads=12, numberOfMpis=3) protRef = self._setupRefinement() relionMbody.protRefine.set(protRef) # copy m-body files into protocol dir currDir1 = os.path.join(self.proj.getPath(), relionMbody._getPath("Uploads")) print("Copying files from %s to %s" % (self.extra, currDir1)) copyTree(self.extra, currDir1) bodyFn = os.path.join(self.proj.getPath(), relionMbody._getPath('Uploads/2-bodies.star')) relionMbody.bodyStarFile.set(bodyFn) self.saveProtocol(relionMbody) self.launchProtocol(relionMbody) self.assertIsNotNone(relionMbody.outputVolumes, "There was a problem with Relion multi-body")
def _createRef3DProtBox(self, label, protocol): from pyworkflow.protocol.constants import STATUS_FINISHED prot = self.newProtocol(protocol) self.saveProtocol(prot) prot.setObjLabel(label) makePath(prot._getPath()) makePath(prot._getExtraPath()) makePath(prot._getTmpPath()) prot.inputParticles.set(self.importPartsFromScipion().outputParticles) outputVol = self.importVolume().outputVolume prot.referenceVolume.set(outputVol) volume = Volume() volume.setFileName(prot._getExtraPath('test.mrc')) pxSize = prot.inputParticles.get().getSamplingRate() volume.setSamplingRate(pxSize) prot._defineOutputs(outputVolume=volume) prot.setStatus(STATUS_FINISHED) # Create a mask protocol print(magentaStr("\n==> Running relion - create mask 3d:")) protMask = self.newProtocol(ProtRelionCreateMask3D) protMask.inputVolume.set(outputVol) self.launchProtocol(protMask) return prot, protMask
def _estimateCTF3D(self, protImportCoords3D, protTSCtfImod): print(magentaStr("\n==> Estimating the 3D CTF per subvolume:")) protEstimateCTF3D = self.newProtocol( ProtRelionEstimateCTF3D, inputCoordinates=getattr(protImportCoords3D, 'outputCoordinates', None), inputSetCTFTomoSeries=getattr(protTSCtfImod, 'outputSetOfCTFTomoSeries', None), doseFilesPath=self.ds.getPath(), filesPattern='*ExpDose.txt', boxSize=self.boxSize, ctf3dMode=CTF3D_PER_SUBVOLUME, ) protEstimateCTF3D.setObjLabel('Estimate CTF 3D') protEstimateCTF3D = self.launchProtocol(protEstimateCTF3D) coord3DSet = getattr(protEstimateCTF3D, 'outputCoordinates', None) # Validate output tomograms self.assertSetSize(coord3DSet, size=self.nSubtomos) self.assertEqual(coord3DSet.getSamplingRate(), self.samplingRate) self.assertEqual(coord3DSet.getBoxSize(), self.boxSize) # Output coordinates must have an attribute named _3dcftMrcFile, which stores the # path of the each ctf3D file for coord3d in coord3DSet: self.assertTrue(exists(coord3d._3dcftMrcFile.get())) return protEstimateCTF3D
def test_sidesplitter(self): protRef, protMask = self._createRef3DProtBox("auto-refine", ProtRelionRefine3D) protRef._createFilenameTemplates() volPath = protRef._getFileName('finalvolume', ref3d=1).split(':')[0] volHalf1 = protRef._getFileName('final_half1_volume', ref3d=1).split(':')[0] volHalf2 = protRef._getFileName('final_half2_volume', ref3d=1).split(':')[0] copyFile(self.volFn, volPath) copyFile(self.half1Fn, volHalf1) copyFile(self.half2Fn, volHalf2) protRef.outputVolume.setFileName(volPath) protRef.outputVolume.setHalfMaps([volHalf1, volHalf2]) project = protRef.getProject() project._storeProtocol(protRef) print(magentaStr("\n==> Testing sidesplitter - after refine 3d:")) sidesplitterProt = self.newProtocol(ProtSideSplitter, protRefine=protRef, mask=protMask.outputMask) sidesplitterProt.setObjLabel('sidesplitter after Auto-refine') self.launchProtocol(sidesplitterProt) self._validations(sidesplitterProt.outputVolume1, 60, 3)
def launchSet(self, **kwargs): "Launch XmippProtImageOperateVolumes and return output volumes." print magentaStr("\n==> Operate set of volumes input params: %s" % kwargs) prot = XmippProtImageOperateVolumes() prot.operation.set(kwargs.get('operation', 1)) prot.inputVolumes.set(self.protImport3.outputVolumes) prot.setObjLabel(kwargs.get('objLabel', None)) prot.isValue.set(kwargs.get('isValue', False)) prot.inputVolumes2.set(kwargs.get('volumes2', None)) prot.value.set(kwargs.get('value', None)) prot.intValue.set(kwargs.get('intValue', None)) self.proj.launchProtocol(prot, wait=True) self.assertTrue(hasattr(prot, "outputVol") and prot.outputVol is not None, "There was a problem producing the output") return prot.outputVol
def test2DAssess(self): print(magentaStr("\n==> Testing cryoassess - 2d assess:")) protAssess2D = self.newProtocol( CryoassessProt2D, inputAverages=self.protImportAvgs.outputAverages) self.launchProtocol(protAssess2D) avgSet = getattr(protAssess2D, 'outputAverages', None) self.assertIsNotNone(avgSet)
def importVolume(self): print(magentaStr("\n==> Importing data - volume:")) protVol = self.newProtocol(ProtImportVolumes, objLabel='import volume', filesPath=self.volFn, samplingRate=3) self.launchProtocol(protVol) return protVol
def setUpClass(cls): setupTestProject(cls) cls.setData() print(magentaStr("\n==> Importing data - movies:")) cls.protImport1 = cls.runImportMovies( cls.ds.getFile('qbeta/qbeta.mrc'), magnification=50000) cls.protImport2 = cls.runImportMovies(cls.ds.getFile('cct/cct_1.em'), magnification=61000)
def runPreprocess(cls, particles): print(magentaStr("\n==> Testing cryoDRGN - preprocess:")) protPreprocess = cls.newProtocol(CryoDrgnProtPreprocess, scaleSize=64) protPreprocess._createFilenameTemplates() protPreprocess.inputParticles.set(particles) cls.launchProtocol(protPreprocess) return protPreprocess
def test_CtfAutoEman(self): print(magentaStr("\n==> Testing eman2 - ctf auto:")) protCtf = self.newProtocol(EmanProtCTFAuto, numberOfThreads=3) protCtf.inputParticles.set(self.protImport.outputParticles) self.launchProtocol(protCtf) self.assertIsNotNone( protCtf.outputParticles_flip_fullRes, "There was a problem with eman ctf auto protocol")
def runImportMask(cls, pattern, samplingRate): """ Run an Import volumes protocol. """ print(magentaStr("\n==> Importing data - mask:")) cls.protImport = cls.newProtocol(ProtImportMask, maskPath=pattern, samplingRate=samplingRate) cls.launchProtocol(cls.protImport) return cls.protImport
def setUpClass(cls): """Prepare the data that we will use later on.""" print "\n", greenStr(" Set Up - Collect data ".center(75, '-')) setupTestProject(cls) # defined in BaseTest, creates cls.proj cls.dataset_xmipp = DataSet.getDataSet('xmipp_tutorial') cls.dataset_mda = DataSet.getDataSet('mda') cls.dataset_ribo = DataSet.getDataSet('ribo_movies') # # Imports # new = cls.proj.newProtocol # short notation launch = cls.proj.launchProtocol # Micrographs print magentaStr("\n==> Importing data - micrographs") p_imp_micros = new(ProtImportMicrographs, filesPath=cls.dataset_xmipp.getFile('allMics'), samplingRate=1.237, voltage=300) launch(p_imp_micros, wait=True) cls.micros = p_imp_micros.outputMicrographs # Volumes print magentaStr("\n==> Importing data - volumes") p_imp_volumes = new(ProtImportVolumes, filesPath=cls.dataset_xmipp.getFile('volumes'), samplingRate=9.896) launch(p_imp_volumes, wait=True) cls.vols = p_imp_volumes.outputVolumes # Movies print magentaStr("\n==> Importing data - movies") p_imp_movies = new(ProtImportMovies, filesPath=cls.dataset_ribo.getFile('movies'), samplingRate=2.37, magnification=59000, voltage=300, sphericalAberration=2.0) launch(p_imp_movies, wait=True) cls.movies = p_imp_movies.outputMovies # Particles print magentaStr("\n==> Importing data - particles") p_imp_particles = new(ProtImportParticles, filesPath=cls.dataset_mda.getFile('particles'), samplingRate=3.5) launch(p_imp_particles, wait=True) cls.particles = p_imp_particles.outputParticles
def launchTest(label, vol, ref, mask=None, mpi=4): print magentaStr("\nTest %s:" % label) pLocScale = self.proj.newProtocol(ProtLocScale, objLabel='locscale - ' + label, inputVolume=vol, refObj=ref, patchSize=16, binaryMask=mask, numberOfMpi=mpi) self.proj.launchProtocol(pLocScale, wait=True) self.assertIsNotNone(pLocScale.outputVolume, "outputVolume is None for %s test." % label) self.assertEqual(self.inputVol.getDim(), pLocScale.outputVolume.getDim(), "outputVolume has diferent size than inputVol " "for %s test" % label) self.assertEqual(self.inputVol.getSamplingRate(), pLocScale.outputVolume.getSamplingRate(), "outputVolume has diferent sampling rate than " "inputVol for %s test" % label)
def setUpClass(cls): setupTestProject(cls) cls.dataSet = DataSet.getDataSet('xmipp_tutorial') # # Imports # print magentaStr("\n==> Importing data - Input data") new = cls.proj.newProtocol # short notation launch = cls.proj.launchProtocol # Volumes print magentaStr("\nImporting Volumes:") pImpVolume = new(ProtImportVolumes, samplingRate=1, filesPath=cls.dataSet.getFile('vol2')) launch(pImpVolume, wait=True) # volume.vol cls.inputVol = pImpVolume.outputVolume pImpVolume2 = new(ProtImportVolumes, samplingRate=1, filesPath=cls.dataSet.getFile('vol1')) launch(pImpVolume2, wait=True) cls.inputVol2 = pImpVolume2.outputVolume # References print magentaStr("\nImporting References:") pImpRef = new(ProtImportVolumes, samplingRate=1, filesPath=cls.dataSet.getFile('vol3')) launch(pImpRef, wait=True) # reference.vol cls.inputRef = pImpRef.outputVolume pImpRef2 = new(ProtImportVolumes, samplingRate=1, filesPath=cls.dataSet.getFile('vol1')) launch(pImpRef2, wait=True) cls.inputRef2 = pImpRef2.outputVolume # Masks print magentaStr("\nImporting Mask:") pImpMask = new(ProtImportMask, maskPath=cls.dataSet.getFile('mask3d'), samplingRate=1) launch(pImpMask, wait=True) cls.mask = pImpMask.outputMask