| Bsoft 2.0.5 Bernard's software package

bmodsym.cpp
Go to the documentation of this file.
1
9 #include "rwmodel.h"
10 #include "model_util.h"
11 #include "model_transform.h"
12 #include "model_symmetry.h"
13 #include "model_map.h"
14 #include "model_select.h"
15 #include "model_links.h"
16 #include "utilities.h"
17 #include "options.h"
18 #include "timer.h"
19
20 // Declaration of global variables
21 extern int verbose; // Level of output to the screen
22
23 /* Usage assistance */
24 const char* use[] = {
25 " ",
26 "Usage: bmodsym [options] in1.star [in2.star...]",
27 "-----------------------------------------------",
28 "Manipulates models.",
29 " ",
30 "Actions for preparation:",
31 "-merge Merge models in different files rather than concatenate.",
32 "-all Reset selection to all models and components before other selections.",
33 " ",
34 "Selections:",
35 "-select #232@14 Select models and components.",
36 " ",
37 "Actions:",
38 "-center Center before all other operations.",
39 "-map image.pif,2 Map and image number associated with model.",
40 "-setasu D8 Set components to within an asymmetric unit.",
41 "-apply T Apply point group symmetry.",
42 "-symmetrize C5 Symmetrize for a point group symmetry.",
43 "-separate D7 Generate separate symmetry-related models.",
44 "-find 3,12 Find component cyclic symmetry in the given order range.",
45 " ",
46 "Actions for finishing:",
47 "-reset Reset selection to all components before other selections.",
48 " ",
49 "Parameters:",
50 "-verbose 7 Verbose output.",
51 "-componentradius 8.4 Set display radius for all components.",
52 "-linkradius 5.1 Set display radius for all links.",
53 "-origin 0,22.5,30 Set the symmetry origin.",
54 " ",
55 "Parameters for finding symmetry:",
56 "-annuli 3,12 Annular range to find cyclic symmetry (pixels).",
57 " If not specified, taken from component radius.",
58 "-width 10 Annular width to find cyclic symmetry (pixels).",
59 " ",
60 "Input:",
61 "-parameters param.star Input parameter file.",
62 " ",
63 "Output:",
64 "-output file.star Output model parameter file.",
65 "-split 3 Split models into individual files:",
66 " Argument: 1-6: number of digits inserted before extension",
67 " Argument: \"id\": model ID's are used as file names.",
68 " ",
69 NULL
70 };
71
72 int main(int argc, char **argv)
73 {
74 /* Initialize variables */
75 int all(0); // Keep selection as read from file
76 int reset(0); // Keep selection as ouput
77 Bstring mod_select; // Model and component selection
78 int center(0); // Flag to center the structure
79 Bstring map_name; // Density map reference
80 int img_num(0); // Image number in density map file
81 Vector3<double> origin; // Translate
82 long minorder(0), maxorder(0); // Order range for finding cyclic symmetry
83 long ann_min(0), ann_max(0); // Annular range in pixels for finding cyclic symmetry
84 long ann_width(0); // Annular width in pixels for finding cyclic symmetry
85 Bstring asu_sym; // Set coordinates within the ASU
86 Bstring symmetry_apply_string; // Point group string
87 Bstring symmetrize_string; // Point group string
88 Bstring separate_symmetrize; // Point group string
89 Bstring find_sym; // Point group string
90 double comprad(0); // Component display radius
91 double linkrad(0); // Link display radius
92 View ref_view; // Reference view
93 Bstring atom_select("all");
94 Bstring paramfile; // Input parameter file name
95 Bstring outfile; // Output parameter file name
96 int split(0); // Sets output of multiple single-model files
97 Bstring astr;
98
99 int optind;
100 Boption* option = get_option_list(use, argc, argv, optind);
101 Boption* curropt;
102 for ( curropt = option; curropt; curropt = curropt->next ) {
103 if ( curropt->tag == "all" ) all = 1;
104 if ( curropt->tag == "reset" ) reset = 1;
105 if ( curropt->tag == "select" )
106 mod_select = curropt->value;
107 if ( curropt->tag == "center" ) center = 1;
108 if ( curropt->tag == "map" ) {
109 map_name = curropt->value;
110 img_num = (map_name.post(',')).integer();
111 map_name = map_name.pre(',');
112 if ( map_name.length() < 1 )
113 cerr << "-map: A file name must be specified!" << endl;
114 }
115 if ( curropt->tag == "parameters" )
116 paramfile = curropt->filename();
117 if ( curropt->tag == "setasu" )
118 asu_sym = curropt->symmetry_string();
119 if ( curropt->tag == "apply" )
120 symmetry_apply_string = curropt->symmetry_string();
121 if ( curropt->tag == "symmetrize" )
122 symmetrize_string = curropt->symmetry_string();
123 if ( curropt->tag == "separate" )
124 separate_symmetrize = curropt->symmetry_string();
125 if ( curropt->tag == "find" )
126 if ( curropt->values(minorder, maxorder) < 2 )
127 cerr << "-find: Minimum and maximum orders must be specified!" << endl;
128 if ( curropt->tag == "componentradius" )
129 if ( ( comprad = curropt->value.real() ) < 1 )
130 cerr << "-componentradius: A display radius must be specified!" << endl;
131 if ( curropt->tag == "linkradius" )
132 if ( ( linkrad = curropt->value.real() ) < 1 )
133 cerr << "-linkradius: A radius must be specified!" << endl;
134 if ( curropt->tag == "origin" )
135 origin = curropt->origin();
136 if ( curropt->tag == "annuli" )
137 if ( curropt->values(ann_min, ann_max) < 1 )
138 cerr << "-annuli: An annular range must be specified!" << endl;
139 if ( curropt->tag == "width" )
140 if ( ( ann_width = curropt->value.integer() ) < 1 )
141 cerr << "-width: An annular width must be specified!" << endl;
142 if ( curropt->tag == "reference" )
143 ref_view = curropt->view();
144 if ( curropt->tag == "output" )
145 outfile = curropt->filename();
146 if ( curropt->tag == "split" ) {
147 if ( curropt->value.contains("id") || curropt->value.contains("ID") ) split = 9;
148 else if ( ( split = curropt->value.integer() ) < 1 )
149 cerr << "-split: An integer must be specified!" << endl;
150 else
151 if ( split > 6 ) split = 6;
152 }
153 }
154 option_kill(option);
155
156 double ti = timer_start();
157
158 // Read all the parameter files
159 Bstring* file_list = NULL;
160 while ( optind < argc ) string_add(&file_list, argv[optind++]);
161 if ( !file_list ) {
162 cerr << "Error: No model files specified!" << endl;
163 bexit(-1);
164 }
165
166 Bmodel* model = read_model(file_list, paramfile);
167 string_kill(file_list);
168
169 if ( !model ) {
170 cerr << "Error: Input file not read!" << endl;
171 bexit(-1);
172 }
173
174 if ( all ) models_process(model, model_reset_selection);
175
176 if ( mod_select.length() ) model_select(model, mod_select);
177
178 if ( map_name.length() ) {
179 model->fmap = map_name;
180 model->img_num = img_num;
181 }
182
183 if ( comprad > 0 ) models_process(model, comprad, model_set_component_radius);
184
185 if ( linkrad > 0 ) models_process(model, linkrad, model_set_link_radius);
186
187 if ( center ) models_process(model, model_center);
188
189 if ( asu_sym.length() ) models_process(model, asu_sym, model_find_asymmetric_unit);
190
191 if ( symmetry_apply_string.length() )
192 model_apply_point_group(model, symmetry_apply_string, origin, ref_view);
193
194 if ( symmetrize_string.length() )
195 models_process(model, symmetrize_string, model_symmetrize);
196
197 if ( separate_symmetrize.length() )
198 model_symmetry_related(model, separate_symmetrize);
199
200 if ( maxorder )
201 model_component_symmetry(model, 360, ann_min, ann_max, ann_width, 0, 0, 0, minorder, maxorder);
202
203 if ( reset ) models_process(model, model_reset_selection);
204
205 model_selection_stats(model);
206
207 // Write an output parameter format file if a name is given
208 if ( model && ( outfile.length() || split == 9 ) ) {
209 model->split = split;
210 model_update_comment(model, argc, argv);
211 write_model(outfile, model);
212 }
213
214 model_kill(model);
215
216 if ( verbose & VERB_TIME )
217 timer_report(ti);
218
219 bexit(0);
220 }
221
Bmodel::img_num
int img_num
Definition: rwmodel.h:127
model_map.h
Header file for model to map conversions.
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
Bstring::post
Bstring post(char c)
Definition: Bstring.cpp:394
Boption::symmetry_string
Bstring symmetry_string()
Definition: options.h:245
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.
use
const char * use[]
Definition: bmodsym.cpp:24
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
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
Boption::view
View view()
Definition: options.h:259
Boption
A class for a command line input option.
Definition: options.h:26
Bstring::pre
Bstring pre(char c)
Definition: Bstring.cpp:381
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
model_symmetrize
long model_symmetrize(Bmodel *model, Bstring &symmetry_string)
Symmetrize a model.
Definition: model_symmetry.cpp:282
main
int main(int argc, char **argv)
Definition: bmodsym.cpp:72
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
model_apply_point_group
long model_apply_point_group(Bmodel *model, Bstring &symmetry_string, Vector3< double > origin, View ref_view, int flags=0)
Applying symmetry to model components.
Definition: model_symmetry.cpp:71
verbose
int verbose
model_symmetry_related
long model_symmetry_related(Bmodel *model, Bstring &symmetry_string)
Generates a list of symmetry-related models.
Definition: model_symmetry.cpp:376
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
Bmodel::fmap
Bstring fmap
Definition: rwmodel.h:125
rwmodel.h
Header file for reading and writing atomic model files.
Vector3< double >
Boption::origin
Vector3< double > origin()
Definition: options.h:180
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
View
Definition: View.h:26
model_center
long model_center(Bmodel *model)
Shifts one models to its center of mass.
Definition: model_transform.cpp:27
model_component_symmetry
int model_component_symmetry(Bmodel *model, long nangles, long ann_min, long ann_max, long ann_width, long zmin, long zmax, long zinc, long minorder, long maxorder)
Determines the cyclic symmetry of components.
Definition: model_map.cpp:618
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.
models_process
long models_process(Bmodel *model, long(modfunc)(Bmodel *))
Process a list of models using the specified function.
Definition: model_util.cpp:36
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