def importCTF(self, mic, fileName): ctf = CTFModel() ctf.setMicrograph(mic) readCtfModel(ctf, fileName, ctf4=ctffindOutputVersion(fileName) == 4) for suffix in ["_psd.mrc", ".mrc"]: if os.path.exists(pwutils.removeExt(fileName) + suffix): ctf.setPsdFile(pwutils.removeExt(fileName) + suffix) return ctf
def importCTF(self, mic, fileName): defocusU, defocusV, defocusAngle = parseCtffindOutput(fileName) ctf = CTFModel() ctf.copyObjId(mic) ctf.setStandardDefocus(defocusU, defocusV, defocusAngle) ctf.setMicrograph(mic) ctf.setPsdFile(removeExt(fileName) + "_psd.mrc") return ctf
def importCTF(self, mic, fileName): ctf = CTFModel() ctf.setMicrograph(mic) readCtfModel(ctf, fileName, ctf4=ctffindOutputVersion(fileName) == 4) # Try to find the given PSD file associated with the cttfind log file # we handle special cases of .ctf extension and _ctffindX prefix for Relion runs fnBase = pwutils.removeExt(fileName) for suffix in ["_psd.mrc", ".mrc", ".ctf"]: psdPrefixes = [fnBase, fnBase.replace("_ctffind3", ""), fnBase.replace("_ctffind4", "")] for prefix in psdPrefixes: psdFile = prefix + suffix if os.path.exists(psdFile): if psdFile.endswith(".ctf"): psdFile += ":mrc" ctf.setPsdFile(psdFile) return ctf
def importCTF(self, mic, fileName): ctf = CTFModel() ctf.setMicrograph(mic) readCtfModel(ctf, fileName, ctf4=False) # Try to find the given PSD file associated with the cttfind log file # we handle special cases of .ctf extension and _ctffindX prefix for Relion runs fnBase = pwutils.removeExt(fileName) for suffix in ['_psd.mrc', '.mrc', '.ctf']: psdPrefixes = [fnBase, fnBase.replace('_ctffind3', ''), fnBase.replace('_gctf', '')] for prefix in psdPrefixes: psdFile = prefix + suffix if os.path.exists(psdFile): if psdFile.endswith('.ctf'): psdFile += ':mrc' ctf.setPsdFile(psdFile) return ctf
def importCTF(self, mic, fileName): ctf = CTFModel() ctf.setMicrograph(mic) readCtfModel(ctf, fileName, ctf4=False) # Try to find the given PSD file associated with the cttfind log file # we handle special cases of .ctf extension and _ctffindX prefix for Relion runs fnBase = pwutils.removeExt(fileName) for suffix in ['_psd.mrc', '.mrc', '.ctf']: psdPrefixes = [ fnBase, fnBase.replace('_ctffind3', ''), fnBase.replace('_gctf', '') ] for prefix in psdPrefixes: psdFile = prefix + suffix if os.path.exists(psdFile): if psdFile.endswith('.ctf'): psdFile += ':mrc' ctf.setPsdFile(psdFile) return ctf
def importCtfStep(self, micsId, pattern): """ Copy movies matching the filename pattern Register other parameters. """ inputMics = self.inputMicrographs.get() ctfSet = self._createSetOfCTF() ctfSet.setMicrographs(inputMics) ctfFiles = self._getFilePaths(pattern) ctfDict = {} for fn in ctfFiles: # Try to match the micrograph id from filename # this is set by the user by using #### format in the pattern match = self._idRegex.match(fn) if match is None: raise Exception("File '%s' doesn't match the pattern '%s'" % (fn, self.pattern.get())) ctfId = int(match.group(1)) ctfDict[ctfId] = fn from pyworkflow.em.packages.grigoriefflab.convert import parseCtffindOutput for mic in inputMics: if mic.getObjId() in ctfDict: defocusU, defocusV, defocusAngle = parseCtffindOutput( ctfDict[mic.getObjId()]) else: self.warning("CTF for micrograph id %d was not found." % mic.getObjId()) defocusU, defocusV, defocusAngle = -999, -1, -999 # save the values of defocus for each micrograph in a list ctf = CTFModel() ctf.copyObjId(mic) ctf.setStandardDefocus(defocusU, defocusV, defocusAngle) ctf.setMicrograph(mic) ctfSet.append(ctf) self._defineOutputs(outputCTF=ctfSet) self._defineCtfRelation(inputMics, ctfSet)
def importCtfStep(self, micsId, pattern): """ Copy movies matching the filename pattern Register other parameters. """ inputMics = self.inputMicrographs.get() ctfSet = self._createSetOfCTF() ctfSet.setMicrographs(inputMics) ctfFiles = self._getFilePaths(pattern) ctfDict = {} for fn in ctfFiles: # Try to match the micrograph id from filename # this is set by the user by using #### format in the pattern match = self._idRegex.match(fn) if match is None: raise Exception("File '%s' doesn't match the pattern '%s'" % (fn, self.pattern.get())) ctfId = int(match.group(1)) ctfDict[ctfId] = fn from pyworkflow.em.packages.grigoriefflab.convert import parseCtffindOutput for mic in inputMics: if mic.getObjId() in ctfDict: defocusU, defocusV, defocusAngle = parseCtffindOutput(ctfDict[mic.getObjId()]) else: self.warning("CTF for micrograph id %d was not found." % mic.getObjId()) defocusU, defocusV, defocusAngle = -999, -1, -999 # save the values of defocus for each micrograph in a list ctf = CTFModel() ctf.copyObjId(mic) ctf.setStandardDefocus(defocusU, defocusV, defocusAngle) ctf.setMicrograph(mic) ctfSet.append(ctf) self._defineOutputs(outputCTF=ctfSet) self._defineCtfRelation(inputMics, ctfSet)
def importCTF(self, mic, fileName): ctf = CTFModel() ctf.setMicrograph(mic) readCTFModel(ctf, fileName) return ctf