From: Bill McIntyre (bill_mcintyre378_at_outlook.com)
Date: Fri Nov 03 2023 - 10:58:11 CDT

Hello everyone,

I have a script for cyclicizing a linear peptide loaded into VMD as a PDB file (thanks Josh) and it runs perfectly when I execute each command manually one-by-one in TKCon, but when I make a .tcl file containing all commands in the file (one command per line) and try to execute the whole script in TKCon (source myScript.tcl), certain lines of code appear to be completely ignored and so the script ends up not doing what it was doing well manually (it should output a psf and a pdb file). Would someone please give me their thoughts as to why this is happening? Below is my script:

resetpsf
package require psfgen
topology top_all36_prot.rtf

#My 20231029 addition to handle renaming things
pdbalias residue HIS HSD
pdbalias atom ILE CD1 CD

segment C {
pdb file.pdb
first none
last none
}

#I need to know the first and last residue numbers
mol new file.pdb
set sel [atomselect top {name CA}] # Previously this was: set sel [atomselect top "name CA"] but script got hung up at this point until I changed the quotes to curly braces
set firstresid [lindex [$sel get resid] {0}]
set lastresid [lindex [$sel get resid] {end}]

#Apply the patch
patch LINK C:$lastresid C:$firstresid C:1 C:2

#Add coordinates and do the rest of the psf building.
coordpdb file.pdb C
regenerate angles dihedrals
guesscoord
writepsf out.psf
writepdb out.pdb