29 "Usage: jpartdif [options] input1.star input2.star",
30 "-------------------------------------------------",
31 "Calculates the difference in the particle parameters,",
32 "or selects particles based on the fom difference.",
35 "-verbose 7 Verbosity of output.",
36 "-consolidate Only consolidate particles based on distance.",
37 "-locdiff Calculate the difference in the locations.",
38 "-fomdiff Calculate the difference in the foms.",
39 "-printlocdiff Print the difference in the locations.",
40 "-printanglediff Print the difference in the view angle.",
41 "-printalphadiff Print the difference in the alpha angles.",
42 "-thrlocdiff 10.0 Analyse only particles below threshold (pixels).",
43 "-thranglediff 20.0 Analyse only particles below threshold (degrees).",
44 "-remove Remove all particles with selection number 0.",
47 "-output file.star Output parameter file.",
53 int main(
int argc,
char** argv)
59 int locdiff(0), fomdiff(0);
60 int printlocdiff(0), printanglediff(0), printalphadiff(0);
61 double anglediffthr(-1), locdiffthr(-1);
65 for ( curropt = option; curropt; curropt = curropt->
next ) {
66 if ( curropt->
tag ==
"consolidate" )
68 if ( curropt->
tag ==
"locdiff" )
70 if ( curropt->
tag ==
"printlocdiff" )
72 if ( curropt->
tag ==
"printanglediff" )
74 if ( curropt->
tag ==
"printalphadiff" )
76 if ( curropt->
tag ==
"fomdiff" )
78 if ( curropt->
tag ==
"output" )
80 if ( curropt->
tag ==
"thrlocdiff" )
81 if ( ( locdiffthr = curropt->
value.
real() ) < 0.001 )
82 cerr <<
"-thrlocdiff: A threshold must be specified!" << endl;
83 if ( curropt->
tag ==
"thranglediff" )
84 if ( ( anglediffthr = curropt->
value.
real() ) < 0.001 )
85 cerr <<
"-thranglediff: A threshold must be specified!" << endl;
108 double locresid(0), angleresid(0), alpharesid(0), sumlocresid2(0), sumangleresid2(0), sumalpharesid2(0), alpha1, alpha2;
115 int closest_part_id(-1), found(0), npart(0);
118 for ( rec1 = project1->
rec, rec2=project2->
rec ; rec1 && rec2; rec1=rec1->
next, rec2=rec2->
next ) {
119 for ( part1 = rec1->
part; part1 ; part1 = part1->
next ) {
122 for ( part2 = rec2->
part; part2 ; part2 = part2->
next ) {
126 closest_part_id = part2->
id;
131 if ( part3->
id == closest_part_id ) {
134 if ( found ) { break ; }
142 part->
fom[0] = part1->
fom[0];
146 if (part1->
fom[0] > part3->
fom[0] ) {
150 part3->
fom[0] = part1->
fom[0];
158 for ( rec1 = project1->
rec, rec2=project2->
rec ; rec1 && rec2; rec1=rec1->
next, rec2=rec2->
next ) {
159 for ( part1 = rec1->
part; part1 ; part1 = part1->
next ) {
161 for ( part2 = rec2->
part; part2 ; part2 = part2->
next ) {
162 if ( part1->
id == part2->
id ) {
168 part->
fom[0] = part1->
fom[0];
172 if ( part1->
sel > 0 ) {
173 if ( locdiff ) { part->
loc = part1->
loc - part2->
loc; }
174 if ( fomdiff ) { part->
fom[0] = part1->
fom[0] - part2->
fom[0]; }
187 angleresid = part1_view.
angle(part2_view);
188 angleresid = angleresid *180.0/
M_PI;
197 while ( alpha1 < 0 ) { alpha1 += 120; }
198 while ( alpha2 < 0 ) { alpha2 += 120; }
200 while ( alpha1 >= 120 ) { alpha1 -= 120; }
201 while ( alpha2 >= 120 ) { alpha2 -= 120; }
206 alpharesid = fabs(alpha1 - alpha2);
207 if ( (120 - fabs(alpha1 - alpha2)) < alpharesid ) { alpharesid = 120 - fabs(alpha1 - alpha2); }
210 if (
verbose &
VERB_PROCESS ) { cout <<
"Part1 ID: " << part1->
id <<
"\tPart2 ID: " << part2->
id <<
tab << locresid <<
tab << angleresid <<
tab << alpharesid <<
tab << alpha1 <<
tab << alpha2 << endl; }
212 if ( ( locdiffthr < 0 || locresid <= locdiffthr ) && ( anglediffthr < 0 || angleresid <= anglediffthr )) {
214 sumlocresid2 += locresid * locresid;
215 sumangleresid2 += angleresid * angleresid;
216 sumalpharesid2 += alpharesid * alpharesid;
228 if ( printlocdiff ) { cout <<
"Location RMSD\t" << sqrt(sumlocresid2/npart) <<
"\tParticles: " << npart << endl; }
229 if ( printanglediff ) { cout <<
"Angle RMSD:\t" << sqrt(sumangleresid2/npart) <<
"\tParticles: " << npart << endl; }
230 if ( printalphadiff ) { cout <<
"Alpha RMSD:\t" << sqrt(sumalpharesid2/npart) <<
"\tParticles: " << npart << endl; }