Exemple #1
0
    def runValidationCryoEMStep(self):
        version = Plugin.getPhenixVersion()
        if version == '1.13':
            print("PHENIX version: 1.13")
        else:
            print("PHENIX version: ", version)

        fileName = self.inputStructure.get().getFileName()
        atomStruct = os.path.abspath(fileName)

        # starting volume (.mrc)
        if self.vol is not None:
            tmpMapFile = self.VALIDATIONCRYOEMFILE
            volume = os.path.abspath(self._getExtraPath(tmpMapFile))
        else:
            volume = None

        # MolProbity is run to get the file molprobity.out
        # (necessary to get geometry outliers)
        numberOfThreads = self.numberOfThreads.get()

        args = self._writeArgsMolProbity(atomStruct, vol=volume)
        cwd = os.getcwd() + "/" + self._getExtraPath()
        # script with auxiliary files
        retry(Plugin.runPhenixProgram, Plugin.getProgram(MOLPROBITY),
              args, cwd=cwd, listAtomStruct=[atomStruct], log=self._log)

        args = self._writeArgsValCryoEM(atomStruct, volume, self.vol)

        if Plugin.getPhenixVersion() != PHENIXVERSION and self.vol is not None:
            retry(Plugin.runPhenixProgram, Plugin.getProgram(VALIDATION_CRYOEM),
                  args, cwd=cwd, listAtomStruct=[atomStruct], log=self._log)
    def _validate(self):
        errors = []
        # Check that the program exists
        program = Plugin.getProgram(EMRINGER)
        if program is None:
            errors.append("Missing variables EMRINGER and/or PHENIX_HOME")
        elif not os.path.exists(program):
            errors.append("Binary '%s' does not exists.\n" % program)
        elif not self.is_tool(DISPLAY):
            errors.append("display program missing.\n "
                          "Please install imagemagick package")

        # If there is any error at this point it is related to config variables
        if errors:
            errors.append("Check configuration file: " +
                          Config.SCIPION_LOCAL_CONFIG)
            errors.append("and set EMRINGER and PHENIX_HOME variables "
                          "properly.")
            if program is not None:
                errors.append("Current values:")
                errors.append("PHENIX_HOME = %s" % Plugin.getVar(PHENIX_HOME))
                errors.append("EMRINGER = %s" % EMRINGER)

        # Check that the input volume exist
        if self._getInputVolume() is None:
            errors.append("Error: You should provide a volume.\n")

        return errors
Exemple #3
0
 def runMolprobityStep(self):
     version = Plugin.getPhenixVersion()
     if version == '1.13':
         print("PHENIX version: 1.13")
     else:
         print(("PHENIX version: ", version))
     # PDBx/mmCIF
     fileName = self.inputStructure.get().getFileName()
     # self.atomStruct = os.path.abspath(fileName)
     self.atomStruct = os.getcwd() + "/" + fileName
     # starting volume (.mrc)
     if (self.inputVolume.get() or self.inputStructure.get().getVolume()) \
             is not None:
         tmpMapFile = self.MOLPROBITYFILE
         # self.vol = os.path.abspath(self._getExtraPath(tmpMapFile))
         self.vol = os.getcwd() + "/" + self._getExtraPath(tmpMapFile)
         args = self._writeArgsMolProbityExpand(self.atomStruct, self.vol)
     else:
         args = self._writeArgsMolProbityExpand(self.atomStruct, vol=None)
     # script with auxiliary files
     retry(
         Plugin.runPhenixProgram,
         Plugin.getProgram(MOLPROBITY),
         # args, cwd=os.path.abspath(self._getExtraPath()),
         args,
         cwd=self._getExtraPath(),
         listAtomStruct=[self.atomStruct],
         log=self._log)
    def runRSrefineStep(self, tmpMapFile):
        atomStruct = os.path.abspath(self.inputStructure.get().getFileName())
        vol = os.path.abspath(self._getExtraPath(tmpMapFile))
        args = self._writeArgsRSR(atomStruct, vol)
        cwd = os.getcwd() + "/" + self._getExtraPath()

        retry(
            Plugin.runPhenixProgram,
            Plugin.getProgram(REALSPACEREFINE),
            args,
            # cwd=os.path.abspath(self._getExtraPath()),
            cwd=cwd,
            listAtomStruct=[atomStruct],
            log=self._log)
        self.refinedFile = False
        for item in os.listdir(self._getExtraPath()):
            p = re.compile('\d+')
            if p.search(item) is not None and item.endswith(".cif"):
                self.refinedFile = True
                break

        if self.refinedFile == False:
            print("WARNING!!!\nPHENIX error:\n pdb_interpretation.clash_guard" \
                  " failure: High number of nonbonded interaction distances " \
                  "< 0.5. This error has been disable by running the same " \
                  "command with the same following additional " \
                  "argument:\npdb_interpretation.clash_guard." \
                  "nonbonded_distance_threshold=None ")
            args += " pdb_interpretation.clash_guard." \
                    "nonbonded_distance_threshold=None"
            retry(
                Plugin.runPhenixProgram,
                Plugin.getProgram(REALSPACEREFINE),
                args,
                # cwd=os.path.abspath(self._getExtraPath()),
                cwd=cwd,
                listAtomStruct=[atomStruct],
                log=self._log)
