55 cout <<
"Model component occupancy:" << endl;
56 cout <<
"Molecular weight: " << mol_weight <<
" Da (rho = " << rho <<
" Da/Å)" << endl;
57 cout <<
"Component coverage cutoff: " << cutoff << endl << endl;
63 if ( invert_flag ) p->
invert();
72 cout <<
"Intensity Threshold for MW = " << mol_weight <<
" is " << threshold << endl;
81 cout <<
"Model\tComponent\tdx\tdy\tdz\tDensity\tCoverage\tOccupancy" << endl;
82 for ( comp = mp->
comp; comp; comp = comp->
next ) {
87 if ( f >= cutoff ) comp->
sel = 1;
90 shift = comp->
loc - comp->
vec;
92 cout << mp->
id <<
tab << comp->
id <<
tab << fixed <<
93 setprecision(2) << shift[0] <<
tab << shift[1] <<
tab << shift[2] <<
tab <<
127 long& ncomp, vector<double>& prob,
double& R)
129 long i, j, k, h, occ, bins, nsets(3+nfit);
137 vector<double> dist(bins);
138 vector<double> disterrfit(bins*nsets);
139 vector<double> sum(bins);
140 vector<double> sum2(bins);
142 for ( i=k=0; i<bins; i++ ) {
143 dist[i] = sum[i] = sum2[i] = 0;
144 for ( j=0; j<nsets; j++, k++ ) disterrfit[k] = 0;
148 for ( occ=0, comp = mp->
comp; comp; comp = comp->
next )
149 if ( comp->
fom >= cutoff ) occ++;
152 for ( s=0, i=0; i<bins; i++ ) s += disterrfit[i];
153 for ( i=0; i<bins; i++ ) disterrfit[i] /= s;
156 for ( c = cutoff - 0.2; c <= cutoff + 0.2; c += 0.1 ) {
157 for ( i=0; i<bins; i++ ) dist[i] = 0;
159 for ( occ=0, comp = mp->
comp; comp; comp = comp->
next )
160 if ( comp->
fom >= c ) occ++;
163 for ( s=0, i=0; i<bins; i++ ) s += dist[i];
164 for ( i=0; i<bins; i++ ) {
167 sum2[i] += dist[i]*dist[i];
171 for ( i=0, j=bins; i<bins; i++, j++ ) {
172 s = sum2[i]/5 - sum[i]*sum[i]/25;
173 if ( s > 0 ) disterrfit[j] = sqrt(s);
179 for ( i=0, k=nfit; i<nfit-1; i++, k++ ) {
180 for ( j=i+1, h=j+nfit; j<nfit; j++, h++ ) {
181 if ( prob[k] > prob[h] ) {
182 swap(prob[i], prob[j]);
183 swap(prob[k], prob[h]);
188 for ( i=0, j=3; i<nfit; i++, j++ ) {
189 for ( k=0, h=j*bins; k<bins; k++, h++ )
190 disterrfit[h] =
Bnpk(ncomp, prob[nfit+i], k, prob[i]);
191 for ( k=0, h=2*bins; k<bins; k++, h++ )
192 disterrfit[h] += disterrfit[j*bins+k];
197 cout << endl <<
"Binomial distributions:" << endl;
198 cout <<
"#\tWeight\tProbability" << endl;
199 for ( i=0; i<nfit; i++)
200 cout << i+1 <<
tab << prob[i] <<
tab << prob[nfit+i] << endl;
201 cout <<
"Residual: " << R << endl;
202 cout << endl <<
"Occup\t Models\t Std\t Fit";
203 for ( j=0; j<nfit; j++) cout <<
"\tB" << j+1;
206 for ( i=0; i<bins; i++ ) {
207 cout << i <<
tab << disterrfit[i] <<
tab << disterrfit[bins+i] <<
tab << disterrfit[2*bins+i];
208 for ( j=0; j<nfit; j++)
209 cout <<
"\t " << disterrfit[(3+j)*bins+i];
238 double hires,
double lores,
double max_shift)
240 if ( max_shift <= 0 ) max_shift = 1e37;
244 cerr <<
"Error: No model map file read! (" <<
model->
fmap <<
")" << endl;
255 if ( hires > lores ) swap(hires, lores);
262 cout <<
"Refinement of component locations for model " <<
model->
id <<
":" << endl;
263 cout <<
"Radius for determination of average intensity: " << radius <<
" voxels" << endl;
264 cout <<
"Radius for cross-correlation search: " << searchradius <<
" voxels" << endl << endl;
265 cout <<
"Refining component positions:" << endl;
266 cout <<
"Resolution limits: " << hires <<
" " << lores <<
" A" << endl;
267 cout <<
"Maximum shift: " << max_shift <<
" A" << endl;
268 cout <<
"Search radius: " << searchradius << endl;
269 cout <<
"Density radius: " << radius << endl << endl;
274 double cc, dist12, dist10, dist20;
275 double sigma1, sigma2;
276 double ccmax, s, d, ccavg(0), d1avg(0), d2avg(0);
291 int* num =
new int[ptemp->
images()];
292 for ( n=0; n<ptemp->
images(); n++ ) num[n] = 0;
296 for ( ncomp=0, comp =
model->
comp; comp; comp = comp->
next, ncomp++ ) {
298 loc = comp->
loc/scale + map_origin;
306 pcomp = p->
extract(0, loc, size, origin, mat);
308 if ( pmask ) pmaskrot = pmask->
extract_wrap(0, size, mat);
309 for ( n=0; n<ptemp->
images(); n++ ) {
313 shift = pcomp->
find_shift(pone, pmaskrot, hires, lores, searchradius, 0, 0, cc);
315 cout <<
"Shift = " << shift << endl;
319 comp_shift = mat * shift;
327 comp->
loc = scale * (loc - map_origin);
328 comp_shift = comp->
loc - comp->
vec;
330 p->
density(0, loc, radius, sigma2);
332 cout <<
"Sigma1=" << sigma1 <<
"\t Sigma2=" << sigma2 << endl;
333 s = comp_shift.length();
336 for ( comp2 =
model->
comp; comp2 && comp2 != comp; comp2 = comp2->
next ) {
339 if ( dist12 < diameter ) {
342 if ( dist10 < dist20 ) {
352 if ( s > 0 && s < max_shift && sigma1 > sigma2 ) {
358 cout <<
"Component " << ncomp+1 <<
" was not shifted!" << endl;
364 cout <<
"Comp\tdx\tdy\tdz\tShift\tCC\tDens1\tDens2\tdDens" << endl;
366 for ( ncomp=0, comp =
model->
comp; comp; comp = comp->
next, ncomp++ ) {
371 comp_shift = comp->
loc - comp->
vec;
372 shift_avg += comp_shift;
375 cout << ncomp+1 <<
tab << comp_shift[0] <<
tab << comp_shift[1]
387 cout <<
"Average\t" << shift_avg[0] <<
tab << shift_avg[1] <<
tab
388 << shift_avg[2] <<
tab << s <<
tab << ccavg <<
tab << d1avg
389 <<
tab << d2avg <<
tab << d2avg - d1avg << endl << endl;
390 cout <<
"Component type distribution:\n#\tCount" << endl;
391 for ( n=0; n<ptemp->
images(); n++ ) cout << n+1 <<
tab << num[n] << endl;
419 double a(1), b(1), c(1), fx, fy, fz;
420 double value, fraction(0);
432 cout <<
"DEBUG component_coverage: start=" << start << endl;
433 cout <<
"DEBUG component_coverage: end=" << end << endl;
436 if ( ( start[0] < 0 ) && ( end[0] < 0 ) )
return 0;
437 if ( ( start[1] < 0 ) && ( end[1] < 0 ) )
return 0;
438 if ( ( start[2] < 0 ) && ( end[2] < 0 ) )
return 0;
439 if ( ( start[0] >= p->
sizeX() ) && ( end[0] >= p->
sizeX() ) )
return 0;
440 if ( ( start[1] >= p->
sizeY() ) && ( end[1] >= p->
sizeY() ) )
return 0;
441 if ( ( start[2] >= p->
sizeZ() ) && ( end[2] >= p->
sizeZ() ) )
return 0;
442 start = start.
max(0);
444 if ( start[0] >= p->
sizeX() ) start[0] = p->
sizeX() - 1;
445 if ( start[1] >= p->
sizeY() ) start[1] = p->
sizeY() - 1;
446 if ( start[2] >= p->
sizeZ() ) start[2] = p->
sizeZ() - 1;
447 if ( end[0] >= p->
sizeX() ) end[0] = p->
sizeX() - 1;
448 if ( end[1] >= p->
sizeY() ) end[1] = p->
sizeY() - 1;
449 if ( end[2] >= p->
sizeZ() ) end[2] = p->
sizeZ() - 1;
450 if ( start[0] > end[0] ) swap(start[0], end[0]);
451 if ( start[1] > end[1] ) swap(start[1], end[1]);
452 if ( start[2] > end[2] ) swap(start[2], end[2]);
456 center[0] = start[0] + size[0]/2.0;
457 center[1] = start[1] + size[1]/2.0;
458 center[2] = start[2] + size[2]/2.0;
459 if ( size[0] ) a = 2.0/size[0];
460 if ( size[1] ) b = 2.0/size[1];
461 if ( size[2] ) c = 2.0/size[2];
467 cout <<
"DEBUG component_coverage: start=" << start << endl;
468 cout <<
"DEBUG component_coverage: end=" << end << endl;
469 cout <<
"DEBUG component_coverage: center=" << center << endl;
472 for ( n=0, z=start[2]; z<=end[2]; z++ ) {
475 for ( y=start[1]; y<=end[1]; y++ ) {
478 for ( x=start[0]; x<=end[0]; x++ ) {
481 if ( fx + fy + fz <= 1 ) {
482 i = p->
index(0, x, y, z, img_num);
484 if ( value > threshold ) np++;
491 if ( n ) fraction = np*1.0L/n;