| Bsoft 2.0.5 Bernard's software package

bmolhel.cpp
Go to the documentation of this file.
1
9 #include "rwmolecule.h"
10 #include "mol_symmetry.h"
11 #include "mol_transform.h"
12 #include "mol_util.h"
13 #include "utilities.h"
14 #include "options.h"
15 #include "timer.h"
16
17 // Declaration of global variables
18 extern int verbose; // Level of output to the screen
19
20 /* Usage assistance */
21 const char* use[] = {
22 " ",
23 "Usage: bmolhel [options] in.pdb out.pdb",
24 "---------------------------------------",
25 "Performs helical symmetry operations on molecules.",
26 " ",
27 "Actions:",
28 "-generate 5,7 Generate new molecules downwards and upwards.",
29 "-translate 0,-50,22 Translate (angstrom)",
30 " ",
31 "Parameters:",
32 "-verbose 7 Verbosity of output.",
33 "-origin 10,-10,20 Origin for rotation (default 0,0,0, can be \"center\" for COM).",
34 "-helix 25.3,67.1 Helical rise and angle.",
35 "-reference 0,1.5,-0.2,35 Reference symmetry axis and rotation angle (default 0,0,1,0).",
36 "-rename D Rename molecules from the given letter.",
37 " ",
38 "Input:",
39 "-parameters parm.star Atomic properties parameter file (default atom_prop.star).",
40 " ",
41 NULL
42 };
43
44 int main(int argc, char **argv)
45 {
46 /* Initialize variables */
47 int gen_down(0), gen_up(0); // Number of molecules to generate
48 Vector3<double> t; // Shift
49 char first_name(0); // First molecule name for renaming
50 int com_origin(0); // Flag to set the center-of-mass as origin of rotation
51 Vector3<double> origin; // Rotation origin
52 double helix_rise(0); // Rise per asymmetric unit
53 double helix_angle(0); // Rotation angle per asymmetric unit
54 Bstring atom_select("ALL");
55 View ref_view; // Reference view for symmetry application
56 Bstring paramfile; // Use default parameter file
57
58 int optind;
59 Boption* option = get_option_list(use, argc, argv, optind);
60 Boption* curropt;
61 for ( curropt = option; curropt; curropt = curropt->next ) {
62 if ( curropt->tag == "generate" )
63 if ( curropt->values(gen_down, gen_up) < 1 )
64 cerr << "-generate: At least one number must be specified!" << endl;
65 if ( curropt->tag == "translate" ) {
66 t = curropt->vector3();
67 if ( t.length() < 0.0001 )
68 cerr << "-translate: Three values must be specified!" << endl;
69 }
70 if ( curropt->tag == "rename" )
71 if ( ( first_name = curropt->value[0] ) < 1 )
72 cerr << "-rename: The first molecule name must be specified!" << endl;
73 if ( curropt->tag == "origin" ) {
74 if ( curropt->value.contains("cen") )
75 com_origin = 1;
76 else
77 origin = curropt->origin();
78 }
79 if ( curropt->tag == "helix" ) {
80 if ( curropt->values(helix_rise, helix_angle) < 2 )
81 cerr << "-helix: Both rise and angle must be specified" << endl;
82 else
83 helix_angle *= M_PI/180.0;
84 }
85 if ( curropt->tag == "reference" )
86 ref_view = curropt->view();
87 if ( curropt->tag == "parameters" )
88 paramfile = curropt->filename();
89 }
90 option_kill(option);
91
92 double ti = timer_start();
93
94 Bstring filename(argv[optind++]);
95 Bmolgroup* molgroup = read_molecule(filename, atom_select, paramfile);
96 if ( !molgroup ) {
97 cerr << "Error: Coordinate file not read!" << endl;
98 bexit(-1);
99 }
100
101 if ( t[0] != 0 || t[1] != 0 || t[2] != 0 )
102 molgroup_coor_shift(molgroup, t);
103
104 if ( com_origin )
105 origin = molgroup_center_of_mass(molgroup);
106
107 if ( origin[0] || origin[1] || origin[2] )
108 molgroup_coor_shift(molgroup, -origin);
109
110 molgroup_stats(molgroup);
111
112 if ( gen_down + gen_up > 0 && helix_rise && helix_angle )
113 molgroup_generate_helix(molgroup, ref_view, helix_rise, helix_angle, gen_down, gen_up);
114
115 molgroup_from_molgroup_list(molgroup);
116
117 if ( first_name )
118 molgroup_rename(molgroup, first_name);
119
120 if ( optind < argc ) {
121 molecule_update_comment(molgroup, argc, argv);
122 if ( write_molecule(argv[optind], molgroup) < 1 )
123 cerr << "Error: " << argv[optind] << " not written!" << endl;
124 }
125
126 molgroup_kill(molgroup);
127
128 if ( verbose & VERB_TIME )
129 timer_report(ti);
130
131 bexit(0);
132 }
133
write_molecule
int write_molecule(char *filename, Bmolgroup *molgroup)
Writes a molecule group.
Definition: rwmolecule.cpp:975
Vector3::length
double length()
Definition: Vector3.h:222
utilities.h
Header file for general utilities.
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
main
int main(int argc, char **argv)
Definition: bmolhel.cpp:44
mol_transform.h
Library routines used for atomic coordinate transformations.
molgroup_generate_helix
int molgroup_generate_helix(Bmolgroup *molgroup, View ref_view, double helix_rise, double helix_angle, int gen_down, int gen_up)
Generates a helix from the given parameters.
Definition: mol_symmetry.cpp:135
molgroup_rename
int molgroup_rename(Bmolgroup *molgroup, char first_name)
Renames molecules.
Definition: mol_util.cpp:161
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
mol_symmetry.h
Library routines used for symmetry operations on atomic coordinates.
Boption::filename
Bstring filename()
Definition: options.h:85
timer.h
Utilities for timing functions.
molgroup_center_of_mass
Vector3< double > molgroup_center_of_mass(Bmolgroup *molgroup)
Calculates the center of mass of a molecule group.
Definition: mol_util.cpp:307
mol_util.h
Library routines used for atomic coordinates.
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
M_PI
#define M_PI
Definition: utilities.h:59
rwmolecule.h
Header file for reading reflection files.
Bmolgroup
Definition: rwmolecule.h:170
molgroup_stats
long molgroup_stats(Bmolgroup *molgroup, int show)
Calculates the statistics of a molecule group.
Definition: rwmolecule.cpp:1291
Boption::view
View view()
Definition: options.h:259
Boption
A class for a command line input option.
Definition: options.h:26
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
molgroup_kill
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
Definition: rwmolecule.cpp:374
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
verbose
int verbose
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
Boption::vector3
Vector3< double > vector3()
Definition: options.h:148
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
molgroup_coor_shift
int molgroup_coor_shift(Bmolgroup *molgroup, Vector3< double > shift)
Translates a molecule group.
Definition: mol_transform.cpp:28
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
molgroup_from_molgroup_list
int molgroup_from_molgroup_list(Bmolgroup *molgroup)
Converts a molecule group list to a single molecule group.
Definition: rwmolecule.cpp:760
options.h
Header file for option handlers.
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
use
const char * use[]
Definition: bmolhel.cpp:21
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52
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