Exemple #5
0
 def runSuperposePDBsStep(self):
     args = os.path.abspath(self.inputStructureFixed.get().getFileName())
     args += " "
     args += os.path.abspath(self.inputStructureMoving.get().getFileName())
     cwd = os.getcwd() + "/" + self._getExtraPath()
     try:
         Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE), args,
                                 extraEnvDict=None, cwd=cwd)
     except:
         # This exception will run when using phenix v. 1.16 after running
         # real space refine the .cif file generated can not be recognized by
         # superpose pdbs program and an error is produced
         list_args = args.split()
         self._runChangingCifFormatSuperpose(list_args)
 def runMolprobityStep(self, tmpMapFile):
     # PDBx/mmCIF
     self._getRSRefineOutput()
     atomStruct = os.path.abspath(self.outAtomStructName)
     # starting volume (.mrc)
     vol = os.path.abspath(self._getExtraPath(tmpMapFile))
     args = self._writeArgsMolProbity(atomStruct, vol)
     cwd = os.getcwd() + "/" + self._getExtraPath()
     retry(
         Plugin.runPhenixProgram,
         Plugin.getProgram(MOLPROBITY2),
         # args, cwd=os.path.abspath(self._getExtraPath()),
         args,
         cwd=cwd,
         listAtomStruct=[atomStruct],
         log=self._log)
