 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
57 fpdb.open(filename.
c_str());
58 if ( fpdb.fail() )
return 0;
60 for ( ; part; part = part->
next ) {
63 shift = (part->
loc - part->
ori) * sampling;
65 for (
int i=0; i<3; i++ )
66 fpdb << fixed <<
"REMARK 350 BIOMT" << i+1 << setw(4) << part->
id
67 << setprecision(6) << setw(10) << mat[i][0]
68 << setw(10) << mat[i][1]
69 << setw(10) << mat[i][2]
70 << setprecision(5) << setw (15) << shift[i] << endl;
79 long part_sel,
double fom_cutoff,
double colorfom_min,
80 double colorfom_max,
RGB<double> color,
double diameter,
double length,
double thickness)
84 fcmm.open(filename.
c_str());
85 if ( fcmm.fail() )
return 0;
88 cout << endl <<
"Creating a Chimera marker file. Only the first datablock is used." << endl;
92 fcmm <<
"<marker_set name=\"" <<
id <<
"\">" << endl;
101 for ( ; part; part = part->
next ) {
107 loc = part->
loc * sampling;
111 if ( ((part_sel < 0) && (fom_cutoff < 0 )) || (part->
sel == part_sel) || ((fom_cutoff > 0) && (fom >= fom_cutoff)) ) {
113 if ( colorfom_min >= 0 ) {
115 if ( fom < colorfom_min ) { fom = colorfom_min; }
116 if ( fom > colorfom_max ) { fom = colorfom_max; }
119 fom = fom - colorfom_min;
120 fom = fom / (colorfom_max - colorfom_min);
129 fcmm <<
"<marker id=\"" << part->
id <<
"99999\" x=\"" << loc[0]
130 <<
"\" y=\"" << loc[1]
131 <<
"\" z=\"" << loc[2]
132 <<
"\" r=\"" << color.
r() <<
"\" g=\"" << color.
g() <<
"\" b=\"" << color.
b()
133 <<
"\" radius=\"" << thickness/2 <<
"\"/>" << endl;
136 fcmm <<
"<marker id=\"" << part->
id <<
"\" x=\"" << loc[0] + view[0] *
length
137 <<
"\" y=\"" << loc[1] + view[1] *
length
138 <<
"\" z=\"" << loc[2] + view[2] *
length
139 <<
"\" r=\"" << color.
r() <<
"\" g=\"" << color.
g() <<
"\" b=\"" << color.
b()
140 <<
"\" radius=\"" << diameter/2 <<
"\"/>" << endl;
143 fcmm <<
"<link id1=\"" << part->
id <<
"\" id2=\"" << part->
id
144 <<
"99999\" r=\"" << color.
r() <<
"\" g=\"" << color.
g() <<
"\" b=\"" << color.
b()
145 <<
"\" radius=\"" << thickness/2 <<
"\"/>" << endl;
152 fcmm <<
"</marker_set>" << endl;
156 cout << n <<
" markers written to " << filename << endl;
164 "Usage: jviews [options] [input.star]",
165 "------------------------------------",
166 "Creates and modifies particle views.",
169 "-Even Output evenly distributed views.",
170 "-Asymmetricunit Output all views within asymmetric unit.",
171 "-Grid 10 Output all views within angular distance from a given reference view.",
172 "-Related Output all symmetry related views for a given reference view and symmetry.",
173 "-Radial 75,75,75 Generate a view vector for each particle extending from the given point.",
174 "-Top 200 Assing one of the two top views (up/down) for each particle, depending if the particle is above or below the chosen Z slice.",
175 "-Segment Generate a view vector for each particle extending from the closest point on a line segment (defined as a filament in the input.star).",
176 "-Filament 100,10,5 Generate views covering a filament with a given radius, helical rise & twist (use with option -symmetry)",
177 " and input.star defining the ends of a filament.",
178 "-Random 100 Generate a number of random views.",
179 "-randomizealpha Randomize the angle around view vector (alpha).",
180 "-symmetry C10 Symmetry to use (default: C1 symmetry).",
181 "-recfile 3d.map Associate views with this reconstruction filename.",
182 "-angle 2 Angular sampling stepsize for theta and phi (default: 45 degrees).",
183 "-radius 75 Place particles views at given radius (default 0).",
184 "-shift 5 Shift particles by given amount along the view vectors (default 0).",
185 "-verbose 7 Verbosity of output.",
186 "-reference 0,0.618,1,0 Reference view (dafault: 0,0,1,0)",
187 "-sampling 1.5,1.5,1.5 Sampling (A/pixel; a single value can be given).",
188 "-origin 110,50,44 View origin (default: 0,0,0).",
189 "-discardz 20 Discard views with Z locations further from the Z origin (pixels).",
190 "-select 1 Process only particles with this selection number (default: all).",
191 "-invert Invert views in outputfile.",
193 "Chimera parameters:",
194 "-diameter 5 Chimera marker diameter (default: 2)",
195 "-length 100 Chimera link length (default: 10).",
196 "-thickness 5 Chimera link thickness (default: 2)",
197 "-color 0,0,1 Chimera marker & link color in RGB (default: 1,1,1).",
198 "-fomcolor 0.2,0.3 Chimera marker & link coloring range from blue to red based on particle FOM.",
201 "-output output.star Output parameter file",
202 "-cmm output.cmm Output Chimera marker file.",
203 "-pdb output.pdb Output PDB file with BIOMT matrixes.",
208 int main(
int argc,
char **argv)
214 int randomize_alpha(0);
219 double filament_ang(0);
220 double filament_rise(0);
222 Bstring symmetry_string =
"C1";
230 double angle_limit(0);
233 double fom_cutoff(-1);
234 double colorfom_min(-1), colorfom_max(-1);
236 double shiftparticle(0);
259 for ( curropt = option; curropt; curropt = curropt->
next ) {
261 if ( curropt->
tag ==
"Even") { mode = 1; }
263 if ( curropt->
tag ==
"Asymmetricunit") { mode = 1; }
265 if ( curropt->
tag ==
"Related") { mode = 2; }
266 if ( curropt->
tag ==
"symmetry") {
269 if ( curropt->
tag ==
"Random") {
271 cerr <<
"-Random: A number of views must be specified!" << endl;
278 if ( curropt->
tag ==
"Radial") {
279 vieworigin = curropt->
origin();
282 if ( curropt->
tag ==
"Grid") {
283 if ( ( angle_limit = curropt->
value.
real() ) < 0.001 ) {
284 cerr <<
"-Grid: An angular distance must be specified!" << endl;
288 angle_limit *=
M_PI/180.0;
292 if ( curropt->
tag ==
"Filament") {
293 if ( curropt->
values(shiftparticle, filament_rise, filament_ang) < 3 ) {
294 cerr <<
"-Filament: Filament radius, angular spacing and angular raise must be specified!" << endl << endl;
299 filament_ang *=
M_PI/180.0;
303 if ( curropt->
tag ==
"Segment") {
306 if ( curropt->
tag ==
"Top") {
308 cerr <<
"-Top: A value for the Z slice must be specified!" << endl << endl;
315 if ( curropt->
tag ==
"recfile")
317 if ( curropt->
tag ==
"radius") {
318 if ( ( rad = curropt->
value.
real() ) < 1 ) {
319 cerr <<
"-radius: A value for radius must be specified!" << endl << endl;
323 if ( rad < 0 ) { rad = 0; }
326 if ( curropt->
tag ==
"shift") {
327 if ( ( shiftparticle = curropt->
value.
real() ) < 0.001 ) {
328 cerr <<
"-shift: A value for shift must be specified!" << endl << endl;
335 if ( curropt->
tag ==
"sampling")
336 sampling = curropt->
scale();
337 if ( curropt->
tag ==
"origin") {
338 origin = curropt->
origin();
341 if ( curropt->
tag ==
"reference")
342 ref_view = curropt->
view();
344 if ( curropt->
tag ==
"length") {
346 cerr <<
"-length: A value for length must be specified!" << endl << endl;
350 if ( curropt->
tag ==
"angle") {
351 if ( ( angle = curropt->
value.
real() ) < 0.001 ) {
352 cerr <<
"-angle: An angular stepsize must be specified!" << endl << endl;
359 if ( curropt->
tag ==
"diameter") {
360 if ( ( diameter = curropt->
value.
real() ) < 0.001 ) {
361 cerr <<
"-diameter: A value for diameter must be specified!" << endl << endl;
365 if ( diameter < 1 ) { diameter = 1; }
368 if ( curropt->
tag ==
"thickness") {
369 if ( ( thickness = curropt->
value.
real() ) < 0.001 ) {
370 cerr <<
"-thickness: A value for thickness must be specified!" << endl << endl;
374 if ( thickness < 1 ) { thickness = 1; }
377 if ( curropt->
tag ==
"color") {
378 if ( curropt->
values(color[0], color[1], color[2]) < 3 ) {
379 cerr <<
"-color: Three values for color must be specified!" << endl << endl;
383 if ( curropt->
tag ==
"fomcolor") {
384 if ( curropt->
values(colorfom_min, colorfom_max) < 2 ) {
385 cerr <<
"-fomcolor: Two values for FOM range must be specified!" << endl << endl;
389 if ( curropt->
tag ==
"output")
391 if ( curropt->
tag ==
"cmm")
393 if ( curropt->
tag ==
"pdb")
395 if ( curropt->
tag ==
"select") {
397 cerr <<
"-select: A selection number must be specified!" << endl << endl;
401 if ( curropt->
tag ==
"fom") {
402 if ( ( fom_cutoff = curropt->
value.
real() ) < 0.001 ) {
403 cerr <<
"-fom: A threshold value must be specified!" << endl << endl;
407 if ( curropt->
tag ==
"invert")
409 if ( curropt->
tag ==
"randomizealpha")
427 part->
view = std_view;
448 cout << endl <<
"Creating all views within asymmetric unit:" << endl;
455 part_original = rec->
part;
458 for ( v=allviews; v; v=v->
next ) {
462 part->
loc = part_original->
loc;
463 part->
ori = part_original->
ori;
465 part->
sel = part_original->
sel;
466 part->
fom[0] = part_original->
fom[0];
479 cout << endl <<
"Creating all symmetry related views:" << endl;
484 part_original= rec->
part;
487 for ( part = part_original; part ; part=part->
next ) {
489 mat2 = (ref_view.
matrix()).transpose();
495 cout <<
"Using the reference view: " << view << endl;
500 for ( v=allviews; v; v=v->
next ) {
501 mat = (v->
matrix()).transpose();
511 part2->
fom[0] = part->
fom[0];
515 cout <<
tab << view << endl;
531 part_original = rec->
part;
535 cout << endl <<
"Creating " << nviews <<
" random views:" << endl;
540 for ( v=allviews; v; v=v->
next ) {
544 cout << view << endl;
548 part->
loc = part_original->
loc;
549 part->
ori = part_original->
ori;
551 part->
sel = part_original->
sel;
552 part->
fom[0] = part_original->
fom[0];
563 cout << endl <<
"Assigning views extending radially from the given point." << endl;
569 for ( part=rec->
part; part; part=part->
next ) {
571 view =
View(part->
loc[0] - vieworigin[0], part->
loc[1] - vieworigin[1],
572 part->
loc[2] - vieworigin[2], 0);
578 cout << view << endl;
594 cout << endl <<
"Creating all views within specified angular distance:" << endl << endl;
599 part_original = rec->
part;
602 for ( part=part_original; part; part=part->
next ) {
607 cout <<
"Using the reference view: " << view << endl;
612 for ( v=allviews; v; v=v->
next ) {
620 part2->
fom[0] = part->
fom[0];
624 cout << view << endl;
641 cout << endl <<
"Creating all views for a filamentous object:" << endl;
650 filament_rise, filament_rise, filament_ang);
654 for ( part=part_original; part; part=part->
next ) {
657 for ( v=allviews; v; v=v->
next ) {
691 cout << endl <<
"Assigning views extending from the closest point on a line segment from " << point1 <<
" to " << point2 << endl;
694 for ( part=rec->
part; part; part=part->
next ) {
699 cout << endl <<
"Closest point:\t" << vieworigin << endl;
701 view =
View(part->
loc[0] - vieworigin[0], part->
loc[1] - vieworigin[1], part->
loc[2] - vieworigin[2], 0);
707 cout << view << endl;
721 for ( part=rec->
part; part; part=part->
next ) {
722 if ( part->
loc[2] < locz ) { part->
view =
View(0,0,-1,0); }
723 else { part->
view =
View(0,0,1,0); }
729 if ( randomize_alpha ) {
732 for ( part=rec->
part; part; part=part->
next ) {
734 cout << endl <<
"Original view" << endl;
735 cout << part->
view << endl;
739 cout << endl <<
"View with random alpha" << endl;
740 cout << part->
view << endl;
749 for ( part=rec->
part; part; part=part->
next ) {
751 cout << endl <<
"Original view" << endl;
752 cout << part->
view << endl;
756 cout << endl <<
"Inverted view" << endl;
757 cout << part->
view << endl;
766 for ( part=rec->
part; part; part=part->
next ) {
771 (origin[1] + rad * view[1]),
772 (origin[2] + rad * view[2]));
780 for ( part=rec->
part; part; part=part->
next ) {
786 (loc[1] + shiftparticle * view[1]),
787 (loc[2] + shiftparticle * view[2]));
794 if ( set_origin == 1 ) {
797 for (part = rec->
part; part; part=part->
next ) { part->
ori = origin; }
802 if ( discardz > 0 ) {
804 for ( part=rec->
part; part; part=part->
next ) {
808 if (loc[2] < (origin[2] - discardz)) {part->
sel = 0;}
809 if (loc[2] > (origin[2] + discardz)) {part->
sel = 0;}
816 part_sel, fom_cutoff, colorfom_min,
817 colorfom_max, color, diameter,
length, thickness) )
818 cerr <<
"Cannot open cmm file for writing!" << endl << endl;
822 cerr <<
"Cannot open PDB file for writing!" << endl << endl;
A class for a command line input option.
int project_kill(Bproject *project)
Frees a whole project.
Header file for spline interpolation.
Vector3< double > scale()
View * symmetry_get_all_views(Bsymmetry *sym, View asu_view)
Get all symmetry-related views of one given view.
int string_kill(Bstring *list)
Kills a string linked list.
int main(int argc, char **argv)
int pdb_matrices_from_particles(Bparticle *part, Vector3< double > sampling, Bstring &filename)
Generates PDB file matrices from particle views and locations.
Matrix3 transpose() const
View * random_views(int nviews)
Calculates a set of random views.
Header file for functions for creating random images.
int bexit(int value)
Exit function for cleanup and debugging.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Header file for option handlers.
View * asymmetric_unit_views(Bsymmetry *sym, double theta_step, double phi_step, int flag)
Initializes a well-distributed set of views in an asymmetric unit.
Vector3< double > origin()
double length(vector< T > v)
Bproject * project_create(int nmg, int nrec)
Creates a micrograph processing project parameter structure.
long values(T1 &v1, T2 &v2)
Header file for reading and writing micrograph parameters.
int cmm_views(Bstring &filename, Bparticle *part, Vector3< double > sampling, long part_sel, double fom_cutoff, double colorfom_min, double colorfom_max, RGB< double > color, double diameter, double length, double thickness)
Utilities for timing functions.
Bstring symmetry_string()
View * views_within_limits(View theview, double theta_step, double phi_step, double alpha_step, double view_angle_limit, double alpha_angle_limit)
Generates a list of views within an angular distance from the input view.
double timer_start()
Starts timer and prints the time.
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Header file for general utilities.
ostream & tab(ostream &out)
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Bparticle * particle_add(Bparticle **part, int pid)
Adds a particle parameter structure to a linked list.
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Vector3< double > closest_point_line(Vector3< double > point, Vector3< double > endpoint1, Vector3< double > endpoint2)
Calculates the closest point on a line segment from a given point.
Header file for micrograph processing.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
A header file for STAR format files.
double irm(1.0L/get_rand_max())
long get_rand_max()
Finds the maximum random number for a system.
bool contains(const Bstring &s)
Header file for functions finding particles (subtomograms) in a tomogram.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.