############################################################################
#
# This SwisssideChain plugin is copyright of the Swiss Institute of Bioinformatics. 
# There are no restriction on its use by non-profit institutions as long as its 
# content is in no way modified and this statement is not removed. 
#
# Usage by and for commercial entities requires a license agreement 
# (see our legal disclaimer on http://www.swisssidechain.ch/license.html
# or send email to license@genebio.com).
#
# For scientific questions, please contact David Gfeller (david.gfeller@isb-sib.ch)
#
############################################################################




######### Usage ###########
#
# Command-line: Mutate 'chain'/'residue#'/, 'newres', e.g: Mutate A/2/, ARG
# If more than one object are loaded:  Mutate 'object'//'chain'/'residue#'/, 'newres', e.g: Mutate 1BFE//A/2/, ARG
#
#########################

import Tkinter
from Tkinter import *

import tkMessageBox
import tkSimpleDialog
from pymol import cmd


def __init__(self):
   
    self.menuBar.addmenuitem('Plugin', 'command', 'D_Mutate', label='D_PySwissSidechain...', command = lambda s=self : D_Mutate(s))

def D_MutateExecute( selection, mutant ):

    cmd.wizard("mutagenesis2")
    cmd.get_wizard().do_select(selection)
    cmd.get_wizard().set_mode(mutant)

    return

def D_Mutate(app):
    
    sel=tkSimpleDialog.askstring('D_PySwissSidechain', 'Please enter the residue you want to mutate:', parent=app.root)

    mut=tkSimpleDialog.askstring('D_PySwissSidechain', 'Please enter the SwissSidechain code of the new residue:', parent=app.root)

    D_MutateExecute(sel, mut)


cmd.extend("D_Mutate", D_MutateExecute)
