예제 #1
0
    def _createActions(self, parentWidget):
        """
        Define flyout toolbar actions for this mode.
        """

        _superclass._createActions(self, parentWidget)

        #Urmi 20080814: show this flyout toolbar only when rosetta plugin path
        # is there
        #Probably only rosetta_enabled_prefs_key check would have sufficed
        plugin_name = "ROSETTA"
        plugin_prefs_keys = (rosetta_enabled_prefs_key, rosetta_path_prefs_key)
        errorcode, errortext_or_path = \
                 checkPluginPreferences(plugin_name, plugin_prefs_keys, ask_for_help = False)
        #print "Error code =", errorcode, errortext_or_path
        if errorcode == 0:
            self.rosetta_enabled = True
        else:
            self.rosetta_enabled = False

        # The subControlActionGroup is the parent of all flyout QActions.
        self.subControlActionGroup = QActionGroup(parentWidget)
            # Shouldn't the parent be self.win?
            # Isn't parentWidget = BuildProteinPropertyManager?
            # Ask Bruce about this. --Mark 2008-12-07.

        self.subControlActionGroup.setExclusive(True)

        self.modelProteinAction = \
            NE1_QWidgetAction(self.subControlActionGroup, win = self.win)
        self.modelProteinAction.setText("Model")
        self.modelProteinAction.setIcon(geticon(
            'ui/actions/Command Toolbar/BuildProtein/ModelProtein.png'))
        self.modelProteinAction.setCheckable(True)
        self.modelProteinAction.setChecked(True)
        self.modelProteinAction.setObjectName('ACTION_MODEL_PROTEINS')

        self.simulateProteinAction = \
            NE1_QWidgetAction(self.subControlActionGroup, win = self.win)
        self.simulateProteinAction.setText("Simulate")
        self.simulateProteinAction.setIcon(geticon(
            "ui/actions/Command Toolbar/BuildProtein/Simulate.png"))
        self.simulateProteinAction.setCheckable(True)
        self.simulateProteinAction.setObjectName('ACTION_SIMULATE_PROTEINS')


        self.subControlActionGroup.addAction(self.modelProteinAction)
        self.subControlActionGroup.addAction(self.simulateProteinAction)

        self._createModelProteinsActions(parentWidget)
        self._createSimulateProteinsActions(parentWidget)
예제 #2
0
 def getExecutablePluginPath(self):
     
     plugin_name = "ROSETTA"
     plugin_prefs_keys = (rosetta_enabled_prefs_key, rosetta_path_prefs_key)
         
     errorcode, errortext_or_path = \
              checkPluginPreferences(plugin_name, plugin_prefs_keys)
     if errorcode:
         msg = redmsg("Verify Plugin: %s (code %d)" % (errortext_or_path, errorcode))
         env.history.message(msg)
         return None
     program_path = errortext_or_path
     
     return program_path
예제 #3
0
 def getDatabasePluginPath(self):
     
     plugin_name = "ROSETTA_DATABASE"
     #Urmi 20080710: using the same code as exectuables. Its kind of bad
     # but probably ok before RosettaCon
     plugin_prefs_keys = (rosetta_database_enabled_prefs_key, rosetta_dbdir_prefs_key)
         
     errorcode, errortext_or_path = \
              checkPluginPreferences(plugin_name, plugin_prefs_keys)
     if errorcode:
         msg = redmsg("Verify Plugin: %s (code %d)" % (errortext_or_path, errorcode))
         env.history.message(msg)
         return None
     dataBase_path = errortext_or_path
     return dataBase_path
예제 #4
0
    def testRosettaAndUpdateCommandToolbar(self, action):
        if action == self.simulateProteinAction:
            if not self.rosetta_enabled:
                #print "Rosetta is not enabled"
                plugin_name = "ROSETTA"
                plugin_prefs_keys = (rosetta_enabled_prefs_key, rosetta_path_prefs_key)
                errorcode, errortext_or_path = \
                         checkPluginPreferences(plugin_name, plugin_prefs_keys, ask_for_help = True)
                #print "Error code =", errorcode, errortext_or_path
                if errorcode == 0:
                    self.rosetta_enabled = True
                else:
                    self.rosetta_enabled = False
                    self.modelProteinAction.setChecked(True)
                    self.simulateProteinAction.setChecked(False)
                    return

        self.updateCommandToolbar()
