From: Geist, Norman (
Date: Wed Jun 08 2022 - 00:19:52 CDT

Hey Oscar,

please keep the list in CC. Glad to hear it works now. The final
change you want is very simple:

_puts $fp "[expr $j + 1] [lindex [$sel get {resname __resid __phi
psi}] $j]"_

 _In case you have multple chains and resids are not unique between
them, consider adding also the chain id:_

_ puts $fp "[expr $j + 1] [lindex [$sel get
{resname chain __resid __phi psi}] $j]"_

Please have a look on the atomselect command and how resulting objects
can be queried for information ;)

Norman Geist

Am Mittwoch, den 08-06-2022 um 00:35 schrieb Oscar Bastidas:

It worked.  Thank you!

One other question, as part of what's printed to the file, I'd also
like to include the residue number printed.  I tried modifying the
following line in the original script:
_puts $fp "[expr $j + 1] [lindex [$sel get {resname phi psi}] $j]"_


_puts $fp "[expr $j + 1] [lindex [$sel get {resname residue $j phi
psi}] $j]"_

but tcl returned an error saying it could not find the attribute $j in

Would you please tell me how I can include printing out the residue
number as found in the pdb file for each residue being analyzed?

Thanks again.

Oscar B.

On Tue, Jun 7, 2022, 1:02 AM Geist, Norman wrote:

Also, to not get duplicates in output, change the selection not to
"all" but "all and name CA" to only select a single atom per amino

Norman Geist

Am Dienstag, den 07-06-2022 um 07:59 schrieb Geist, Norman:

Hey Oscar,

you changed the wrong lines ;)


   set mol [mol new "monom.psf" waitfor all]
   mol addfile "monom.dcd" molid $mol waitfor all


set mol [molinfo top]


_set sel [ atomselect $mol "alpha" ]_


_set sel [ atomselect $mol "all" ]_

_In case of selection "all" you can also remove the "$sel update"
which might optimize performance._

_Norman Geist_

Am Dienstag, den 07-06-2022 um 06:12 schrieb Oscar Bastidas:


I came across the following tcl script for printing the values of phi
and psi angles to a file for a loaded trajectory coming from a MD
simulation.  However, the original script takes the psf and dcd files
as inputs which I do not have.  I have a pdb file which contains all
frames of the trajectory.  Would someone please tell me how to modify
the tcl script below so that it works for my pdb file - once my pdb
file is loaded - instead of the psf and dcd files that the script was
originally designed for (I tried replacing the original "set mol..."
with "set mol [atomselect top "all"]" but I got an error in the tcl
console stating that it was expecting an integer)?  Thanks for any
direction anyone can provide.

Oscar B.


   set mol [mol new "monom.psf" waitfor all]
    mol addfile "monom.dcd" molid $mol waitfor all
    set fp [ open "phi-psi.dat" w ]
    set sel [ atomselect $mol "alpha" ]
    set n [ molinfo $mol get numframes ]

    for {set i 0 } { $i < $n } { incr i } {
        $sel frame $i
        $sel update
        puts $fp "\# frame: $i"

        set a [ $sel num ]
        for {set j 0 } { $j < $a } { incr j } {
            puts $fp "[expr $j + 1] [lindex [$sel get
{resname phi psi}] $j]"

    $sel delete
    close $fp