From: William Howe (howew_at_mail.gvsu.edu)
Date: Tue Feb 02 2021 - 18:14:55 CST

I have a TCL script that creates a PDB file meant to list all protein
residues within 4 angstroms of the ligand. This script iterates over a
directory of ligand-protein complexes and, essentially, outputs aPDB file
containing a binding pocket for each one. However, I noticed that the PDB
files generated by VMD typically lists the protein atoms first and then the
ligand atoms. Is there a way to generate a PDB file that lists the ligand
atoms first, and then the protein atoms? What can I modify to my TCL script
to accomplish this?

set filelist [glob *.pdb]

set und " Partial Pocket"

foreach i $filelist {

set PDBID [lindex [split $i .] 0]

        mol load pdb $i

        set sel [atomselect top "protein and within 4 of resname
UNK"]

       $sel writepdb $PDBID$und.pdb

}