Exemple #7
0
    def _validate(self):
        errors = []
        # Check that the program exists
        program = Plugin.getProgram(SUPERPOSE)
        if not os.path.exists(program):
            errors.append("Cannot find " + program)

            # If there is any error at this point it is related to config variables
            errors.append("Check configuration file: " +
                          Config.SCIPION_LOCAL_CONFIG)
            errors.append("and set PHENIX_HOME variables properly.")
            if program is not None:
                errors.append("Current values:")
                errors.append("PHENIX_HOME = %s" % Plugin.getVar(PHENIX_HOME))
                errors.append("SUPERPOSE = %s" % SUPERPOSE)

        return errors
 def runDockInMapStep(self):
     # starting structure
     atomStructFileName = self.inputStructure.get().getFileName()
     atomStruct = os.getcwd() + "/" + atomStructFileName
     # starting map (.mrc)
     mapFile = self.DOCKINMAPFILE
     vol = os.getcwd() + "/" + self._getExtraPath(mapFile)
     args = self._writeArgsDocKInMap(vol, atomStruct)
     cwd = os.getcwd() + "/" + self._getExtraPath()
     retry(
         Plugin.runPhenixProgram,
         Plugin.getProgram(DOCKINMAP),
         # args, cwd=os.path.abspath(self._getExtraPath()),
         args,
         cwd=cwd,
         listAtomStruct=[atomStruct],
         log=self._log)
    def runValidationCryoEMStep(self, tmpMapFile):
        # PDBx/mmCIF
        atomStruct = os.path.abspath(self.outAtomStructName)
        # starting volume (.mrc)
        volume = os.path.abspath(self._getExtraPath(tmpMapFile))
        if self.inputVolume.get() is not None:
            vol = self.inputVolume.get()
        else:
            vol = self.inputStructure.get().getVolume()

        args = self._writeArgsValCryoEM(atomStruct, volume, vol)
        cwd = os.getcwd() + "/" + self._getExtraPath()
        retry(
            Plugin.runPhenixProgram,
            Plugin.getProgram(VALIDATION_CRYOEM),
            # args, cwd=os.path.abspath(self._getExtraPath()),
            args,
            cwd=cwd,
            listAtomStruct=[atomStruct],
            log=self._log)
 def runEMRingerStep(self):
     inPDBAtomStructFile = self.inputStructure.get().getFileName()
     # atomStruct = os.path.abspath(inPDBAtomStructFile)
     if not inPDBAtomStructFile == os.path.abspath(inPDBAtomStructFile):
         atomStruct = os.getcwd() + "/" + inPDBAtomStructFile
     else:
         atomStruct = inPDBAtomStructFile
     # vol = os.path.abspath(self._getExtraPath(self.EMRINGERFILE))
     vol = os.getcwd() + "/" + self._getExtraPath(self.EMRINGERFILE)
     args = self._writeArgsEMRinger(atomStruct, vol)
     # script with auxiliary files
     import sys
     sys.stdout.flush()
     # import time
     # time.sleep(30)
     retry(
         Plugin.runPhenixProgram,
         Plugin.getProgram(EMRINGER),
         # args, cwd=os.path.abspath(self._getExtraPath()),
         args,
         cwd=self._getExtraPath(),
         listAtomStruct=[atomStruct],
         log=self._log)
Exemple #11
0
 def createOutputStep(self):
     MOLPROBITYOUTFILENAME = self._getExtraPath(self.MOLPROBITYOUTFILENAME)
     try:
         self._parseFile(MOLPROBITYOUTFILENAME)
     except:
         if self.MOLPROBITYFILE is not None:
             # self.vol = os.path.abspath(self._getExtraPath(self.MOLPROBITYFILE))
             self.vol = self._getExtraPath(self.MOLPROBITYFILE)
             args = self._writeArgsMolProbityExpand(self.atomStruct,
                                                    self.vol)
         else:
             args = self._writeArgsMolProbityExpand(self.atomStruct,
                                                    vol=None)
         args += " allow_polymer_cross_special_position=True "
         retry(
             Plugin.runPhenixProgram,
             Plugin.getProgram(MOLPROBITY),
             # args, cwd=os.path.abspath(self._getExtraPath()),
             args,
             cwd=self._getExtraPath(),
             listAtomStruct=[self.atomStruct],
             log=self._log)
         self._parseFile(MOLPROBITYOUTFILENAME)
     self._store()
    def validateBase(self, program, label):
        errors = []
        # Check that the program exists
        program = Plugin.getProgram(program)
        if program is None:
            errors.append("Missing variables %s and/or PHENIX_HOME" % label)
        elif not os.path.exists(program):
            errors.append("Binary '%s' does not exists.\n" % program)
            errors.append("Check if you need to upgrade your PHENIX version"
                          " to run %s.\nYour current PHENIX version is %s.\n" %
                          (label, PHENIXVERSION))

        # If there is any error at this point it is related to config variables
        if errors:
            errors.append("Check configuration file: " +
                          Config.SCIPION_LOCAL_CONFIG)
            errors.append("and set %s and PHENIX_HOME variables "
                          "properly." % label)
            if program is not None:
                errors.append("Current values:")
                errors.append("PHENIX_HOME = %s" % Plugin.getHome())
                #errors.append("%s = %s" % label, program)

        return errors
