def createRefmacOutputStep(self): pdb = AtomStruct() pdb.setFileName(self._getOutPdbFileName(self.OutPdbFileName)) self._defineOutputs(outputPdb=pdb) self._defineSourceRelation(self.inputStructure, self.outputPdb) fnVol = self._getInputVolume() self._defineSourceRelation(fnVol, self.outputPdb)
def createOutput(self): """ Copy the PDB structure and register the output object. """ # Check vol and pdb files directory = self._getExtraPath() for filename in sorted(os.listdir(directory)): if not filename.startswith("tmp"): # files starting with "tmp" will not be converted in scipion objects if filename.endswith(".mrc"): volFileName = os.path.join(directory, filename) vol = Volume() vol.setFileName(volFileName) # fix mrc header ccp4header = Ccp4Header(volFileName, readHeader=True) sampling = ccp4header.computeSampling() origin = Transform() shifts = ccp4header.getOrigin() origin.setShiftsTuple(shifts) vol.setOrigin(origin) vol.setSamplingRate(sampling) keyword = filename.split(".mrc")[0] kwargs = {keyword: vol} self._defineOutputs(**kwargs) if filename.endswith(".pdb") or filename.endswith(".cif"): path = os.path.join(directory, filename) pdb = AtomStruct() pdb.setFileName(path) if filename.endswith(".cif"): keyword = filename.split(".cif")[0].replace(".", "_") else: keyword = filename.split(".pdb")[0].replace(".", "_") kwargs = {keyword: pdb} self._defineOutputs(**kwargs)
def createOutput(self): # Check vol and pdb files directory = self._getExtraPath() for filename in sorted(os.listdir(directory)): if filename.endswith(".mrc"): volFileName = os.path.join(directory, filename) vol = Volume() vol.setFileName(volFileName) # fix mrc header ccp4header = Ccp4Header(volFileName, readHeader=True) sampling = ccp4header.computeSampling() origin = Transform() shifts = ccp4header.getOrigin() origin.setShiftsTuple(shifts) vol.setOrigin(origin) vol.setSamplingRate(sampling) keyword = filename.split(".mrc")[0] kwargs = {keyword: vol} self._defineOutputs(**kwargs) elif filename.endswith(".pdb") or filename.endswith(".cif"): path = os.path.join(directory, filename) pdb = AtomStruct() pdb.setFileName(path) keyword = filename.split(".pdb")[0].replace(".","_") kwargs = {keyword: pdb} self._defineOutputs(**kwargs)
def createOutputStep(self): """ Copy the PDB structure and register the output object. """ # Check vol and pdb files directory = self._getExtraPath() for filename in sorted(os.listdir(directory)): if filename.endswith(".mrc"): volFileName = os.path.join(directory, filename) vol = Volume() vol.setFileName(volFileName) # fix mrc header ccp4header = Ccp4Header(volFileName, readHeader=True) sampling = ccp4header.computeSampling() origin = Transform() shifts = ccp4header.getOrigin() origin.setShiftsTuple(shifts) vol.setOrigin(origin) vol.setSamplingRate(sampling) keyword = filename.split(".mrc")[0] kwargs = {keyword: vol} self._defineOutputs(**kwargs) if filename.endswith(".pdb") or filename.endswith(".cif"): path = os.path.join(directory, filename) pdb = AtomStruct() pdb.setFileName(path) if filename.endswith(".cif"): keyword = filename.split(".cif")[0].replace(".", "_") else: keyword = filename.split(".pdb")[0].replace(".", "_") kwargs = {keyword: pdb} self._defineOutputs(**kwargs) # upodate config file flag enablebundle # so scipionwrite is disabled config = configparser.ConfigParser() config.read(self._getExtraPath(CHIMERA_CONFIG_FILE)) config.set('chimerax', 'enablebundle', 'False') with open(self._getExtraPath(CHIMERA_CONFIG_FILE), 'w') as configfile: config.write(configfile)
def createOutputStep(self): self._getDockInMapOutput() pdb = AtomStruct() pdb.setFileName(relpath(self.outAtomStructName)) if self.inputVolume1.get() is not None: pdb.setVolume(self.inputVolume1.get()) else: pdb.setVolume(self.inputStructure.get().getVolume()) self._defineOutputs(outputPdb=pdb) self._defineSourceRelation(self.inputStructure.get(), pdb) if self.inputVolume1.get() is not None: self._defineSourceRelation(self.inputVolume1.get(), pdb)
def createOutputStep(self): # viewer: extract cc from database and plot it # make 5 pdbs with higher score available to scipion conn = sqlite3.connect(os.path.abspath(self._getExtraPath(DATAFILE))) c = conn.cursor() sqlCommand = """SELECT filename, model_to_map_fit, phenix_id FROM %s ORDER BY model_to_map_fit DESC LIMIT 5""" % TABLE c.execute(sqlCommand) rows = c.fetchall() argsOutput = {} for counter, row in enumerate(rows): atomStructFn = row[0][:-4] + "_real_space_refined%s.log" % row[2] atomStruct = AtomStruct() atomStruct.setFileName(atomStructFn) argsOutput["outputAtomStruct_%d" % counter] = atomStruct c.close() conn.close() self._defineOutputs(**argsOutput)
def createOutputStep(self, outFileName, twoRelations=False, suffix=''): outFileName = os.path.abspath(outFileName) fnCmd = self._getExtraPath("chimera_output.cxc") f = open(fnCmd, 'a+') f.write("open %s\n" % outFileName) f.close() pdb = AtomStruct() pdb.setFileName(outFileName) # MM: to get appropriate cif files to be visualize with Chimera # Transform the output cif file in mmcif log = self._log fromCIFTommCIF(outFileName, outFileName, log) if suffix == "": self._defineOutputs(outputPdb=pdb) else: outputDict = {'outputPdb_chain%s' % suffix: pdb} self._defineOutputs(**outputDict) self._defineSourceRelation(self.pdbFileToBeRefined, pdb) if twoRelations: self._defineSourceRelation(self.InputAtomStruct2, pdb)
def createOutputStep(self, targetSym, targetAtomStructFn): """ save new atomic structure""" pdb = AtomStruct() pdb.setFileName(targetAtomStructFn) # MM: to get appropriate cif files to be visualize with Chimera # Transform the output cif file in mmcif log = self._log fromCIFTommCIF(pdb.getFileName(), pdb.getFileName(), log) self._defineOutputs(rotatedAtomStruct=pdb) self._defineSourceRelation(self.pdbFileToBeRefined, pdb)
def createOutputStep(self): # self._getRSRefineOutput() pdb = AtomStruct() pdb.setFileName(self.outAtomStructName) if self.inputVolume.get() is not None: pdb.setVolume(self.inputVolume.get()) else: pdb.setVolume(self.inputStructure.get().getVolume()) self._defineOutputs(outputPdb=pdb) self._defineSourceRelation(self.inputStructure.get(), pdb) if self.inputVolume.get() is not None: self._defineSourceRelation(self.inputVolume.get(), pdb) if Plugin.getPhenixVersion() == PHENIXVERSION: MOLPROBITYOUTFILENAME = self._getExtraPath( self.MOLPROBITYOUTFILENAME) self._parseFile(MOLPROBITYOUTFILENAME) else: VALIDATIONCRYOEMPKLFILENAME = self._getExtraPath( self.VALIDATIONCRYOEMPKLFILE) self._readValidationPklFile(VALIDATIONCRYOEMPKLFILENAME) self._store()
def createOutputStep(self): fnPdb = os.path.basename(self.inputStructureMoving.get().getFileName()) fnPdb = fnPdb.split('.')[0] for file in os.listdir(self._getExtraPath()): if file.endswith('_fitted.pdb'): os.rename(self._getExtraPath() + "/" + file, self._getExtraPath() + "/" + fnPdb + "_fitted.pdb") pdb = AtomStruct() pdb.setFileName(self._getExtraPath(fnPdb + "_fitted.pdb")) if self.inputStructureFixed.get().getVolume() is not None: pdb.setVolume(self.inputStructureFixed.get().getVolume()) self._defineOutputs(outputPdb=pdb) self._defineSourceRelation(self.inputStructureFixed.get(), pdb) self._defineSourceRelation(self.inputStructureMoving.get(), pdb) logFile = os.path.abspath(self._getLogsPath()) + "/run.stdout" self._parseLogFile(logFile) self._store()
def createOutputStep(self): inputVol = self.inputStructure.get() samplingRate = inputVol.getSamplingRate() volume = Volume() volume.setFileName(self._getExtraPath("pseudoatoms_approximation.vol")) volume.setSamplingRate(samplingRate) x, y, z = volume.getDim() xv, yv, zv = inputVol.getOrigin(force=True).getShifts() t = Transform() t.setShifts((x / 2. * samplingRate) - xv, (y / 2. * samplingRate) - yv, (z / 2. * samplingRate) - zv) volume.setOrigin(inputVol.getOrigin()) self._defineOutputs(outputVolume=volume) self._defineSourceRelation(self.inputStructure.get(), volume) pdb = AtomStruct(self._getPath('pseudoatoms.pdb'), pseudoatoms=True) pdb.setVolume(volume) pdb.setOrigin(t) self.createChimeraScript(inputVol, pdb) self._defineOutputs(outputPdb=pdb) self._defineSourceRelation(self.inputStructure, pdb)
def createOutputStep(self): outFile = pwutils.removeBaseExt( self.inputPDB.get().getFileName()) + '_deformed.pdb' pdb = AtomStruct(self._getExtraPath(outFile)) self._defineOutputs(outputPDB=pdb) self._defineSourceRelation(self.inputPDB, pdb)
def createOutput(self): """ Copy the PDB structure and register the output object. """ databasePath = self._getExtraPath(OUTPUTDATABASENAMESWITHLABELS) getModels(databasePath, DATABASETABLENAME) # open database conn = sqlite3.connect(databasePath) if not _checkTableExists(conn, DATABASETABLENAME): conn.close() return c = conn.cursor() # read atom struct filename and label in a loop c.execute('SELECT fileName, labelName ' 'FROM %s ' 'WHERE saved = 0 AND type=%d' % (DATABASETABLENAME, TYPE_ATOMSTRUCT)) for row in c: pdbFileName = row[0] pdbLabelName = row[1] pdb = AtomStruct() pdb.setFileName(pdbFileName) outputs = {str(pdbLabelName): pdb} self._defineOutputs(**outputs) self._defineSourceRelation(self.inputPdbFiles, pdb) # files has been saved sql = 'UPDATE %s SET saved = 1 WHERE saved=0 ' \ 'AND type=%d' % (DATABASETABLENAME, TYPE_ATOMSTRUCT) c.execute(sql) # check if normalized files are saved sql = "SELECT count(*) " \ "FROM %s " \ "WHERE saved = 0 " \ " AND type = %d LIMIT 1" % (DATABASETABLENAME, TYPE_3DMAP) c.execute(sql) result = c.fetchone()[0] # update saved parameter if result > 0: sql = 'UPDATE %s SET saved = 1 WHERE saved=0 ' \ 'AND type=%d' % (DATABASETABLENAME, TYPE_3DMAP) c.execute(sql) conn.commit() conn.close() # save normalized vols... if result > 0: inVolumes, norVolumesNames = self._getVolumesList() counter = 1 for inVol, norVolName in zip(inVolumes, norVolumesNames): outVol = Volume() sampling = inVol.getSamplingRate() origin = inVol.getOrigin(force=True) outVol.setSamplingRate(sampling) outVol.setOrigin(origin) if norVolName.endswith('.mrc'): norVolName = norVolName + ":mrc" outFileName = self._getVolumeFileName(norVolName) outVol.setFileName(outFileName) outputs = {"output3DMap_%04d" % counter: outVol} counter += 1 self._defineOutputs(**outputs) self._defineSourceRelation(inVol, outVol) else: print("skip save normalized vol") if os.path.isfile(self._getExtraPath('STOPPROTCOL')): self.setStatus(STATUS_FINISHED) # NOTE: (ROB) can a dirty way to make an interactive process finish but I do not # think there is a clean one self._steps[self.step - 1].setInteractive(False)