Beispiel #1
0
def pickAtoms(ignoreDensity=False):
    """Prompt the user to pick two atoms to rotamerize a stretch of nucleotides.  Alternatively, if
    we're already waiting for the user to pick atoms, then cancel the pending picks.
    
    ARGUMENTS:
        None
    OPTIONAL ARGUMENTS:
        ignoreDensity - ignore the density when performing the minimization
                        defaults to False
    RETURNS:
        None
    """

    #create the citation pop-up if necessary
    createCitationPopup()

    global waitingForClicks

    #make sure that we're not waiting on a pending extendChain call
    extendChain.clearPendingExtendChain()

    if waitingForClicks:
        #if we're already in the middle of a rotamerize call, then cancel the pending rotamerize
        print "Rotamerize cancelled"
        add_status_bar_text("Rotamerize cancelled")
        clear_pending_picks(
        )  #tell Coot to stop waiting for the user to click on atoms
        __setMenuToRotamerize()
        waitingForClicks = False

    else:
        #if we're not in the middle of a rotamerize call, then start one

        #make sure that there is a refinement map set
        if not ignoreDensity and imol_refinement_map() == -1:
            print "No refinement map set for RCrane rotamerize"
            selectMapDialog(pickAtoms)
            return

        print "Click on 2 atoms (in the same molecule)"
        add_status_bar_text(
            "Pick 2 atoms [Ctrl Left-mouse rotates the view]...")
        __setMenuToCancel()
        waitingForClicks = True
        user_defined_click(
            2, lambda atomSpec1, atomSpec2: rotamerizeFromAtomSpecs(
                atomSpec1, atomSpec2, ignoreDensity))
Beispiel #2
0
def pickAtoms(ignoreDensity = False):
    """Prompt the user to pick two atoms to rotamerize a stretch of nucleotides.  Alternatively, if
    we're already waiting for the user to pick atoms, then cancel the pending picks.
    
    ARGUMENTS:
        None
    OPTIONAL ARGUMENTS:
        ignoreDensity - ignore the density when performing the minimization
                        defaults to False
    RETURNS:
        None
    """
    
    #create the citation pop-up if necessary
    createCitationPopup()
    
    global waitingForClicks
    
    #make sure that we're not waiting on a pending extendChain call
    extendChain.clearPendingExtendChain()
    
    if waitingForClicks:
        #if we're already in the middle of a rotamerize call, then cancel the pending rotamerize
        print "Rotamerize cancelled"
        add_status_bar_text("Rotamerize cancelled")
        clear_pending_picks() #tell Coot to stop waiting for the user to click on atoms
        __setMenuToRotamerize()
        waitingForClicks = False
    
    else:
        #if we're not in the middle of a rotamerize call, then start one
        
        #make sure that there is a refinement map set
        if not ignoreDensity and imol_refinement_map() == -1:
            print "No refinement map set for RCrane rotamerize"
            selectMapDialog(pickAtoms)
            return
        
        print "Click on 2 atoms (in the same molecule)"
        add_status_bar_text("Pick 2 atoms [Ctrl Left-mouse rotates the view]...")
        __setMenuToCancel()
        waitingForClicks = True
        user_defined_click(2, lambda atomSpec1, atomSpec2: rotamerizeFromAtomSpecs(atomSpec1, atomSpec2, ignoreDensity))
Beispiel #3
0
def pickAtoms():
    """Prompt the user to pick an atoms to extend a stretch of nucleotides.  Alternatively, if
    we're already waiting for the user to pick an atom, then cancel the pending pick.
    
    ARGUMENTS:
        None
    RETURNS:
        None
    """

    #create the citation pop-up if necessary
    createCitationPopup()

    #make sure that we're not waiting on a pending rotamerize call
    rotamerize.clearPendingRotamerize()

    global waitingForClicks

    if waitingForClicks:
        #if we're already in the middle of an extend chain call, then cancel the pending call
        print "Rotamerize cancelled"
        add_status_bar_text("Extend chain cancelled")
        clear_pending_picks(
        )  #tell Coot to stop waiting for the user to click on atoms
        __setMenuToExtendChain()
        waitingForClicks = False

    else:
        #if we're not in the middle of a extend chain call, then start one

        #make sure that there is a refinement map set
        if imol_refinement_map() == -1:
            print "No refinement map set for RCrane extend chain"
            selectMapDialog(pickAtoms)
            return

        print "Click on a nucleotide to extend"
        add_status_bar_text(
            "Pick a nucleotide [Ctrl Left-mouse rotates the view]...")
        __setMenuToCancel()
        waitingForClicks = True
        user_defined_click(1, extendChainFromAtomSpec)
Beispiel #4
0
def pickAtoms():
    """Prompt the user to pick an atoms to extend a stretch of nucleotides.  Alternatively, if
    we're already waiting for the user to pick an atom, then cancel the pending pick.
    
    ARGUMENTS:
        None
    RETURNS:
        None
    """
    
    #create the citation pop-up if necessary
    createCitationPopup()
    
    #make sure that we're not waiting on a pending rotamerize call
    rotamerize.clearPendingRotamerize()
    
    global waitingForClicks
    
    if waitingForClicks:
        #if we're already in the middle of an extend chain call, then cancel the pending call
        print "Rotamerize cancelled"
        add_status_bar_text("Extend chain cancelled")
        clear_pending_picks() #tell Coot to stop waiting for the user to click on atoms
        __setMenuToExtendChain()
        waitingForClicks = False
    
    else:
        #if we're not in the middle of a extend chain call, then start one
        
        #make sure that there is a refinement map set
        if imol_refinement_map() == -1:
            print "No refinement map set for RCrane extend chain"
            selectMapDialog(pickAtoms)
            return
        
        print "Click on a nucleotide to extend"
        add_status_bar_text("Pick a nucleotide [Ctrl Left-mouse rotates the view]...")
        __setMenuToCancel()
        waitingForClicks = True
        user_defined_click(1, extendChainFromAtomSpec)
