def test_insertObjects(self): dbName = self.getOutputPath("images.sqlite") print ">>> test_insertObjects: dbName = '%s'" % dbName mapper = SqliteFlatMapper(dbName, globals()) n = 10 for i in range(n): img = Image() img.setLocation(i + 1, "images.stk") mapper.store(img) mapper.setProperty("samplingRate", "3.0") mapper.setProperty("defocusU", 1000) mapper.setProperty("defocusV", 1000) mapper.setProperty("defocusU", 2000) # Test update a property value mapper.deleteProperty("defocusV") # Test delete a property mapper.commit() mapper.close() # Test that values where stored properly mapper2 = SqliteFlatMapper(dbName, globals()) self.assertTrue(mapper2.hasProperty("samplingRate")) self.assertTrue(mapper2.hasProperty("defocusU")) self.assertFalse(mapper2.hasProperty("defocusV")) self.assertEqual(mapper2.getProperty("samplingRate"), "3.0") self.assertEqual(mapper2.getProperty("defocusU"), "2000")
def test_insertObjects(self): dbName = self.getOutputPath('images.sqlite') print ">>> test_insertObjects: dbName = '%s'" % dbName mapper = SqliteFlatMapper(dbName, globals()) n = 10 for i in range(n): img = Image() img.setLocation(i+1, 'images.stk') mapper.store(img) mapper.setProperty('samplingRate', '3.0') mapper.setProperty('defocusU', 1000) mapper.setProperty('defocusV', 1000) mapper.setProperty('defocusU', 2000) # Test update a property value mapper.deleteProperty('defocusV') # Test delete a property mapper.commit() self.assertEqual(1, mapper.db.getVersion()) mapper.close() # Test that values where stored properly mapper2 = SqliteFlatMapper(dbName, globals()) self.assertTrue(mapper2.hasProperty('samplingRate')) self.assertTrue(mapper2.hasProperty('defocusU')) self.assertFalse(mapper2.hasProperty('defocusV')) self.assertEqual(mapper2.getProperty('samplingRate'), '3.0') self.assertEqual(mapper2.getProperty('defocusU'), '2000')
def test_insertObjects(self): dbName = self.getOutputPath('images.sqlite') print ">>> test_insertObjects: dbName = '%s'" % dbName mapper = SqliteFlatMapper(dbName, globals()) n = 10 for i in range(n): img = Image() img.setLocation(i + 1, 'images.stk') mapper.store(img) mapper.setProperty('samplingRate', '3.0') mapper.setProperty('defocusU', 1000) mapper.setProperty('defocusV', 1000) mapper.setProperty('defocusU', 2000) # Test update a property value mapper.deleteProperty('defocusV') # Test delete a property mapper.commit() self.assertEqual(1, mapper.db.getVersion()) mapper.close() # Test that values where stored properly mapper2 = SqliteFlatMapper(dbName, globals()) self.assertTrue(mapper2.hasProperty('samplingRate')) self.assertTrue(mapper2.hasProperty('defocusU')) self.assertFalse(mapper2.hasProperty('defocusV')) self.assertEqual(mapper2.getProperty('samplingRate'), '3.0') self.assertEqual(mapper2.getProperty('defocusU'), '2000')
def __setXmippImage(label): attr = '_xmipp_' + xmipp.label2Str(label) if not hasattr(particle, attr): img = Image() setattr(particle, attr, img) img.setSamplingRate(particle.getSamplingRate()) else: img = getattr(particle, attr) img.setLocation(xmippToLocation(row.getValue(label)))
def _updateClass(self, item): classId = item.getObjId() classRow = findRow(self.mdClasses, xmipp.MDL_REF2, classId) representative = item.getRepresentative() representative.setTransform(rowToAlignment(classRow, ALIGN_PROJ)) representative.setLocation(xmippToLocation(classRow.getValue(xmipp.MDL_IMAGE))) setXmippAttributes(representative, classRow, xmipp.MDL_ANGLE_ROT) setXmippAttributes(representative, classRow, xmipp.MDL_ANGLE_TILT) setXmippAttributes(representative, classRow, xmipp.MDL_CLASS_COUNT) self.averageSet.append(representative) reprojection = Image() reprojection.setLocation(xmippToLocation(classRow.getValue(xmipp.MDL_IMAGE1))) item.reprojection = reprojection
def _updateClass(self, item): classId = item.getObjId() classRow = findRow(self.mdClasses, xmippLib.MDL_REF2, classId) representative = item.getRepresentative() representative.setTransform(rowToAlignment(classRow, ALIGN_PROJ)) representative.setLocation(xmippToLocation(classRow.getValue(xmippLib.MDL_IMAGE))) setXmippAttributes(representative, classRow, xmippLib.MDL_ANGLE_ROT) setXmippAttributes(representative, classRow, xmippLib.MDL_ANGLE_TILT) setXmippAttributes(representative, classRow, xmippLib.MDL_CLASS_COUNT) self.averageSet.append(representative) reprojection = Image() reprojection.setLocation(xmippToLocation(classRow.getValue(xmippLib.MDL_IMAGE1))) item.reprojection = reprojection
def createOutputStep(self): inputMics = self.inputMicrographs.get() outputMics = self._createSetOfMicrographs() outputMics.copyInfo(inputMics) for mic in inputMics: # Set the thumbnail image mic.thumbnail = Image(self._getOutputMicThumbnail(mic.getObjId())) outputMics.append(mic) self._defineOutputs(outputMicrographs=outputMics) self._defineTransformRelation(self.inputMicrographs, outputMics)
def createOutputStep(self): # Really load the input, since in the streaming case we can not # use the self.inputMovies directly allFramesSum = self._getPath('all_frames_sum.mrc') allFramesAvg = self._getPath('all_frames_avg.mrc') self._loadInputList() n = len(self.listOfMovies) ih = ImageHandler() sumImg = ih.read(allFramesSum) sumImg.inplaceDivide(float(n)) sumImg.write(allFramesAvg) outputAvg = Image() outputAvg.setFileName(allFramesAvg) outputAvg.setSamplingRate(self.listOfMovies[0].getSamplingRate()) self._defineOutputs(outputAverage=outputAvg) self._defineSourceRelation(self.inputMovies, outputAvg)
def test_insertObjects(self): dbName = self.getOutputPath('images.sqlite') print ">>> test_insertObjects: dbName = '%s'" % dbName mapper = SqliteFlatMapper(dbName, globals()) self.assertEqual(0, mapper.count()) self.assertEqual(0, mapper.maxId()) n = 10 for i in range(n): img = Image() img.setLocation(i + 1, 'images.stk') mapper.insert(img) self.assertEqual(n, mapper.count()) self.assertEqual(n, mapper.maxId()) # Store one more image with bigger id img = Image() bigId = 1000 img.setLocation(bigId, 'images.stk') img.setObjId(bigId) mapper.insert(img) self.assertEqual(bigId, mapper.maxId()) # Insert another image with None as id, it should take bigId + 1 img.setLocation(bigId + 1, 'images.stk') img.setObjId(None) mapper.insert(img) self.assertEqual(bigId + 1, mapper.maxId()) mapper.setProperty('samplingRate', '3.0') mapper.setProperty('defocusU', 1000) mapper.setProperty('defocusV', 1000) mapper.setProperty('defocusU', 2000) # Test update a property value mapper.deleteProperty('defocusV') # Test delete a property mapper.commit() self.assertEqual(1, mapper.db.getVersion()) mapper.close() # Test that values where stored properly mapper2 = SqliteFlatMapper(dbName, globals()) self.assertTrue(mapper2.hasProperty('samplingRate')) self.assertTrue(mapper2.hasProperty('defocusU')) self.assertFalse(mapper2.hasProperty('defocusV')) self.assertEqual(mapper2.getProperty('samplingRate'), '3.0') self.assertEqual(mapper2.getProperty('defocusU'), '2000') # Make sure that maxId() returns the proper value after loading db self.assertEqual(bigId + 1, mapper2.maxId())