Beispiel #1
0
 def _write_resfile(self):
     from protein.model.Protein import write_rosetta_resfile
     for chunk in self.win.assy.molecules:
         if chunk.isProteinChunk():
             write_rosetta_resfile("/Users/piotr/test.resfile", chunk)
             return
    def set_options_errQ(self): #e maybe split further into several setup methods? #bruce 051115 removed unused 'options' arg
        """
        Figure out and set filenames, including sim executable path.
        All inputs and outputs are self attrs or globals or other obj attrs...
        except, return error code if sim executable missing
        or on other errors detected by subrs.
        """
        part = self.part
        movie = self._movie
        
        # simFilesPath = "~/Nanorex/RosettaDesignFiles".
        simFilesPath = find_or_make_Nanorex_subdir('RosettaDesignFiles')

        # Create temporary part-specific filename, for example:
        # "partname-minimize-pid1000".
        # We'll be appending various extensions to tmp_file_prefix to make temp
        # file names for sim input and output files as needed (e.g. mmp, xyz,
        # etc.)
        
        pdbId, chunk = self.getPDBIDFromChunk(part)
        #write the residue file
        resFile = pdbId + ".resfile"
        resFilePath = os.path.join(simFilesPath, resFile)
        success = write_rosetta_resfile(resFilePath, chunk)
        if success:
            self.resFile = resFile
        else:
            print "Residue file could not be written"
        
        #remove all previously existing fasta files
        fastaFile = pdbId + "_out_design.fasta"
        checkPointFile = pdbId + "_out_design.checkpoint"
        checkPointPath = os.path.join(simFilesPath, checkPointFile)
        fastaFilePath = os.path.join(simFilesPath, fastaFile)
        if os.path.exists(fastaFilePath):
            os.remove(fastaFilePath)
        
        if os.path.exists(checkPointPath):
            os.remove(checkPointPath)
            
        if pdbId is None:
            basename = "Untitled"
        else:
            basename = pdbId
        timestampString = ""
        if (self.background):
            # Add a timestamp to the pid so that multiple backgrounded
            # calculations don't clobber each other's files.
            timestamp = datetime.today()
            timestampString = timestamp.strftime(".%y%m%d%H%M%S")
        self.tmp_file_prefix = \
            os.path.join(simFilesPath,
                         "%s-rosetta-design-pid%d%s" % (basename, os.getpid(),
                                                  timestampString))

        
        #get program path, database path and write path.txt
        self.program = self.getExecutablePluginPath()
        if self.program is None:
            msg = redmsg("The simulator program is missing.  Simulation aborted.")
            env.history.message(self.cmdname + ": " + msg)
            return -1
        databasePath = self.getDatabasePluginPath()
        if databasePath is None:
            msg = redmsg("The protein database is missing.  Simulation aborted.")
            env.history.message(self.cmdname + ": " + msg)
            return -1
        self.path = self.getPathLocation(databasePath, simFilesPath)
        
        return None # no error
    def set_options_errQ(self, args):
        """
        Figure out and set filenames, including sim executable path.
        All inputs and outputs are self attrs or globals or other obj attrs...
        except, return error code if sim executable missing
        or on other errors detected by subrs.

        @param args: name of the protein for which rosetta simulation is run and
                     if its empty then it is run for the first available chunk
        @type args: str
        """
        movie = self._movie
        simFilesPath = find_or_make_Nanorex_subdir('RosettaDesignFiles')

        # Create temporary part-specific filename, for example:
        # "partname-minimize-pid1000".
        # We'll be appending various extensions to tmp_file_prefix to make temp
        # file names for sim input and output files as needed
        if args != "":
            pdbId = args
            for mol in self.win.assy.molecules:
                if mol.name == args:
                    chunk = mol
                    break
        else:
            pdbId, chunk = self.getPDBIDFromChunk()

        if self.cmd_type == "BACKRUB_PROTEIN_SEQUENCE_DESIGN":
            backrubSetupCorrect = chunk.protein.is_backrub_setup_correctly()
            #Urmi 20080807: The backrub motion is so poorly documented that
            #I do not have any idea what is the threshold value
            #my experiments with 2gb1 seems to show that its 3, but I dont know for sure
            if not backrubSetupCorrect:
                msg = redmsg("Rosetta sequence design with backrub motion failed. Please edit your residues properly from Edit REsidues command.")
                env.history.message(self.cmdname + "," + self.cmd_type + ": " + msg)
                return -1
        #write the residue file
        resFile = pdbId + ".resfile"
        resFilePath = os.path.join(simFilesPath, resFile)
        success = write_rosetta_resfile(resFilePath, chunk)
        if success:
            self.resFile = resFile
        else:
            #Shall we refuse to run the program if we cannot write the residue file?
            print "Residue file could not be written"
            return -1
        #remove all previously existing fasta files
        #may not be needed. But we are doing with out pdb, might as well do it
        #fasta and design files as well
        fastaFile = pdbId + "_out_design.fasta"
        checkPointFile = pdbId + "_out_design.checkpoint"
        checkPointPath = os.path.join(simFilesPath, checkPointFile)
        fastaFilePath = os.path.join(simFilesPath, fastaFile)
        if os.path.exists(fastaFilePath):
            os.remove(fastaFilePath)
        if os.path.exists(checkPointPath):
            os.remove(checkPointPath)
        if pdbId is None:
            basename = "Untitled"
        else:
            basename = pdbId
        timestampString = ""
        if (self.background):
            # Add a timestamp to the pid so that multiple backgrounded
            # calculations don't clobber each other's files.
            #We are not running Rosetta in the background now, so may not be useful
            timestamp = datetime.today()
            timestampString = timestamp.strftime(".%y%m%d%H%M%S")
        self.tmp_file_prefix = \
            os.path.join(simFilesPath,
                         "%s-rosetta-design-pid%d%s" % (basename, os.getpid(),
                                                  timestampString))
        #get program path, database path and write path.txt
        self.program = self.getExecutablePluginPath()
        if self.program is None:
            msg = redmsg("The simulator program is missing.  Simulation aborted.")
            env.history.message(self.cmdname + ": " + msg)
            return -1
        databasePath = self.getDatabasePluginPath()
        if databasePath is None:
            msg = redmsg("The protein database is missing.  Simulation aborted.")
            env.history.message(self.cmdname + ": " + msg)
            return -1
        self.path = self.getPathLocation(databasePath, simFilesPath)
        return None # no error
 def _write_resfile(self):
     from protein.model.Protein import write_rosetta_resfile
     for chunk in self.win.assy.molecules:
         if chunk.isProteinChunk():
             write_rosetta_resfile("/Users/piotr/test.resfile", chunk)
             return