Beispiel #5
0
def selectMapDialog(callback=None):
    """Display a GUI for selecting the refinement map.
    
    OPTIONAL ARGUMENTS:
        callback - a function to call when the user clicks OK
    RETURNS:
        None
    """

    # create a list of map molecules and their names
    mapList = []
    for imol in xrange(graphics_n_molecules()):
        if is_valid_map_molecule(imol):
            mapList.append(imol)

    # if we have no maps, then display an error and don't invoke the callback
    if len(mapList) == 0:
        warningMessage = gtk.MessageDialog(
            type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format="Please load a map before using RCrane."
        )
        warningMessage.set_title("RCrane Error")
        warningMessage.run()
        warningMessage.destroy()

    else:
        # if we have one or more maps
        dialog = gtk.Dialog(title="Select Map for Fitting", buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))

        # create a combo box that lists maps
        mapListStore = gtk.ListStore(int, str)
        for imol in mapList:
            mapListStore.append([imol, str(imol) + " " + molecule_name(imol)])
        mapCombo = gtk.ComboBox(mapListStore)
        mapRender = gtk.CellRendererText()
        mapCombo.pack_start(mapRender, True)
        mapCombo.add_attribute(mapRender, "text", 1)

        # select the current refinemnt map, or the first map if no map has been selected
        currentMap = imol_refinement_map()
        if currentMap == -1:
            set_imol_refinement_map(mapListStore[0][0])
            mapCombo.set_active(0)
        else:
            # figure out which combobox row corresponds to the currently selected map
            comboIndex = [i[0] for i in mapListStore].index(currentMap)
            mapCombo.set_active(comboIndex)

        # connect the changed signal for the combobox
        mapCombo.connect("changed", __changeMap)

        # add the label and frame
        chooseLabel = gtk.Label("Choose a Map:")
        frame = gtk.Frame()
        frameBox = gtk.VBox(False, 0)
        frame.add(frameBox)
        frameBox.pack_start(chooseLabel, False, False, 2)
        frameBox.pack_start(mapCombo, False, False, 2)

        # pack things into the top area of the dialog box
        dialog.vbox.pack_start(frame, False, False, 2)
        dialog.vbox.show_all()

        # connect the callback function
        if callback is not None:
            # if there is a callback function and the user clicks OK, then call the callback
            # if the user clicks the close button, then don't call the callback
            def checkResponse(dialog, responseID, callback):
                if responseID == gtk.RESPONSE_OK:
                    callback()

            dialog.connect("response", checkResponse, callback)

        # create the dialog box
        dialog.run()
        dialog.destroy()
Beispiel #6
0
def selectMapDialog(callback=None):
    """Display a GUI for selecting the refinement map.
    
    OPTIONAL ARGUMENTS:
        callback - a function to call when the user clicks OK
    RETURNS:
        None
    """

    #create a list of map molecules and their names
    mapList = []
    for imol in xrange(graphics_n_molecules()):
        if is_valid_map_molecule(imol):
            mapList.append(imol)

    #if we have no maps, then display an error and don't invoke the callback
    if len(mapList) == 0:
        warningMessage = gtk.MessageDialog(
            type=gtk.MESSAGE_ERROR,
            buttons=gtk.BUTTONS_OK,
            message_format="Please load a map before using RCrane.")
        warningMessage.set_title("RCrane Error")
        warningMessage.run()
        warningMessage.destroy()

    else:
        #if we have one or more maps
        dialog = gtk.Dialog(title="Select Map for Fitting",
                            buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK))

        #create a combo box that lists maps
        mapListStore = gtk.ListStore(int, str)
        for imol in mapList:
            mapListStore.append([imol, str(imol) + " " + molecule_name(imol)])
        mapCombo = gtk.ComboBox(mapListStore)
        mapRender = gtk.CellRendererText()
        mapCombo.pack_start(mapRender, True)
        mapCombo.add_attribute(mapRender, 'text', 1)

        #select the current refinemnt map, or the first map if no map has been selected
        currentMap = imol_refinement_map()
        if currentMap == -1:
            set_imol_refinement_map(mapListStore[0][0])
            mapCombo.set_active(0)
        else:
            #figure out which combobox row corresponds to the currently selected map
            comboIndex = [i[0] for i in mapListStore].index(currentMap)
            mapCombo.set_active(comboIndex)

        #connect the changed signal for the combobox
        mapCombo.connect("changed", __changeMap)

        #add the label and frame
        chooseLabel = gtk.Label("Choose a Map:")
        frame = gtk.Frame()
        frameBox = gtk.VBox(False, 0)
        frame.add(frameBox)
        frameBox.pack_start(chooseLabel, False, False, 2)
        frameBox.pack_start(mapCombo, False, False, 2)

        #pack things into the top area of the dialog box
        dialog.vbox.pack_start(frame, False, False, 2)
        dialog.vbox.show_all()

        #connect the callback function
        if callback is not None:
            #if there is a callback function and the user clicks OK, then call the callback
            #if the user clicks the close button, then don't call the callback
            def checkResponse(dialog, responseID, callback):
                if responseID == gtk.RESPONSE_OK: callback()

            dialog.connect("response", checkResponse, callback)

        #create the dialog box
        dialog.run()
        dialog.destroy()