Generating a lot of segments in proper order and selection around a center of mass

From: Leonardo Sepulveda Durán (
Date: Wed Jun 01 2005 - 16:13:35 CDT

Hello list!!!!

I am trying to create a .tcl script suitable for automatic generation
of a psf file from a pdb with a lot of fragments. I found in the
NAMD2.5UserGuide(pag. 28) the following script to take diferent
segments from a pdb file and create a single pdb of each of them:

# Split a file containing protein and water into separate segments.
# Creates files named myfile_water.pdb, myfile_frag0.pdb, myfile_frag1.pdb,...
# Requires VMD.
mol load pdb myfile.pdb
set water [atomselect top water]
$water writepdb myfile_water.pdb
set protein [atomselect top protein]
set chains [lsort -unique [$protein get pfrag]]
foreach chain $chains {
      set sel [atomselect top "pfrag $chain"]
      $sel writepdb myfile_frag${chain}.pdb

I modify it to generate segments of every fragment as well:

mol load pdb prot.pdb
package require psfgen
topology /home/RPMs/NAMD/toppar/top_all22_prot.inp

set protein [atomselect top protein]
set chains [lsort -unique [$protein get pfrag]]
foreach chain $chains {
        set sel [atomselect top "pfrag $chain"]
        $sel writepdb P${chain}.pdb

        # Build protein segment
        segment P${chain} {pdb P${chain}.pdb}

        # read Coordinates from file
        pdbalias atom ILE CD1 CD
        pdbalias residue HIS HSE
        coordpdb P${chain}.pdb P${chain}

# Write structure and coordinate files
writepsf complejo.psf
writepdb complejo.pdb


It works well, it creates 6 files from P0.pdb to P5.pdb . That was
weird because my protein have only two subunits, A and B. I realized
this is because my structure have some gaps, so VMD cut subunit A into
2 fragments and subunit B into 4. As they are diferent segments, I
think the gaps will be treated as N and C terminal, making them
chargued. I would like to ask if there is a way to undo or avoid this
script for adding N and C terminals into the gaps, because they are
far from the place where I want to make my minimization, but maybe not
far enough for one chargued C or N terminal.

My second question comes from the order in which fragments are
considered. When I read P0.pdb I realized it is not the first segment
from subunit A, but the last of subunit B. So in "complejo.pdb" the
ordering of segments goes backwards, wich is a bit odd for later
analysis. Reading the script the only command I Thought would be
responsable of it is

 set chains [lsort -unique [$protein get pfrag]]

I have not found any word about "lsort -unique" neither in
VMD-User-Guide nor NAMD-User-Guide, so I would like to ask where can I
found information about those commands, or more directly, if someone
knows how to fix the error.

As a Third question I would like to define a subset around N angstroms
from the center of mass of the active site, and change the B factor
column in "complejo.pdb" for every atom outside that subset to 1.00 to
use "fixedAtomsCol B", to fix them for minimization.

The first problem I had is concerned with a complex atomselection.
Adding the following comand to the script above:

set sel [atomselect top protein and ((segname P0 and resid "362 364")
and (segname P5 and resid "326 328"))]

which is intended to select resids 362 and 364 in segment P0 and
resids 326 and 328 in segment P5. When I use

$sel get resid

to see the resid they belong, all the protein appear selected. ¿Does
someone Know how to fix the set command to obtain the correct

Well, that is all. I hope someone would gime a hand with this


This archive was generated by hypermail 2.1.6 : Wed Feb 29 2012 - 15:40:48 CST