Exemple #13
0
 def _runChangingCifFormatSuperpose(self, list_args):
     cwd = os.getcwd() + "/" + self._getExtraPath()
     try:
         if list_args[0].endswith(".cif") and list_args[1].endswith(".cif"):
             try:
                 # upgrade cifs
                 list_args1 = []
                 for i in range(0, 2):
                     list_args1.append(fromCIFTommCIF(list_args[i], list_args[i]))
                 args1 = list_args1[0] + " " + list_args1[1]
                 Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE), args1,
                                         extraEnvDict=None, cwd=cwd)
             except:
                 # convert cifs to pdbs
                 list_args2 = []
                 for i in range(0, 2):
                     list_args2.append(fromCIFToPDB(
                         list_args[i], list_args[i].replace('.cif', '.pdb')))
                 args2 = list_args2[0] + " " + list_args2[1]
                 Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE), args2,
                                         extraEnvDict=None, cwd=cwd)
         elif list_args[0].endswith(".cif") and list_args[1].endswith(".pdb"):
             try:
                 # pdbs: convert cif to pdb
                 list_args1 = []
                 list_args1.append(fromCIFToPDB(
                     list_args[0], list_args[0].replace('.cif', '.pdb')))
                 args1 = list_args1[0] + " " + list_args[1]
                 Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE), args1,
                                         extraEnvDict=None, cwd=cwd)
             except:
                 try:
                     # cifs: convert pdb to cif
                     list_args2 = []
                     list_args2.append(fromPDBToCIF(
                         list_args[1], list_args[1].replace('.pdb', '.cif')))
                     args2 = list_args[0] + " " + list_args2[0]
                     Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE), args2,
                                             extraEnvDict=None, cwd=cwd)
                 except:
                     # upgrade cif
                     list_args3 = []
                     list_args0 = args2.split()
                     for i in range(0, 2):
                         list_args3[i].append(fromCIFTommCIF(
                             list_args0[i], list_args0[i]))
                     args3 = list_args3[0] + " " + list_args3[1]
                     Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE),
                                             args3, extraEnvDict=None, cwd=cwd)
         elif list_args[0].endswith(".pdb") and list_args[1].endswith(".cif"):
             try:
                 # pdbs: convert cif to pdb
                 list_args1 = []
                 list_args1.append(fromCIFToPDB(
                     list_args[1], list_args[1].replace('.cif', '.pdb')))
                 args1 = list_args[0] + " " + list_args1[0]
                 Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE), args1,
                                         extraEnvDict=None, cwd=cwd)
             except:
                 try:
                     # cifs: convert pdb to cif
                     list_args2 = []
                     list_args2.append(fromPDBToCIF(
                         list_args[0], list_args[0].replace('.pdb', '.cif')))
                     args2 = list_args2[0] + " " + list_args[1]
                     Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE), args2,
                                             extraEnvDict=None, cwd=cwd)
                 except:
                     # upgrade cifs
                     list_args3 = []
                     list_args0 = args2.split()
                     for i in range(0, 2):
                         list_args3.append(fromCIFTommCIF(
                             list_args0[i], list_args0[i]))
                     args3 = list_args3[0] + " " + list_args3[1]
                     Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE),
                                             args3, extraEnvDict=None, cwd=cwd)
     except:
         # biopython conversion
         aSH = AtomicStructHandler()
         try:
             for i in range(0, 2):
                 aSH.read(list_args[i])
                 aSH.write(list_args[i])
                 args = list_args[0] + " " + list_args[1]
                 Plugin.runPhenixProgram(Plugin.getProgram(SUPERPOSE),
                                         args, extraEnvDict=None, cwd=cwd)
         except:
             print("CIF file standarization failed.")
