 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
23 "Usage: bsim [options] in.star [in2.star]",
24 "----------------------------------------",
25 "Simulates TEM images from atomic coordinates.",
26 "The program has different entry and exit points:",
27 "A new STAR file can be generated (use -generate or -symmetry option and no input STAR file)",
28 " or parameters can be read in from existing STAR files.",
29 "The provision of a coordinate file leads to calculation of potential slices.",
30 "Input of STAR file(s) without a coordinate file implies that the potentials",
31 " have already been calculated and will be used for multislice simulation.",
34 "-generate 10,3,50 Generate a project, specifying number of fields, number of",
35 " micrographs per field and number particles per micrograph.",
36 "-symmetry C5 Generates images based on a grid in the asymmetric unit.",
37 "-coordinates file.pdb Input coordinate file, generate simulated images in project.",
38 "-image Generate a final image and parameter file (default not).",
39 "-poisson Add poisson noise (default not).",
40 "-gaussian 0.2 Add gaussian noise with the given signal-to-noise ratio.",
41 "-MTF 17.5 Set the MTF decay constant (required to impose MTF).",
44 "-verbose 7 Verbosity of output.",
46 "Parameters for generation:",
47 "-translate 2.4 Standard deviation for random translation (default 0).",
48 "-origin 120 Set the particle image origin (default 50 pixels).",
49 "-angles 8,6 Step sizes for theta and phi in the asymmetric unit, one value sets both.",
50 " Use with the -symmetry option (default 10,10).",
51 "-Pixelsize 5.5 Set the particle pixel size (default 1 angstrom/pixel).",
52 "-electrondose 35.5 Set the electron dose (default 20 electrons/angstrom).",
53 "-Cs 2.0 Set the spherical aberration, Cs (default 2 mm).",
54 "-Cc 2.0 Set the chromatic aberration, Cc (default 2.0 mm).",
55 "-alpha 0.15 Set the illumination half-angle (default 0.1 milliradians).",
56 "-energyspread 2e-5 Set the effective energy spread (default 1e-5).",
57 "-Volt 100 Set the acceleration voltage (default 120 kV).",
58 "-Amplitude 0.07 Set the amplitude contrast (fraction, default 0.07).",
59 "-Defocus 0.5,3.4 Defocus range (required to apply CTF).",
60 "-fieldbasename field Field-of-view base name (default field).",
61 "-fieldnumber 5 Field starting number (default 1).",
62 "-mgbasename mg Micrograph base name (default mg).",
63 "-mgnumber 23 Micrograph starting number (default 1).",
64 "-partbasename part Particle base name (default part).",
65 "-partnumber 158 Particle starting number (default 1).",
67 "Parameters for simulation:",
68 "-fieldname field Field-of-view name (for selecting a specific field).",
69 "-mgname mg Micrograph base name (for selecting a specific micrograph).",
70 "-partselect 132 Particle selection for potential generation (default all).",
71 "-type real Type of potential calculation (default reciprocal, other gauss).",
72 "-size 100,80,120 Size of enclosing box (default based on input coordinates).",
73 "-thickness 20 Slice thickness in angstrom (default 10 A).",
74 "-resolution 8.5 Resolution limits (default Nyquest frequency).",
75 "-Bfactor 24.5 Set the overall temperature factor (default 0 A^2).",
78 "-parameters param.star Parameter file name for electron scattering curves (default atom_prop.star).",
79 "-Water water.pdb Block of water to embed the molecule into (default none).",
82 "-output mg.star Parameter file (use with generate option).",
87 int main(
int argc,
char **argv)
90 int genfield(0), genmg(0), genpart(0);
92 double theta_step(
M_PI*10.0/180.0);
93 double phi_step(
M_PI*10.0/180.0);
100 double Volts(120000);
102 double def_min(0), def_max(0);
106 double thickness(10);
107 double resolution(0);
109 double alpha(0.0001);
110 double energy_spread(1e-5);
133 for ( curropt = option; curropt; curropt = curropt->
next ) {
134 if ( curropt->
tag ==
"generate" )
135 if ( curropt->
values(genfield, genmg, genpart) < 3 )
136 cerr <<
"-generate: Three numbers must be specified!" << endl;
137 if ( curropt->
tag ==
"symmetry" )
139 if ( curropt->
tag ==
"angles" ) {
140 if ( ( i = curropt->
values(theta_step, phi_step) ) < 1 )
141 cerr <<
"-angles: An angle step size must be specified!" << endl;
143 theta_step *=
M_PI/180.0;
144 if ( i < 2 ) phi_step = theta_step;
145 else phi_step *=
M_PI/180.0;
148 if ( curropt->
tag ==
"translate" )
149 if ( ( tsigma = curropt->
value.
real() ) < 1e-30 )
150 cerr <<
"-translate: A translation standard deviation must be specified!" << endl;
151 if ( curropt->
tag ==
"origin" )
152 if ( ( img_origin = curropt->
value.
real() ) < 1e-30 )
153 cerr <<
"-origin: The image origin must be specified!" << endl;
154 if ( curropt->
tag ==
"Pixelsize" )
155 pixel_size = curropt->
scale();
158 if ( curropt->
tag ==
"electrondose" )
159 if ( ( dose = curropt->
value.
real() ) < 1e-30 )
160 cerr <<
"-electrondose: The electron dose must be specified!" << endl;
161 if ( curropt->
tag ==
"Cs" ) {
162 if ( ( Cs = curropt->
value.
real() ) < 1e-30 )
163 cerr <<
"-Cs: A Cs value must be specified!" << endl;
164 else if ( Cs < 1e3 ) Cs *= 1e7;
166 if ( curropt->
tag ==
"Cc" ) {
167 if ( ( Cc = curropt->
value.
real() ) < 1e-30 )
168 cerr <<
"-Cc: A Cc value must be specified!" << endl;
169 else if ( Cc < 1e3 ) Cc *= 1e7;
171 if ( curropt->
tag ==
"alpha" ) {
172 if ( ( alpha = curropt->
value.
real() ) < 1e-30 )
173 cerr <<
"-alpha: The illumination half-angle must be specified!" << endl;
175 if ( alpha > 0.01 ) alpha /= 1000;
176 if ( alpha < 0 ) alpha = 0.0001;
179 if ( curropt->
tag ==
"energyspread" ) {
180 if ( ( energy_spread = curropt->
value.
real() ) < 1e-30 )
181 cerr <<
"-energyspread: A energy spread must be specified!" << endl;
183 if ( energy_spread > 0.001 ) energy_spread /= 1e5;
184 if ( energy_spread < 0 ) energy_spread = 0;
187 if ( curropt->
tag ==
"Volt" ) {
188 if ( ( Volts = curropt->
value.
real() ) < 1e-30 )
189 cerr <<
"-Volt: A voltage must be specified!" << endl;
190 else if ( Volts < 1e3 ) Volts *= 1e3;
192 if ( curropt->
tag ==
"Amplitude" ) {
193 if ( ( Amp = curropt->
value.
real() ) < 1e-30 )
194 cerr <<
"-Amplitude: A fraction must be specified!" << endl;
195 else if ( Amp > 1 ) Amp /= 100;
197 if ( curropt->
tag ==
"Defocus" ) {
198 if ( curropt->
values(def_min, def_max) < 1 )
199 cerr <<
"-Defocus: Both defocus minimum and maximum must be specified!" << endl;
200 if ( def_max < def_min ) def_max = def_min;
201 if ( def_min < 100 && def_max < 100 ) {
208 if ( curropt->
tag ==
"type" ) {
213 if ( curropt->
tag ==
"size" )
214 size = curropt->
size();
215 if ( curropt->
tag ==
"thickness" )
216 if ( ( thickness = curropt->
value.
real() ) < 1e-30 )
217 cerr <<
"-thickness: A slice thickness must be specified!" << endl;
218 if ( curropt->
tag ==
"resolution" )
219 if ( ( resolution = curropt->
value.
real() ) < 0.001 )
220 cerr <<
"-resolution: A resolution limit must be specified!" << endl;
221 if ( curropt->
tag ==
"Bfactor" )
222 if ( ( Bfactor = curropt->
value.
real() ) < 0.001 )
223 cerr <<
"-Bfactor: A temperature factor must be specified!" << endl;
224 if ( curropt->
tag ==
"image" )
226 if ( curropt->
tag ==
"poisson" )
228 if ( curropt->
tag ==
"MTF" )
229 if ( ( kmtf = curropt->
value.
real() ) < 1e-30 )
230 cerr <<
"-MTF: The MTF decay constant must be specified!" << endl;
231 if ( curropt->
tag ==
"gaussian" )
232 if ( ( gauss = curropt->
value.
real() ) < 1e-30 )
233 cerr <<
"-gaussian: The signal-to-noise ratio must be specified!" << endl;
234 if ( curropt->
tag ==
"fieldbasename" ) {
236 else cerr <<
"-fieldbasename: A field-of-view base name must be specified!" << endl;
238 if ( curropt->
tag ==
"fieldname" ) {
240 else cerr <<
"-fieldname: A field-of-view name must be specified!" << endl;
242 if ( curropt->
tag ==
"mgbasename" ) {
244 else cerr <<
"-mgbasename: A micrograph base name must be specified!" << endl;
246 if ( curropt->
tag ==
"mgname" ) {
248 else cerr <<
"-mgname: A micrograph name must be specified!" << endl;
250 if ( curropt->
tag ==
"partbasename" ) {
252 else cerr <<
"-partbasename: A particle base name must be specified!" << endl;
254 if ( curropt->
tag ==
"fieldnumber" )
256 cerr <<
"-fieldnumber: A field-of-view starting number must be specified!" << endl;
257 if ( curropt->
tag ==
"mgnumber" )
259 cerr <<
"-mgnumber: A micrograph starting number must be specified!" << endl;
260 if ( curropt->
tag ==
"partnumber" )
262 cerr <<
"-partnumber: A particle starting number must be specified!" << endl;
263 if ( curropt->
tag ==
"partselect" )
265 cerr <<
"-partselect: A particle number must be specified!" << endl;
266 if ( curropt->
tag ==
"coordinates" )
268 if ( curropt->
tag ==
"Water" )
270 if ( curropt->
tag ==
"Parameter" )
272 if ( curropt->
tag ==
"output" )
282 while ( optind < argc )
string_add(&file_list, argv[optind++]);
288 if ( img_origin <= 0 ) img_origin = size[0]/2;
291 if ( symmetry_string.
length() > 0 ) {
293 theta_step, phi_step, Volts, Cs, Cc, alpha, energy_spread, Amp,
294 def_min, dose, mgbase, partbase);
295 }
else if ( genfield*genmg*genpart > 0 ) {
297 Volts, Cs, Cc, alpha, energy_spread, Amp, def_min, def_max, dose,
298 tsigma, fieldbase, mgbase, partbase, fieldnumber, mgnumber, partnumber);
303 cerr <<
"Error: No STAR file generated or read!" << endl;
307 if ( outfile.
c_str() ) {
313 if ( coorfile.
length() ) {
320 if ( waterfile.
c_str() ) {
328 size, thickness, resolution, Bfactor, pottype, paramfile);
A class for a command line input option.
int project_kill(Bproject *project)
Frees a whole project.
Generates and manipulates projects for multislice calculations.
Vector3< double > scale()
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
int string_kill(Bstring *list)
Kills a string linked list.
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.
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.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Bmolgroup * read_molecule(const char *filename, const char *select, const char *paramfile)
The generalized function for reading molecular files.
Header file for option handlers.
Bproject * project_generate(int nfield, int nmg, int npart, Vector3< double > pixel_size, double img_origin, double volt, double Cs, double Cc, double alpha, double energy_spread, double amp_shift, double def_min, double def_max, double dose, double tsigma, Bstring &fieldbase, Bstring &mgbase, Bstring &partbase, int fieldnumber, int mgnumber, int partnumber)
Generates a project for multislice simulations.
int project_generate_potential(Bmolgroup *molgroup, Bmolgroup *water, Bproject *project, Bstring &fieldname, Bstring &mgname, int partselect, Vector3< long > size, double thickness, double resolution, double Bfactor, int pottype, Bstring ¶mfile)
Generates potential images using a multislice calculation.
long values(T1 &v1, T2 &v2)
Header file for reading and writing micrograph parameters.
string insert(string &filename, string ins)
Header file for reading reflection files.
int main(int argc, char **argv)
int project_apply_distortions(Bproject *project, int poisson, double gauss, double kmtf)
Applies imaging distortions to the final images from a multislice calculation.
Utilities for timing functions.
Bstring symmetry_string()
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.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Header file for micrograph processing.
int project_generate_image(Bproject *project, double thickness, double resolution)
Generates final images from a multislice calculation.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Bproject * project_generate_asu(Bstring &symmetry_string, Vector3< double > pixel_size, double img_origin, double theta_step, double phi_step, double volt, double Cs, double Cc, double alpha, double energy_spread, double amp_shift, double defocus, double dose, Bstring &mgbase, Bstring &partbase)
Generates a project for multislice calculations of an asymmetric unit.
bool contains(const Bstring &s)
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.