| Bsoft 2.0.5 Bernard's software package

bass.cpp
Go to the documentation of this file.
1
9 #include "rwmolecule.h"
10 #include "mol_edit.h"
11 #include "rwmodel.h"
12 #include "model_select.h"
13 #include "model_views.h"
14 #include "model_links.h"
15 #include "model_util.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: bass [options] in1.star [in2.star ...]",
27 "---------------------------------------------",
28 "Assemble molecular components specified in a model.",
29 " ",
30 "Actions for preparation:",
31 "-com Generate a new model from the centers-of-mass of molecules.",
32 "-all Reset selection to all components before other selections.",
33 " ",
34 "Selections:",
35 "-select #232@14 Select models and components.",
36 "-first 22 Select the first number of components.",
37 " ",
38 "Actions:",
39 "-views local Calculate views for components. Modes: origin: current origin,",
40 " com: center-of-mass origin, map: map origin, local: neigbor plane.",
41 "-associate TRS,trs.pdb Associate a component type with a file name.",
42 "-untangle 3.5,0.2 Eliminate overlaps by moving molecules apart (sampling and damping factor).",
43 " ",
44 "Parameters:",
45 "-verbose 7 Verbose output.",
46 "-separate Each model is defined as a separate molecule group.",
47 "-componentradius 8.4 Set display radius for all components.",
48 "-linkradius 5.1 Set display radius for all links.",
49 " ",
50 "Actions for finishing:",
51 "-reset Reset selection to all components before other selections.",
52 " ",
53 "Input:",
54 "-parameters param.star Input parameter file.",
55 " ",
56 "Output:",
57 "-output file.star Output model parameter file.",
58 "-coordinates all.pdb Output coordinate files.",
59 " ",
60 NULL
61 };
62
63 int main(int argc, char **argv)
64 {
65 /* Initialize variables */
66 int all(0); // Keep selection as read from file
67 int reset(0); // Keep selection as ouput
68 Bstring mod_select; // Model and component selection
69 int first(0); // First number of components to select
70 int com(0); // Flag to generate a centers-of-mass model
71 Bstring calc_views; // Mode to calculate component views
72 Bstring associate_type; // Component type
73 Bstring associate_file; // Component file name
74 int separate(0); // Flag to define separate molecule groups
75 double untangle(0); // Untangling grid sampling
76 double lambda(0.1); // Untangling damping factor
77 double comprad(0); // Component display radius
78 double linkrad(0); // Link display radius
79 Bstring atom_select("all");
80 Bstring paramfile; // Input parameter file name
81 Bstring outfile; // Output parameter file name
82 Bstring coorfile; // Output coordinates file name
83
84 int optind;
85 Boption* option = get_option_list(use, argc, argv, optind);
86 Boption* curropt;
87 for ( curropt = option; curropt; curropt = curropt->next ) {
88 if ( curropt->tag == "all" ) all = 1;
89 if ( curropt->tag == "reset" ) reset = 1;
90 if ( curropt->tag == "select" )
91 mod_select = curropt->value;
92 if ( curropt->tag == "first" )
93 if ( ( first = curropt->value.integer() ) < 1 )
94 cerr << "-first: An integer must be specified!" << endl;
95 if ( curropt->tag == "com" ) com = 1;
96 if ( curropt->tag == "views" ) calc_views = curropt->value.lower();
97 if ( curropt->tag == "associate" ) {
98 associate_file = curropt->value;
99 associate_type = associate_file.pre(',');
100 associate_file = associate_file.post(',');
101 }
102 if ( curropt->tag == "untangle" )
103 if ( curropt->values(untangle, lambda) < 1 )
104 cerr << "-untangle: Grid sampling in angstrom must be specified!" << endl;
105 if ( curropt->tag == "separate" ) separate = 1;
106 if ( curropt->tag == "componentradius" )
107 if ( ( comprad = curropt->value.real() ) < 1 )
108 cerr << "-componentradius: A display radius must be specified!" << endl;
109 if ( curropt->tag == "linkradius" )
110 if ( ( linkrad = curropt->value.real() ) < 1 )
111 cerr << "-linkradius: A radius must be specified!" << endl;
112 if ( curropt->tag == "parameters" )
113 paramfile = curropt->filename();
114 if ( curropt->tag == "output" )
115 outfile = curropt->filename();
116 if ( curropt->tag == "coordinates" )
117 coorfile = curropt->filename();
118 }
119 option_kill(option);
120
121 double ti = timer_start();
122
123 // Read all the parameter files
124 Bstring* file_list = NULL;
125 while ( optind < argc ) string_add(&file_list, argv[optind++]);
126 if ( !file_list ) {
127 cerr << "Error: No model files specified!" << endl;
128 bexit(-1);
129 }
130
131 Bmodel* model = NULL;
132 Bmolgroup* molgroup = NULL;
133
134 if ( com ) {
135 molgroup = read_molecule(*file_list, atom_select, paramfile);
136 model = model_generate_com(molgroup);
137 molgroup_kill(molgroup);
138 molgroup = NULL;
139 } else {
140 model = read_model(file_list, paramfile);
141 string_kill(file_list);
142 }
143
144 if ( !model ) {
145 cerr << "Error: Input file not read!" << endl;
146 bexit(-1);
147 }
148
149 if ( all ) models_process(model, model_reset_selection);
150
151 if ( mod_select.length() ) model_select(model, mod_select);
152
153 if ( first ) model_select_first(model, first);
154
155 if ( associate_file.length() )
156 model_associate(model, associate_type, associate_file);
157
158 if ( comprad > 0 ) models_process(model, comprad, model_set_component_radius);
159
160 if ( linkrad > 0 ) models_process(model, linkrad, model_set_link_radius);
161
162 if ( calc_views.length() ) model_calculate_views(model, calc_views);
163
164 molgroup = model_assemble(model, paramfile, separate);
165
166 if ( molgroup ) {
167 if ( untangle ) {
168 molgroup_untangle_groups(molgroup, untangle, lambda);
169 model_update_centers_of_mass(model, molgroup);
170 }
171 if ( coorfile.length() ) {
172 molecule_update_comment(molgroup, argc, argv);
173 molgroup_list_write(coorfile, molgroup);
174 }
175 molgroup_list_kill(molgroup);
176 }
177
178 if ( reset ) models_process(model, model_reset_selection);
179
180 model_selection_stats(model);
181
182 // Write an output parameter format file if a name is given
183 if ( outfile.length() && model ) {
184 model_update_comment(model, argc, argv);
185 write_model(outfile, model);
186 }
187
188 model_kill(model);
189
190 if ( verbose & VERB_TIME )
191 timer_report(ti);
192
193 bexit(0);
194 }
195
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
model_views.h
Library routines used for analysing model component views.
model_select_first
long model_select_first(Bmodel *model, int first)
Selects the first number of components.
Definition: model_select.cpp:566
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
molgroup_untangle_groups
int molgroup_untangle_groups(Bmolgroup *molgroup, double sampling, double lambda)
Moves overlapping molecules away from each other.
Definition: mol_edit.cpp:849
Bstring::length
long length() const
Definition: Bstring.cpp:263
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
molgroup_list_write
int molgroup_list_write(Bstring &filename, Bmolgroup *molgroup)
Writes a molecule group list.
Definition: rwmolecule.cpp:1048
Boption::filename
Bstring filename()
Definition: options.h:85
timer.h
Utilities for timing functions.
main
int main(int argc, char **argv)
Definition: bass.cpp:63
model_kill
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Definition: rwmodel.cpp:1124
rwmolecule.h
Header file for reading reflection files.
Bmolgroup
Definition: rwmolecule.h:170
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
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
molgroup_kill
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
Definition: rwmolecule.cpp:374
model_selection_stats
long model_selection_stats(Bmodel *model)
Calculates selection statistics.
Definition: model_select.cpp:870
model_generate_com
Bmodel * model_generate_com(Bmolgroup *molgroup)
Calculates the centers-of-mass of molecule group components and generates a new model.
Definition: model_util.cpp:790
molgroup_list_kill
int molgroup_list_kill(Bmolgroup *molgroup)
Destroys a molecule group linked list.
Definition: rwmolecule.cpp:347
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
molecule_update_comment
int molecule_update_comment(Bmolgroup *molgroup, int n, char **strings)
Puts a set of strings and time in the main comment of a molecule group.
Definition: rwmolecule.cpp:1462
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
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
verbose
int verbose
Bmodel
Definition: rwmodel.h:119
model_associate
int model_associate(Bmodel *model, Bstring &associate_type, Bstring &associate_file)
Associates a model file with a component type.
Definition: rwmodel.cpp:1177
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
model_update_centers_of_mass
long model_update_centers_of_mass(Bmodel *model, Bmolgroup *molgroup)
Updates the centers-of-mass of molecule group components.
Definition: model_util.cpp:839
model_calculate_views
long model_calculate_views(Bmodel *model, Bstring &mode)
Calculates the views associated with each component.
Definition: model_views.cpp:263
model_assemble
Bmolgroup * model_assemble(Bmodel *model, Bstring &paramfile, int separate)
Concatenates selected molecules into one group.
Definition: model_util.cpp:688
model_select.h
Header file for reading and writing atomic model files.
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
mol_edit.h
Library routines used for atomic coordinates.
use
const char * use[]
Definition: bass.cpp:24
read_molecule
Bmolgroup * read_molecule(const char *filename, const char *select, const char *paramfile)
The generalized function for reading molecular files.
Definition: rwmolecule.cpp:818
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760