From: Axel Kohlmeyer (
Date: Fri Sep 21 2007 - 13:15:29 CDT

On Fri, 21 Sep 2007, Nicolas Sapay wrote:


NS> 5 set sel [ atomselect $molid "$seltext" ]
NS> 6 # Retrieve the 'residue' number of the selection
NS> 7 set reslist [ lsort -integer -unique [ $sel get residue ] ]
NS> 8
NS> 9 # Assign a new 'resid' to each residue of the selection
NS> 10 foreach res $reslist {
NS> 11 # Do a temporary selection
NS> 12 set tmpsel [ atomselect $molid "$seltext and residue
NS> $res" ]

please note, that in this case you overwrite only the resids
of those atoms that are in the selection, so parts of the same
residue may have different resids after the procedure.
if you want to overwrite the resid of all atoms in a given residue,
just use the selection text of "residue $res".

NS> 13 $tmpsel set resid $start
NS> 14 $tmpsel delete
NS> 15 # Increment the new resid
NS> 16 incr start
NS> 17 }
NS> 18 $sel delete
NS> 19 return
NS> 20}
NS> #======================================
NS> However, the proc doesn't work with a simple system of 214 identical
NS> residues (it's a membrane bilayer). When I use the 'residue' keyword at
NS> line 7, I obtain a list of 218 'residue' which is wrong. But when I do
NS> the same thing using the 'resid' keyworkd, I obtain a correct list of
NS> 214 'resid'. Why do the 'residue' keyword give me 4 more residues? (When
NS> I do the renumbering, the resids start to be wrong at 200)

please check, whether those resids have been actually overwritten.
see above.


NS> Thanks for your help. I hope I'm not too confusing with all this
NS> 'residue' and 'resid'
NS> Nicolas

Axel Kohlmeyer
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
If you make something idiot-proof, the universe creates a better idiot.