| Bsoft 2.0.5 Bernard's software package

bmodview.cpp
Go to the documentation of this file.
1
9 #include "rwmodel.h"
10 #include "model_views.h"
11 #include "model_util.h"
12 #include "model_transform.h"
13 #include "model_symmetry.h"
14 #include "model_select.h"
15 #include "model_links.h"
16 #include "ps_model.h"
17 #include "utilities.h"
18 #include "options.h"
19 #include "timer.h"
20
21 // Declaration of global variables
22 extern int verbose; // Level of output to the screen
23
24 /* Usage assistance */
25 const char* use[] = {
26 " ",
27 "Usage: bmodview [options] in1.star [in2.star...]",
28 "------------------------------------------------",
29 "Manipulates models.",
30 " ",
31 "Actions:",
32 "-merge Merge models in different files rather than concatenate.",
33 "-views local Calculate views for components. Modes: origin: current origin,",
34 " com: center-of-mass origin, map: map origin, local: neigbor plane.",
35 "-invert Invert views for selected components.",
36 "-setasu D6 Set components to within an asymmetric unit.",
37 "-directions 10,1 Histogram of component view directions with histogram bin width (degrees)",
38 " and a flag: 0=wrt z-axis, 1=wrt component locations.",
39 "-setfom 0.8 Set the FOM of selected components to a specific value.",
40 " ",
41 "Selections:",
42 "-all Reset selection to all models and components before other selections.",
43 "-select #232@14 Select models and components.",
44 " ",
45 "Parameters:",
46 "-verbose 7 Verbose output.",
47 "-componentradius 8.4 Set display radius for all components.",
48 "-linkradius 5.1 Set display radius for all links.",
49 "-combined The views for all models are combined (-Postscript option).",
50 "-separate Each model is defined as a separate molecule group (-coordinates option).",
51 " ",
52 "Input:",
53 "-parameters param.star Input parameter file.",
54 //"-reference file.pdb Reference coordinate file to set views.",
55 " ",
56 "Output:",
57 "-output file.star Output model parameter file.",
58 "-split 3 Split models into individual files:",
59 " Argument: 1-6: number of digits inserted before extension",
60 " Argument: \"id\": model ID's are used as file names.",
61 "-coordinates all.pdb Output coordinate files.",
62 "-Postscript plot.ps Output postscript file with a plot of views.",
63 " ",
64 NULL
65 };
66
67 int main(int argc, char **argv)
68 {
69 /* Initialize variables */
70 int reset(0); // Keep selection as read from file
71 Bstring mod_select; // Model and component selection
72 int merge(0); // Flag to merge models rather than concatenate
73 Bstring calc_views; // Mode to calculate component views
74 int inv_views(0); // Flag to invert views for selected components
75 Bstring asu_sym; // Point group string
76 int view_dir_bins(0); // Flag and histogram bin width to assess view directions
77 int view_dir_flag(0); // Flag to set the reference for view directions
78 double setfom(-1); // Value to set FOM to
79 double comprad(0); // Component display radius
80 double linkrad(0); // Link display radius
81 Bstring paramfile; // Input parameter file name
82 // Bstring reffile; // Reference file name
83 Bstring outfile; // Output parameter file name
84 Bstring coorfile; // Output coordinates file name
85 int split(0); // Output one big STAR file
86 int combined(0); // Flag to combine models for Postscript output
87 Bstring ps_file; // Postscript output
88
89 int optind;
90 Boption* option = get_option_list(use, argc, argv, optind);
91 Boption* curropt;
92 for ( curropt = option; curropt; curropt = curropt->next ) {
93 if ( curropt->tag == "all" ) reset = 1;
94 if ( curropt->tag == "select" ) mod_select = curropt->value;
95 if ( curropt->tag == "merge" ) merge = 1;
96 if ( curropt->tag == "views" ) calc_views = curropt->value.lower();
97 if ( curropt->tag == "invert" ) inv_views = 1;
98 if ( curropt->tag == "setasu" ) asu_sym = curropt->value.upper();
99 if ( curropt->tag == "directions" )
100 if ( curropt->values(view_dir_bins, view_dir_flag) < 1 )
101 cerr << "-directions: A histogram bin width in degrees must be specified!" << endl;
102 if ( curropt->tag == "setfom" )
103 if ( ( setfom = curropt->value.real() ) < 0 )
104 cerr << "-setfom: A FOM value must be specified!" << endl;
105 if ( curropt->tag == "componentradius" )
106 if ( ( comprad = curropt->value.real() ) <= 0 )
107 cerr << "-componentradius: A display radius must be specified!" << endl;
108 if ( curropt->tag == "linkradius" )
109 if ( ( linkrad = curropt->value.real() ) <= 0 )
110 cerr << "-linkradius: A radius must be specified!" << endl;
111 if ( curropt->tag == "combined" ) combined = 1;
112 if ( curropt->tag == "parameters" )
113 paramfile = curropt->filename();
114 if ( curropt->tag == "output" )
115 outfile = curropt->filename();
116 if ( curropt->tag == "split" ) {
117 if ( curropt->value.contains("id") || curropt->value.contains("ID") ) split = 9;
118 else if ( ( split = curropt->value.integer() ) < 1 )
119 cerr << "-split: An integer must be specified!" << endl;
120 else
121 if ( split > 6 ) split = 6;
122 }
123 if ( curropt->tag == "coordinates" )
124 coorfile = curropt->filename();
125 if ( curropt->tag == "Postscript" )
126 ps_file = curropt->filename();
127 }
128 option_kill(option);
129
130 double ti = timer_start();
131
132 // Read all the parameter files
133 Bstring* file_list = NULL;
134 while ( optind < argc ) string_add(&file_list, argv[optind++]);
135 if ( !file_list ) {
136 cerr << "Error: No model files specified!" << endl;
137 bexit(-1);
138 }
139
140 Bmodel* model = read_model(file_list, paramfile);
141 string_kill(file_list);
142
143 if ( !model ) {
144 cerr << "Error: Input file not read!" << endl;
145 bexit(-1);
146 }
147
148 if ( reset ) models_process(model, model_reset_selection);
149
150 if ( mod_select.length() ) model_select(model, mod_select);
151
152 if ( merge ) model_merge(model);
153
154 if ( comprad > 0 ) models_process(model, comprad, model_set_component_radius);
155
156 if ( linkrad > 0 ) models_process(model, linkrad, model_set_link_radius);
157
158 if ( setfom >= 0 ) model_set_fom(model, setfom);
159
160 if ( calc_views.length() ) model_calculate_views(model, calc_views);
161
162 if ( inv_views ) model_invert_views(model);
163
164 // cout << "Symmetry " << asu_sym << endl;
165 if ( asu_sym.length() ) models_process(model, asu_sym, model_find_asymmetric_unit);
166
167 if ( view_dir_bins ) model_view_directions(model, view_dir_bins, view_dir_flag);
168
169 if ( ps_file.length() )
170 ps_model_symmetry_views(ps_file, model, asu_sym, combined);
171
172 model_selection_stats(model);
173
174 // Write an output parameter format file if a name is given
175 if ( model && ( outfile.length() || split == 9 ) ) {
176 model->split = split;
177 model_update_comment(model, argc, argv);
178 write_model(outfile, model);
179 }
180
181 model_kill(model);
182
183 if ( verbose & VERB_TIME )
184 timer_report(ti);
185
186 bexit(0);
187 }
188
Bstring::real
double real()
Definition: Bstring.cpp:545
model_set_component_radius
long model_set_component_radius(Bmodel *model, double comprad)
Set the display radius for all components to a specific value.
Definition: rwmodel.cpp:1264
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:705
model_view_directions
long model_view_directions(Bmodel *model, int bin_width, int ref_flag)
Analyzes view directions in a model.
Definition: model_views.cpp:359
model_views.h
Library routines used for analysing model component views.
utilities.h
Header file for general utilities.
model_select
long model_select(Bmodel *model, Bstring &comptype)
Selects models, components and component types.
Definition: model_select.cpp:36
model_util.h
Library routines used for model processing.
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
Bmodel::split
int split
Definition: rwmodel.h:130
Bstring::length
long length() const
Definition: Bstring.cpp:263
model_symmetry.h
Library routines used for model symmetry operations.
ps_model_symmetry_views
int ps_model_symmetry_views(Bstring &filename, Bmodel *model, Bstring &symmetry_string, int combined)
Postscript plot of the distribution of model views.
Definition: ps_model.cpp:92
model_links.h
Library routines used for model link processing.
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
Boption::filename
Bstring filename()
Definition: options.h:85
timer.h
Utilities for timing functions.
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
verbose
int verbose
model_set_fom
long model_set_fom(Bmodel *model, double fom)
Set the FOM of selected components to a specific value.
Definition: rwmodel.cpp:1306
model_kill
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Definition: rwmodel.cpp:1124
model_set_link_radius
long model_set_link_radius(Bmodel *model, double linkrad)
Set the display radius for all links to a specific value.
Definition: model_links.cpp:139
use
const char * use[]
Definition: bmodview.cpp:25
Boption
A class for a command line input option.
Definition: options.h:26
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
model_update_comment
int model_update_comment(Bmodel *model, int n, char **strings)
Puts a set of strings and time in the comment of a model.
Definition: rwmodel.cpp:1158
merge
int merge(Bimage *p, int padd)
Pads an image and shifts it to the middle.
Definition: sin_gal.cpp:270
Bstring::upper
Bstring upper()
Definition: Bstring.cpp:316
model_find_asymmetric_unit
long model_find_asymmetric_unit(Bmodel *model, Bstring &symmetry_string)
Set model component locations within the asymmetric unit.
Definition: model_symmetry.cpp:34
model_selection_stats
long model_selection_stats(Bmodel *model)
Calculates selection statistics.
Definition: model_select.cpp:870
model
Bmodel * model
Definition: bshow.cpp:32
read_model
Bmodel * read_model(Bstring &filename)
Definition: rwmodel.cpp:28
write_model
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
Definition: rwmodel.cpp:91
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
model_reset_selection
long model_reset_selection(Bmodel *model)
Resets the selection to all components.
Definition: model_select.cpp:232
model_invert_views
long model_invert_views(Bmodel *model)
Invert views.
Definition: model_views.cpp:109
rwmodel.h
Header file for reading and writing atomic model files.
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
ps_model.h
Header file for postscript tools dealing with models.
Bstring::lower
Bstring lower()
Definition: Bstring.cpp:308
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
Bstring::integer
long integer()
Definition: Bstring.cpp:539
Bmodel
Definition: rwmodel.h:119
options.h
Header file for option handlers.
model_merge
long model_merge(Bmodel *model)
Merges components from all models into one.
Definition: model_util.cpp:299
main
int main(int argc, char **argv)
Definition: bmodview.cpp:67
models_process
long models_process(Bmodel *model, long(modfunc)(Bmodel *))
Process a list of models using the specified function.
Definition: model_util.cpp:36
model_calculate_views
long model_calculate_views(Bmodel *model, Bstring &mode)
Calculates the views associated with each component.
Definition: model_views.cpp:263
split
vector< string > split(const string &s)
Splits a string on whitespace.
Definition: string_util.cpp:92
model_select.h
Header file for reading and writing atomic model files.
model_transform.h
Library routines used for model transformation.
Boption::values
long values(T1 &v1, T2 &v2)
Definition: options.h:115
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760