def readPartsFromMics(self, micList, outputParts): """ Read the particles extract for the given list of micrographs and update the outputParts set with new items. """ relionToLocation = relion.convert.relionToLocation p = Particle() p._rlnOpticsGroup = Integer() acq = self.getInputMicrographs().getAcquisition() # JMRT: Ideally I would like to disable the whole Acquisition for each # particle row, but the SetOfImages will set it again. # Another option could be to disable in the set, but then in # streaming, other protocols might get the wrong optics info pAcq = Acquisition(magnification=acq.getMagnification(), voltage=acq.getVoltage(), amplitudeContrast=acq.getAmplitudeContrast(), sphericalAberration=acq.getSphericalAberration()) p.setAcquisition(pAcq) tmp = self._getTmpPath() extra = self._getExtraPath() for mic in micList: posSet = set() coordDict = {self._getPos(c): c for c in self.coordDict[mic.getObjId()]} del self.coordDict[mic.getObjId()] ogNumber = mic.getAttributeValue('_rlnOpticsGroup', 1) partsStar = self.__getMicFile(mic, '_extract.star', folder=tmp) partsTable = relion.convert.Table(fileName=partsStar) stackFile = self.__getMicFile(mic, '.mrcs', folder=tmp) endStackFile = self.__getMicFile(mic, '.mrcs', folder=extra) pwutils.moveFile(stackFile, endStackFile) for part in partsTable: pos = (int(float(part.rlnCoordinateX)), int(float(part.rlnCoordinateY))) if pos in posSet: print("Duplicate coordinate at: %s, IGNORED. " % str(pos)) coord = None else: coord = coordDict.get(pos, None) if coord is not None: # scale the coordinates according to particles dimension. coord.scale(self.getBoxScale()) p.copyObjId(coord) idx, fn = relionToLocation(part.rlnImageName) p.setLocation(idx, endStackFile) p.setCoordinate(coord) p.setMicId(mic.getObjId()) p.setCTF(mic.getCTF()) p._rlnOpticsGroup.set(ogNumber) outputParts.append(p) posSet.add(pos)
def particlesFactory(index): newParticle = Particle(location=(1, self.particlesStk)) newParticle.setCoordinate(Coordinate(x=1, y=2)) newParticle.setAcquisition(Acquisition()) return newParticle