[Chimera-users] [EXTERNAL] Re: Help please: extracting distances from each frame of a short MD

Batra, Vinod (NIH/NIEHS) [C] batra1 at niehs.nih.gov
Fri Dec 10 09:21:18 PST 2021

Hi Anne-Frances
I can provide you a python script to do that if you can write each trajectory as pdb file. 
In the image attached, I have measured 12 distance pairs in 10 different pdb files. The plot shows that if the distance between atom pairs are similar to some reference structure they are colored black, and green if shorter, and red if longer with a predefined and customizable cutoff value eg. 0.2 or 0.3 å. The script writes these distances to a csv file also at the same time  so that you can plot it in any graphic program.

My script does not measure angles, but can be added to the script easily.

On 12/10/21, 11:48 AM, "Elaine Meng via Chimera-users" <chimera-users at cgl.ucsf.edu> wrote:

    CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and are confident the content is safe.

    Hi Anne-Frances,
    There is no way to populate the MD plots from a command script, sorry.  You would just use the GUI (MD Movie menu: Analysis... Plot), select the two atoms (for a distance) or 3-4 atoms (for an angle) and then it will be plotted across the whole trajectory:

    Once you create a distance monitor it is persistent across trajectory frames and will continue to display the updated distance while the trajectory plays.  If you really wanted to do it in a per-frame command script and measure distance at each trajectory frame (each value reported in the Reply Log) you could use ~distance command at each frame to remove all the distance monitors after they are added.  E.g.

    distance :1058 at O2 :741 at ND1
    distance :730 at OH :741 at NE2
    distance :721 at OG1 :1058 at N5
    distance :718 at O :1058 at N3
    distance :721 at N :1058 at O4
    distance :722 at N :1058 at O4
    distance :720 at N :1058 at O4
    distance :740 at O :720 at N

    But then you would need to save Reply Log and process its contents and then put it into some other graphing program if you wanted a plot.   This would be a pain since you have lots of different distances.  If you want a plot, or even the values in some convenient form for plotting with another program, then probably the way to go is using the GUI from the MD Movie menu.

    I hope this helps,
    Elaine C. Meng, Ph.D.
    UCSF Chimera(X) team
    Department of Pharmaceutical Chemistry
    University of California, San Francisco

    > On Dec 10, 2021, at 12:06 AM, Anne-Frances Miller via Chimera-users <chimera-users at cgl.ucsf.edu> wrote:
    > Dear Chimera support,
    > I want to extract a set of distances and one angle from each snapshot of an MD trajectory (there are 11 of them).
    > My plan was to have all my distances appear in one of the MD-movie analysis>plot distances windows and use ‘Dump Values’ to get my numbers out in a way I could use for other plots.
    > I realize angles cannot appear in the same plot, but hope I can measure an angle in the same script.
    > I have a ‘per-frame’ script that runs fine on the first frame, however it returns ‘Problem in per-frame script: Distance monitor already exists’ when I step forward to a second frame.
    > Nothing appears in a 'MD plots' window (such a window does not open on its own either).
    > Reply Log shows the correct distances for the first frame but then only repeats the error after that.
    > Problem in per-frame script:
    > Distance monitor already exists
    > My work-flow:
    > Open MD/movie, load my trajectory
    > open analysis, Per-Frame
    > copy my script into the window (chimera commands)
    > click ‘apply' in the script window, click ‘play’ or step forward one frame in the MD GUI (looping disabled)
    > My script:
    > ~disp
    > ~ribbon
    > disp :718,720,721,722,730,740,741,1058
    > distance :1058 at O2 :741 at ND1
    > distance :730 at OH :741 at NE2
    > distance :721 at OG1 :1058 at N5
    > distance :718 at O :1058 at N3
    > distance :721 at N :1058 at O4
    > distance :722 at N :1058 at O4
    > distance :720 at N :1058 at O4
    > distance :740 at O :720 at N
    > angle :1058 at C2 :1058 at O2 :741 at HD1 :741 at ND1
    > Reply Log output:
    > Distance between FDM 1058 O2 and HID 741 ND1: 2.8
    > Distance between TYR 730 OH and HID 741 NE2: 2.8
    > Distance between THR 721 OG1 and FDM 1058 N5: 3.4
    > Distance between ILE 718 O and FDM 1058 N3: 3.2
    > Distance between THR 721 N and FDM 1058 O4: 2.9
    > Distance between GLY 722 N and FDM 1058 O4: 3.2
    > Distance between GLN 720 N and FDM 1058 O4: 3.2
    > Distance between GLN 740 O and GLN 720 N: 3.0
    > Dihedral #0:1058 at C2 #0:1058 at O2 #0:741 at HD1 #0:741 at ND1: -51.0515
    > Problem in per-frame script:
    > Distance monitor already exists
    > Thank you for any assistance,
    > Anne-Frances

    Chimera-users mailing list: Chimera-users at cgl.ucsf.edu
    Manage subscription: https://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Distances_figures.jpg
Type: image/jpeg
Size: 304218 bytes
Desc: Distances_figures.jpg
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20211210/6095dbcd/attachment-0001.jpg>

More information about the Chimera-users mailing list