VMD-L Mailing List
From: John Stone (johns_at_ks.uiuc.edu)
Date: Fri May 22 2009 - 10:57:39 CDT
- Next message: Axel Kohlmeyer: "Re: Question about introducing variables in "mol selection...""
- Previous message: Peter Freddolino: "Re: Question about introducing variables in "mol selection...""
- In reply to: Maria Sanchez: "RMSF"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hi,
It calculates the average position, then computes the variance for
each atom position in the selection, then takes the square root:
// Calculate RMS fluctuation of selected atoms over selected frames
extern int measure_rmsf(AtomSel *sel, MoleculeList *mlist,
int start, int end, int step, float *rmsf) {
if (!sel) return MEASURE_ERR_NOSEL;
if (sel->num_atoms == 0) return MEASURE_ERR_NOATOMS;
Molecule *mymol = mlist->mol_from_id(sel->molid());
int maxframes = mymol->numframes();
// accept value of -1 meaning "all" frames
if (end == -1)
end = maxframes-1;
if (maxframes == 0 || start < 0 || start > end ||
end >= maxframes || step <= 0)
return MEASURE_ERR_BADFRAMERANGE;
int i;
for (i=0; i<sel->selected; i++)
rmsf[i] = 0.0f;
int rc;
float *avpos = new float[3*sel->selected];
rc = measure_avpos(sel, mlist, start, end, step, avpos);
if (rc != MEASURE_NOERR) {
delete [] avpos;
return rc;
}
// calculate per-atom variance here
int frame, avcount, j;
for (avcount=0,frame=start; frame<=end; avcount++,frame+=step) {
const float *framepos = (mymol->get_frame(frame))->pos;
for (i=0, j=0; i<sel->num_atoms; i++) {
if (sel->on[i]) {
rmsf[j] += distance2(&avpos[3*j], &framepos[3*i]);
j++;
}
}
}
float avinv = 1.0f / (float) avcount;
for (j=0; j<sel->selected; j++) {
rmsf[j] = sqrtf(rmsf[j] * avinv);
}
delete [] avpos;
return MEASURE_NOERR;
}
On Thu, May 21, 2009 at 12:14:17AM -0400, Maria Sanchez wrote:
> Hi All,
>
> I want to learn how VMD calculates the RMSF. From a previous post, I know
> that for the frames and atom selected, it calculates an average position of
> the atom for the specified frames. I presume that then it calculates the
> distance between the average position and the position each time. But,
> my calculation doesn't match the result that I obtain using the rmsf
> function. Can somebody explain me how vmd does this calculation?
>
> Thanks,
> Maria Antonieta
-- NIH Resource for Macromolecular Modeling and Bioinformatics Beckman Institute for Advanced Science and Technology University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801 Email: johns_at_ks.uiuc.edu Phone: 217-244-3349 WWW: http://www.ks.uiuc.edu/~johns/ Fax: 217-244-6078
- Next message: Axel Kohlmeyer: "Re: Question about introducing variables in "mol selection...""
- Previous message: Peter Freddolino: "Re: Question about introducing variables in "mol selection...""
- In reply to: Maria Sanchez: "RMSF"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]