[gmx-users] question

Teemu Murtola teemu.murtola at gmail.com
Tue Jan 21 21:07:47 CET 2014


Instead of such a complicated script, I would use 'g_select -os', which
gives you the same output without any post-processing. Whether this matches
what the original poster wanted, or whether g_rdf is more suitable, depends
on what they want to count.

Best regards,
Teemu

On Tue, Jan 21, 2014 at 2:04 PM, <jkrieger at mrc-lmb.cam.ac.uk> wrote:

> Here is my python script as promised:
>
> # select filenames for reading and writing
> fr = open('chainA_T78-waters_index.ndx','r')
> fw = open('chainA_T78-waters_counts.xvg','w')
>
> line = fr.readline()
> t = line.split('_')[-1].split()[0]
> c = 0
>
> for line in fr:
>     if line.find('[') == -1:
>         c += len(line.split())
>     else:
>         fw.write(t + ' ' + str(c) + '\n')
>         t = line.split('_')[-1].split()[0]
>         c = 0
>
> fw.write(t + ' ' + str(c) + '\n')
>
> fr.close()
> fw.close()
>
> It reads in a file from g_select that looks as follows
> [ chain_A_T78_waters_0.000 ]
> 45170 45172 55565 55566 55567 217685 217686 217688 217689 217690 217709
> 217710 217711 355868 355870
> 380249 380250 380251
> [ chain_A_T78_waters_2.000 ]
> 55565 55566 55567 217686 217688 217689 217690 217709 217710 217711 289964
> 355868 355870 380249 380250
> 380251
> [ chain_A_T78_waters_4.000 ]
> 45170 45171 45172 55565 55566 55567 217688 217689 217690 217709 217710
> 217711 355869 367615 380249
> 380250 380251
>
> and write out a file with counts that looks like this that xmgrace can read
> 0.000 18
> 2.000 16
> 4.000 17
>
> Best wishes
> James
>
> > I have no experience with g_rdf but that looks like it might work if you
> > only want the average number. Anyhow I'm writing the script to count my
> > g_select output now and I'll send it to you soon. This script should
> allow
> > the number to be plotted over time.
> >
> > Best wishes
> > James
> >
> >> Dear Jkrieger
> >>
> >> Thanks for your attention.
> >>
> >> I have index file containing 2 group which are my interest.
> >>
> >> Unfortunately, I am beginner in scripting and I have no long time.
> >> I should do this analysis as soon as possible. Please if you write such
> >> a
> >> script, send me it.
> >>
> >> Is g_rdf -cn appropriate for my case?
>


More information about the gromacs.org_gmx-users mailing list