From: Maxim Belkin (mbelkin_at_ks.uiuc.edu)
Date: Tue Feb 04 2014 - 16:00:03 CST

Hi Ali,

If you want to save centers of mass of water molecules only, you should use the fact that its COM is very close to its oxygen atom. Then, you can simply extract trajectories of all water oxygens from your TRR file. To do that:

1. Load your psf/pdb or just pdb file into VMD

2. Make a selection of necessary oxygens, like:
set sel [atomselect top “name OH2”]; # or set sel [atomselect top “oxygen”]

3. Write their indices:
set ch [open “oxygen_indices.txt” w]
puts $ch [$sel get index]
close ch

4. Use catdcd to extract trajectory for those oxygen atoms
catdcd -otype TRR -o output.trr -i oxygen_indices.txt your_input_file.trr

Try that and let us know if it works for you.
 
Maxim

On Feb 4, 2014, at 3:21 PM, Ali Alizadeh <ali.alizadehmoj_at_gmail.com> wrote:

> Dear Axel,
>
> I asked you a question about saving COM trajectory fro atomic trajectories. I've written this code but I can not save the coordination of each atom as a standard COM
>
> trajectory. This code can calculate the COM of each atom in each frame. I need your advice for building COM trajectory. My simulation box includes 500 water
>
> molecules.
>
> -------------
>
> set file [open "COM.xyz" w]
> set nf [molinfo top get numframes]
> for {set i 0} {$i <=$nf} {incr i} {animate dup frame $i
> animate goto $i} {
> puts $file "500"
> puts $file "frame $i"
> puts "frame $i"
> for {set x 0} {$x <=1500} {incr x 3} {
> set sel [atomselect top "index $x" frame $i]
> set com [measure center $sel weight [$sel get mass]]
> puts $file "C $com"
> }
>
> }
>
> close $file
>
> ---------------------
>
>
>
> On Mon, Dec 9, 2013 at 7:56 PM, Ali Alizadeh <ali.alizadehmoj_at_gmail.com> wrote:
>
> Dear Axel,
>
> Thank you for your complete and useful reply. I'll try to write each separately and then combine them.
>
>
> On Mon, Dec 9, 2013 at 8:21 AM, Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:
> On Mon, Dec 9, 2013 at 4:55 PM, Ali Alizadeh <ali.alizadehmoj_at_gmail.com> wrote:
> > Dear Axel,
> >
> > Thank you very much for your reply.
> >
> > I know I am ready for scripting but If possible I need some guides. I have
> > found I can calculate the COM of molecules but I do not know how I can
> >
> > save them and write in to standard trajectory.
>
> here is the recipe in 'vmd shorthand':
> you need to build a new molecule with "mol new atoms ###" where ### is
> the number of molecules, create a selection for this molecule
> containing all atoms with atomselect, and then loop over the existing
> trajectory, collect the COMs in a list of xyz coordinate triples,
> create a new frame in the new molecule with "animate dup", then step
> the selection to that frame and assign the coordinate list to the {x y
> z} property.
>
> once the loop is complete, you can save the new molecule as a .dcd or
> similar file. for easier processing, you may assign some other
> properties (type, name, mass, etc.) to the atoms in the molecule and
> write out a .psf file as well.
>
> more detailed explanations for all those steps are in the users guide
> and some examples for parts of these tasks are in some of the
> available tutorials as well. each step by itself is fairly simple, the
> complications come from having to combine and properly assemble all of
> them. you are better off first writing small test scriptlets where you
> practice each feature and piece separately until you are confident to
> know what you are doing. any more detailed guide would be the same as
> writing the script directly.
>
> axel.
>
> >
> >
> > On Mon, Dec 9, 2013 at 6:32 AM, Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:
> >>
> >> Possible? Yes.
> >> Automatic? No.
> >>
> >> It would require quite a bit of custom vmd scripting. Not very difficult,
> >> but you would have to combine different pieces of scripting that have been
> >> discussed before.
> >>
> >> Axel.
> >> --
> >> Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0
> >> International Centre for Theoretical Physics, Trieste. Italy.
> >> ________________________________
> >> From: Ali Alizadeh <ali.alizadehmoj_at_gmail.com>
> >> Sender: owner-vmd-l_at_ks.uiuc.edu
> >> Date: Mon, 9 Dec 2013 16:39:30 +0330
> >> To: Vmd l<vmd-l_at_ks.uiuc.edu>
> >> Subject: vmd-l: Atomic trajectory to COM trajectory,
> >>
> >>
> >> Dear All users,
> >>
> >> I have done an NVT ensemble with LAMMPS package. I have saved its
> >> trajectory in trr format.
> >>
> >> Now, I want to convert that atomic trajectory to trajectory of center of
> >> mass of molecules. Is it
> >>
> >> possible? Does any body have experience? I want to do this for calculation
> >> of density and g(r)
> >>
> >> values of COMs in VMD. Can I save the coordinates of atomic trajectory of
> >> atoms as COM
> >>
> >> trajectory?
> >>
> >>
> >> --
> >> Sincerely
> >>
> >> Ali Alizadeh
> >
> >
> >
> >
> > --
> > Sincerely
> >
> > Ali Alizadeh
>
>
>
> --
> Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0
> International Centre for Theoretical Physics, Trieste. Italy.
>
>
>
> --
> Sincerely
>
> Ali Alizadeh
>
>
>
> --
> Sincerely
>
> Ali Alizadeh