From: Akshay Bhatnagar (
Date: Sun Apr 03 2016 - 11:17:30 CDT

Hello everyone

I have created a small script to create psf files for multi-chain proteins.
the script is:

package require psfgen
psfcontext reset
topology top_all27_prot_na.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 {
echo $chain
for {set i 0} {$i <= $chain} {incr i} {
set sel [atomselect top "pfrag $chain"]
$sel writepdb $name-$chain.pdb
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 MAIN {pdb $name-$chain.pdb}
coordpdb $name-$chain.pdb MAIN
writepdb $file-$chain-psf.pdb
while {$chain >= 0} {
exec cat $file-$chain-psf.pdb >> $name-final.pdb &
incr chain -1
echo $chain

But, the psfgen package creates the psf linked pdb files for chains in the
reverse order. for example, if a protein has 2 chains A and B, then it
creates the psf for B before chain A (chain ID 0 to last chain). Due to
this during concatenation of the -psf.pdb files the B chain psf.psd is
coming before the A chan psf.pdb files.

Can anyone please help to create psf.pdb for chain A before chain B.

With Regards
Akshay Bhatnagar
PhD Student
BITS Pilani Hyderabad Campus