Exemple #14
0
    def refineStep2(self):
        # atomStruct = os.path.abspath(self.inputStructure.get().getFileName())
        ## vol = os.path.abspath(self._getInputVolume().getFileName())
        vol = os.path.abspath(self._getExtraPath(self.FITTEDFILE))
        cwd = os.getcwd() + "/" + self._getExtraPath()
        conn = sqlite3.connect(os.path.abspath(self._getExtraPath(DATAFILE)))
        c = conn.cursor()
        while 1:
            command = """SELECT filename from %s
                         WHERE done=0
                         LIMIT 1""" % TABLE
            c.execute(command)
            myrow = c.fetchone()
            if not myrow:
                print("refineStep: no more available works")
                break  # break while if no job is available

            atomStructFn, = myrow
            c.execute("""UPDATE %s
                            SET done=1
                          WHERE filename='%s' AND done=0""" %
                      (TABLE, atomStructFn))
            # ^^^^^^ This will return the number of rows updated (c.rowcount).
            # Note that we only update if done is still '0', so if we get 1 updated
            # row, we're sure no one else took our job. This works because UPDATE is atomic.

            if not c.rowcount:
                # Whoops this job was taken! Try again and get another one
                continue
            conn.commit()

            args = self._writeArgsRSR(atomStructFn, vol)
            retry(
                Plugin.runPhenixProgram,
                Plugin.getProgram(REALSPACEREFINE),
                args,
                # cwd=os.path.abspath(self._getExtraPath()),
                cwd=cwd,
                listAtomStruct=[atomStructFn],
                log=self._log)
            if Plugin.getPhenixVersion() >= PHENIXVERSION19:
                # update data base with phenix version
                logFileFn = atomStructFn[:-4] + "_real_space_refined_???.log"
                # last file
                lastLogFile = sorted(glob.glob(logFileFn))[-1]
                phenix_id = lastLogFile[-8:-4]  # _000
                c.execute("""UPDATE %s
                                SET phenix_id='%s'
                              WHERE filename='%s'""" %
                          (TABLE, phenix_id, atomStructFn))
            else:
                phenix_id = ''
            conn.commit()
            #            refinedFile = False
            #            for item in os.listdir(self._getExtraPath()):
            #                p = re.compile('\d+')
            #                if p.search(item) is not None and item.endswith(".cif"):
            #                    self.refinedFile = True
            #                    break
            #
            #            if self.refinedFile == False:
            #                print("WARNING!!!\nPHENIX error:\n pdb_interpretation.clash_guard" \
            #                      " failure: High number of nonbonded interaction distances " \
            #                      "< 0.5. This error has been disable by running the same " \
            #                      "command with the same following additional " \
            #                      "argument:\npdb_interpretation.clash_guard." \
            #                      "nonbonded_distance_threshold=None ")
            #                args += " "
            #                args += "pdb_interpretation.clash_guard." \
            #                        "nonbonded_distance_threshold=None"
            #                retry(Plugin.runPhenixProgram,
            #                      Plugin.getProgram(REALSPACEREFINE), args,
            #                      # cwd=os.path.abspath(self._getExtraPath()),
            #                      cwd=cwd,
            #                      listAtomStruct=[atomStructFn], log=self._log)
            # coot_000000_Imol_0000_version_0004_real_space_refined_001.eff
            # coot_000000_Imol_0000_version_0030.pdb
            # glob
            logFileFn = atomStructFn[:-4] + "_real_space_refined%s.log" % phenix_id
            model_to_map_fit = self.extractNumber(logFileFn)
            accepted = c.execute(
                """UPDATE %s
                                    SET model_to_map_fit=%f
                                    WHERE filename='%s'""" %
                (TABLE, float(model_to_map_fit), atomStructFn))
            conn.commit()
        c.close()
        conn.close()