Actually never mind, the following seems to work: def delete_chain(): def first_residue(mol_id,ch_id): result=seqnum_from_serial_number(mol_id,"%s"%(ch_id),0) return result def last_residue(mol_id,ch_id): n=chain_n_residues(ch_id,mol_id)-1 result=seqnum_from_serial_number(mol_id,"%s"%(ch_id),n) return result active_mol_id=active_residue()[0] active_chain_id=active_residue()[1] first_res=first_residue(active_mol_id,active_chain_id) last_res=last_residue(active_mol_id,active_chain_id) delete_residue_range(active_mol_id,active_chain_id,first_res,last_res) menu=coot_menubar_menu("Custom") add_simple_coot_menu_menuitem(menu,"Delete active chain", lambda func: delete_chain()) On Mar 12, 2014, at 9:52 AM, Oliver Clarke <[log in to unmask]> wrote: > Thanks Bernhard, that’s very helpful. > > Using that function, I wrote a little script that will delete a chain based on the currently selected residue: > > def first_residue(mol_id,ch_id): > result=seqnum_from_serial_number(mol_id,"%s"%(ch_id),0) > return result > def last_residue(mol_id,ch_id): > n=chain_n_residues(ch_id,mol_id)-1 > result=seqnum_from_serial_number(mol_id,"%s"%(ch_id),n) > return result > active_mol_id=active_residue()[0] > active_chain_id=active_residue()[1] > first_res=first_residue(active_mol_id,active_chain_id) > last_res=last_residue(active_mol_id,active_chain_id) > delete_residue_range(active_mol_id,active_chain_id,first_res,last_res) > > > I’d quite like to assign this to a button, but the user defined button interface in coot only seems to take one-line commands, not multi-line - I guess I can assign it to a key binding though. Or is there an easy way to add a user-defined menu item? > > Oliver. > On Mar 12, 2014, at 3:08 AM, Bernhard Lohkamp <[log in to unmask]> wrote: > >> >> Hi Oliver, >> >> You can use the scripting function delete_residue_range (https://www2.mrc-lmb.cam.ac.uk/Personal/pemsley/coot/web/docs/coot.html#index-delete_002dresidue_002drange-709): >> >> delete_residue_range(imol, chain_id, start_res, stop_res) >> >> Maybe not exactly what you want, but that works fine for this purpose (*). You can give a residue range outside what you have, just to make sure everything is deleted, i.e. delete_residue_range(0,"A", -100,100000). >> >> B >> >> (*) Incidentally it has been on my todo list for quite some time to make a delete chain (etc) function... >> >> On 12/03/2014 00:51, Oliver Clarke wrote: >>> Another one to chalk on the list of things that would be nice to have but not really needed - I feel like having a delete chain option in the ‘Delete item’ dialog would be very handy… >>> >>> I often find myself needing to delete a chain (from a complex or oligomer for example), and I always switch the color to Jone’s Rainbow and then hunt around for the N- and C- termini and use delete zone, which works but is a little cumbersome. >>> >>> Being able to click on a single atom from the desired chain to delete it would speed things up tremendously, for example when editing the kind of spaghetti-model that sometimes comes out of buccaneer or Arp/warp at low resolution (where there a lot of peptide fragments that need cleaning up). >>> >>> Best, >>> Oliver. >>> >> >> -- >> *************************************************** >> >> Dr. Bernhard Lohkamp >> Associate Professor/Docent >> Div. Molecular Structural Biology >> Dept. of Medical Biochemistry and Biophysics (MBB) >> Karolinska Institutet >> S-17177 Stockholm >> Sweden >> >> phone: (+46) 08-52487651 >> fax: (+46) 08-327626 >> email: [log in to unmask] >