| Bsoft 2.0.5 Bernard's software package

bmg2imod.cpp
Go to the documentation of this file.
1
10 #include "mg_processing.h"
11 #include "mg_img_proc.h"
12 #include "mg_tomography.h"
13 #include "rwmg.h"
14 #include "rwmgIMOD.h"
15 #include "rwimg.h"
16 #include "linked_list.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 int write_IMOD_parameters(Bstring& imodfile, Bproject* project);
25
26 // Usage assistance
27 const char* use[] = {
28 " ",
29 "Usage: bmg2imod [options] input.mrc input.xf input.tlt input.xyz",
30 "----------------------------------------------------------------",
31 "Converts between IMOD files and a micrograph parameter file.",
32 " ",
33 "Actions:",
34 "-topif Flag to convert the image file to multi-image PIF (default not).",
35 " ",
36 "Parameters:",
37 "-verbose 7 Verbosity of output.",
38 "-sampling 1.5 Sampling (A/pixel).",
39 " ",
40 "Output:",
41 "-output file.star Output micrograph parameter file.",
42 "-imod file.xf Output IMOD parameter files.",
43 " ",
44 NULL
45 };
46
47
48 int main(int argc, char** argv)
49 {
50 // Initializing variables
51 int flag(0); // Flag to rewrite the image file
52 float sampling(0); // A/pixel
53 Bstring outfile; // Output parameter file
54 Bstring imodfile; // IMOD output parameter file
55
56 int optind;
57 Boption* option = get_option_list(use, argc, argv, optind);
58 Boption* curropt;
59 for ( curropt = option; curropt; curropt = curropt->next ) {
60 if ( curropt->tag == "topif" ) flag = 1;
61 if ( curropt->tag == "sampling" )
62 if ( ( sampling = curropt->value.real() ) < 0.1 )
63 cerr << "-sampling: A pixel size must be specified" << endl;
64 if ( curropt->tag == "output" )
65 outfile = curropt->filename();
66 if ( curropt->tag == "imod" )
67 imodfile = curropt->filename();
68 }
69 option_kill(option);
70
71 double ti = timer_start();
72
73 // Read all the parameter files
74 Bstring* file_list = NULL;
75 while ( optind < argc ) string_add(&file_list, argv[optind++]);
76 if ( !file_list ) {
77 cerr << "Error: No parameter files specified!" << endl;
78 bexit(-1);
79 }
80
81 Bproject* project = read_project(file_list, flag);
82
83 string_kill(file_list);
84
85 if ( project == NULL ) {
86 cerr << "Error: No project generated!" << endl;
87 bexit(-1);
88 }
89
90 if ( sampling > 0.1 )
91 project_set_pixel_size(project, sampling);
92
93 project_update_comment(project, argc, argv);
94
95 if ( outfile.length() )
96 write_project(outfile, project, 0, 0);
97
98 if ( imodfile.length() )
99 write_project_imod(imodfile, project);
100
101 project_kill(project);
102
103 if ( verbose & VERB_TIME )
104 timer_report(ti);
105
106 bexit(0);
107 }
108
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:320
rwmg.h
Header file for reading and writing micrograph parameters.
Bstring::real
double real()
Definition: Bstring.cpp:545
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:705
rwmgIMOD.h
Converts between IMOD files and a micrograph parameter file.
utilities.h
Header file for general utilities.
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
mg_img_proc.h
Header file for image processing from micrograph structures.
read_project
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Definition: rwmg.cpp:140
Bstring::length
long length() const
Definition: Bstring.cpp:263
project
Bproject * project
Definition: bshow.cpp:31
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.
linked_list.h
Header file for generalized linked list functions.
Boption
A class for a command line input option.
Definition: options.h:26
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
use
const char * use[]
Definition: bmg2imod.cpp:27
mg_tomography.h
Header file for single particle image processing in Bsoft.
verbose
int verbose
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:1224
project_set_pixel_size
int project_set_pixel_size(Bproject *project, double pixel_size)
Sets the pixel size for all the micrographs.
Definition: mg_processing.cpp:3398
write_IMOD_parameters
int write_IMOD_parameters(Bstring &imodfile, Bproject *project)
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
mg_processing.h
Header file for micrograph processing.
rwimg.h
Header file for 2D and 3D image I/O.
options.h
Header file for option handlers.
project_update_comment
int project_update_comment(Bproject *project, int n, char **strings)
Puts a set of strings and time in the main comment of a project.
Definition: rwmg.cpp:468
write_project_imod
int write_project_imod(Bstring &imodfile, Bproject *project)
Creates IMOD parameter files from a project structure.
Definition: rwmgIMOD.cpp:451
main
int main(int argc, char **argv)
Definition: bmg2imod.cpp:48
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
Bproject
Definition: mg_processing.h:333
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760