예제 #5
0
def launch_qutemol(pdb_file):
    """
    Launch and load QuteMolX with the PDB file I{pdb_file}.
    
    @param pdb_file: the PDB filename to load
    @type  pdb_file: string
    
    @return: (errorcode, errortext)
             where errorcode is one of the following: ###k
                 0 = successful
                 8 = QuteMolX failed for an unknown reason.
    @rtype:  int, text
    """
    
    plugin_name = "QuteMolX"
    plugin_prefs_keys = (qutemol_enabled_prefs_key, qutemol_path_prefs_key)
            
    errorcode, errortext_or_path = \
             checkPluginPreferences(plugin_name, plugin_prefs_keys,
                                    insure_executable = True)
    if errorcode:
        return errorcode, errortext_or_path
    
    program_path = errortext_or_path
    
    workdir, junk_exe = os.path.split(program_path)
    
    # This provides a way to tell NE1 which version of QuteMolX is installed.
    if debug_pref("QuteMol 0.4.1 or later", 
                  Choice_boolean_True, 
                  prefs_key = True):
        version = "0.4.1"
    else:
        version = "0.4.0"
    
    # Start QuteMolX.
    try:
        args = [pdb_file]
        if env.debug():
            print "Debug: Launching", plugin_name, \
                  "\n  working directory=", workdir, \
                  "\n  program_path=", program_path,  \
                  "\n  args are %r" % (args,)
        
        arguments = QStringList()
        for arg in args:
            if arg != "":
                arguments.append(arg)
        
        p = Process()
        
        # QuteMolX must run from the directory its executable lives. Otherwise,  
        # it has serious problems (but still runs). Mark 2007-06-02.
        p.setWorkingDirectory(QString(workdir))
        
        # Tried p.startDetached() so that QuteMolX would be its own process and 
        # continue to live even if NE1 exits. Unfortunately, 
        # setWorkingDirectory() doesn't work. Seems like a Qt bug to me. 
        # Mark 2007-06-02
        p.start(program_path, arguments)
        
    except:
        print_compact_traceback( "exception in launch_qutemol(): " )
        return 8, "%s failed for an unknown reason." % plugin_name
    
    # set an appropriate exitcode and msg
    if p.exitStatus() == QProcess.NormalExit:
        exitcode = p.exitStatus()
        if not exitcode:
            msg = plugin_name + " launched."
        else:
            msg = plugin_name + " had exitcode %r" % exitcode
    else:
        exitcode = p.exitStatus()
        exitcode = -1
        msg = "Abnormal exit (or failure to launch)"
        
    if exitcode:
        return 8, "Error: " + msg 
        # this breaks the convention of the other error returns
            
    return 0, plugin_name + " launched." # from launch_qutemol
예제 #6
0
def launch_qutemol(pdb_file):
    """
    Launch and load QuteMolX with the PDB file I{pdb_file}.
    
    @param pdb_file: the PDB filename to load
    @type  pdb_file: string
    
    @return: (errorcode, errortext)
             where errorcode is one of the following: ###k
                 0 = successful
                 8 = QuteMolX failed for an unknown reason.
    @rtype:  int, text
    """

    plugin_name = "QuteMolX"
    plugin_prefs_keys = (qutemol_enabled_prefs_key, qutemol_path_prefs_key)

    errorcode, errortext_or_path = \
             checkPluginPreferences(plugin_name, plugin_prefs_keys,
                                    insure_executable = True)
    if errorcode:
        return errorcode, errortext_or_path

    program_path = errortext_or_path

    workdir, junk_exe = os.path.split(program_path)

    # This provides a way to tell NE1 which version of QuteMolX is installed.
    if debug_pref("QuteMol 0.4.1 or later",
                  Choice_boolean_True,
                  prefs_key=True):
        version = "0.4.1"
    else:
        version = "0.4.0"

    # Start QuteMolX.
    try:
        args = [pdb_file]
        if env.debug():
            print "Debug: Launching", plugin_name, \
                  "\n  working directory=", workdir, \
                  "\n  program_path=", program_path,  \
                  "\n  args are %r" % (args,)

        arguments = QStringList()
        for arg in args:
            if arg != "":
                arguments.append(arg)

        p = Process()

        # QuteMolX must run from the directory its executable lives. Otherwise,
        # it has serious problems (but still runs). Mark 2007-06-02.
        p.setWorkingDirectory(QString(workdir))

        # Tried p.startDetached() so that QuteMolX would be its own process and
        # continue to live even if NE1 exits. Unfortunately,
        # setWorkingDirectory() doesn't work. Seems like a Qt bug to me.
        # Mark 2007-06-02
        p.start(program_path, arguments)

    except:
        print_compact_traceback("exception in launch_qutemol(): ")
        return 8, "%s failed for an unknown reason." % plugin_name

    # set an appropriate exitcode and msg
    if p.exitStatus() == QProcess.NormalExit:
        exitcode = p.exitStatus()
        if not exitcode:
            msg = plugin_name + " launched."
        else:
            msg = plugin_name + " had exitcode %r" % exitcode
    else:
        exitcode = p.exitStatus()
        exitcode = -1
        msg = "Abnormal exit (or failure to launch)"

    if exitcode:
        return 8, "Error: " + msg
        # this breaks the convention of the other error returns

    return 0, plugin_name + " launched."  # from launch_qutemol