| Bsoft 2.0.5 Bernard's software package

balpha.cpp
Go to the documentation of this file.
1
9 #include "rwmolecule.h"
10 #include "mol_alpha.h"
11 #include "mol_util.h"
12 #include "options.h"
13 #include "utilities.h"
14 #include "timer.h"
15
16 // Declaration of global variables
17 extern int verbose; // Level of output to the screen
18
19 /* Usage assistance */
20 const char* use[] = {
21 " ",
22 "Usage: balpha [options] [input.pdb] output.pdb",
23 "----------------------------------------------",
24 "Creates and manipulates alpha helices.",
25 " ",
26 "Actions:",
27 "-create 12 Create an alpha helix of a given length.",
28 "-helix 213,236 Set residues to a helix (all molecules).",
29 "-find Find a helix center and orientation (only for a single helix).",
30 "-set Set a helix to the standard orientation (only for a single helix).",
31 "-consolidate Consolidate a set of helices to eliminate redundancy.",
32 " ",
33 "Parameters:",
34 "-verbose 7 Verbosity of output.",
35 " ",
36 NULL
37 };
38
39 int main(int argc, char **argv)
40 {
41 // Initialize variables
42 int create_number(0); // Length of helix to create
43 int helix_start(0), helix_end(0); // Setting to a helix
44 int find_orientation(0); // Flag to find the helix orientation
45 int set_orientation(0); // Flag to set standard orientation
46 int consolidate(0); // Flag to consolidate a set of helices
47 Bstring atom_select("all"); // Selection
48 Bstring paramfile;
49
50 int optind;
51 Boption* option = get_option_list(use, argc, argv, optind);
52 Boption* curropt;
53 for ( curropt = option; curropt; curropt = curropt->next ) {
54 if ( curropt->tag == "create" )
55 if ( ( create_number = curropt->value.integer() ) < 1 )
56 cerr << "-create: The desired helix length must be specified!" << endl;
57 if ( curropt->tag == "helix" )
58 if ( curropt->values(helix_start, helix_end) < 2 )
59 cerr << "-helix: Both the start and end of the helix must be specified!" << endl;
60 if ( curropt->tag == "find" )
61 find_orientation = 1;
62 if ( curropt->tag == "set" )
63 find_orientation = set_orientation = 1;
64 if ( curropt->tag == "consolidate" )
65 consolidate = 1;
66 }
67 option_kill(option);
68
69 double ti = timer_start();
70
71 // Read the molecule file
72 Bmolgroup* molgroup = NULL;
73 Bstring filename(argv[optind++]);
74
75 if ( create_number > 0 )
76 molgroup = molgroup_generate_alpha_helix(create_number);
77 else
78 molgroup = read_molecule(filename, atom_select, paramfile);
79
80 if ( !molgroup ) {
81 cerr << "Error: No molecules created or read!" << endl;
82 bexit(-1);
83 }
84
85 if ( helix_end )
86 molgroup_set_alpha_helix(molgroup, helix_start, helix_end);
87
88 molgroup_find_helical_axes(molgroup);
89
90 if ( find_orientation )
91 mol_find_alpha_orientation(molgroup->mol, set_orientation);
92
93 if ( consolidate )
94 molgroup = molgroup_consolidate_alpha(molgroup);
95
96 // Write an output file if a file name is given
97 if ( optind < argc ) {
98 molecule_update_comment(molgroup, argc, argv);
99 write_molecule(argv[optind], molgroup);
100 }
101
102 molgroup_kill(molgroup);
103
104 if ( verbose & VERB_TIME )
105 timer_report(ti);
106
107 bexit(0);
108 }
109
Bmolgroup::mol
Bmolecule * mol
Definition: rwmolecule.h:189
write_molecule
int write_molecule(char *filename, Bmolgroup *molgroup)
Writes a molecule group.
Definition: rwmolecule.cpp:975
utilities.h
Header file for general utilities.
Boption::value
Bstring value
Definition: options.h:30
molgroup_consolidate_alpha
Bmolgroup * molgroup_consolidate_alpha(Bmolgroup *molgroup)
Cluster a set of alpha helices to consolidate helices.
Definition: mol_alpha.cpp:382
Boption::tag
Bstring tag
Definition: options.h:29
mol_alpha.h
Header for functions to make and analyze alpha helices.
verbose
int verbose
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
timer.h
Utilities for timing functions.
mol_util.h
Library routines used for atomic coordinates.
molgroup_generate_alpha_helix
Bmolgroup * molgroup_generate_alpha_helix(int length)
Generates an alpha helix of the desired length.
Definition: mol_alpha.cpp:54
use
const char * use[]
Definition: balpha.cpp:20
rwmolecule.h
Header file for reading reflection files.
Bmolgroup
Definition: rwmolecule.h:170
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
main
int main(int argc, char **argv)
Definition: balpha.cpp:39
molgroup_find_helical_axes
int molgroup_find_helical_axes(Bmolgroup *molgroup)
Calculates the centers and orientations of all alpha helices.
Definition: mol_alpha.cpp:147
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
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
mol_find_alpha_orientation
Vector3< double > mol_find_alpha_orientation(Bmolecule *mol, int set_std)
Calculates the orientation of an alpha helix.
Definition: mol_alpha.cpp:249
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
Bstring::integer
long integer()
Definition: Bstring.cpp:539
options.h
Header file for option handlers.
molgroup_set_alpha_helix
int molgroup_set_alpha_helix(Bmolgroup *molgroup, int helix_start, int helix_end)
Sets a residue range to an alpha helix in all molecules.
Definition: mol_alpha.cpp:117
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
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