From: Akshay Bhatnagar (
Date: Wed Mar 30 2016 - 23:08:34 CDT

Hello everyone

I am creating a tcl script to create psf files for all the pdb file in the
directory. But when there are more than one chain in the PDB, the program
is creating psf for only the 'A' chain. To overcome this i used the chain
id to separate the psf files for each chain of a pdb file. Now, how can i
concatenate the generated psf.pdb files for two chains of a PDB file.

Also, the second problem i am facing is that chain B is saved with chain id
0 identifier , whereas, chain A is saved with chain id 1 identifier, i was
expecting the reverse. i.e the psf.pdb file with chain A should have a
lower id in the file name.

The script used is:

package require autopsf
psfcontext reset
topology top_all27_prot_lipid.inp
set filelist [glob *.PDB]
  foreach file $filelist {
    mol new $file
    set name [file rootname $file]
    set selp [atomselect top "not hetero"]
set chains [lsort -unique [$selp get pfrag]]
foreach chain $chains {
  set sel [atomselect top "pfrag $chain"]
  $sel writepdb $file-$chain.pdb
echo "$chain"
pdbalias residue HIS HSP
pdbalias atom ILE CD1 CD
pdbalias atom LYS 1HZ HZ1
pdbalias atom LYS 2HZ HZ2
pdbalias atom LYS 3HZ HZ3
pdbalias atom ARG 1HH1 HH11
pdbalias atom ARG 2HH1 HH12
pdbalias atom ARG 1HH2 HH21
pdbalias atom ARG 2HH2 HH22
pdbalias atom ASN 1HD2 HD21
pdbalias atom ASN 2HD2 HD22
pdbalias atom SER HG HG1
segment U {pdb $file-$chain.pdb}
coordpdb $file-$chain.pdb U
writepdb $file-$chain-psf.pdb

With Regards
Akshay Bhatnagar
PhD Student
BITS Pilani Hyderabad Campus