| Bsoft 2.0.5 Bernard's software package

bparam.cpp
Go to the documentation of this file.
1
9 #include "rwmolecule.h"
10 #include "rwmd.h"
11 #include "mol_param.h"
12 #include "utilities.h"
13 #include "options.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: bparam [options] param.star",
23 "----------------------------------",
24 "Manipulate molecular parameter files.",
25 " ",
26 "Actions:",
27 "-select CA Atom selection (default all).",
28 "-bonds List all bond lengths.",
29 "-angles List all angles.",
30 "-length 1.85 Length to define bonds.",
31 " ",
32 "Parameters:",
33 "-verbose 7 Verbosity of output.",
34 "-elements Use elements as identifiers rather than atom names.",
35 " ",
36 "Input:",
37 "-from input.pdb Extract parameters from an atomic coordinate file.",
38 "-parameters parm.star Molecular parameter file (default atom_prop.star)",
39 " ",
40 "Output:",
41 "-output param.star Output parameter file.",
42 " ",
43 NULL
44 };
45
46 int main(int argc, char **argv)
47 {
48 /* Initialize variables */
49 Bstring atom_select("ALL");
50 int show_bonds(0);
51 int show_angles(0);
52 double length_cutoff(0);
53 int elements(0); // Flag to use element names
54 Bstring paramfile; // Use default parameter file
55 Bstring atomfile; // Atom coordinate file
56 Bstring outfile; // Output 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 == "select" ) {
63 atom_select = curropt->value;
64 if ( atom_select.length() < 1 )
65 cerr << "-select: A selection must be specified!" << endl;
66 }
67 if ( curropt->tag == "bonds" ) show_bonds = 1;
68 if ( curropt->tag == "angles" ) show_angles = 1;
69 if ( curropt->tag == "length" )
70 length_cutoff = curropt->value.real();
71 if ( curropt->tag == "elements" ) elements = 1;
72 if ( curropt->tag == "from" )
73 atomfile = curropt->filename();
74 if ( curropt->tag == "parameters" )
75 paramfile = curropt->filename();
76 if ( curropt->tag == "output" )
77 outfile = curropt->filename();
78 }
79 option_kill(option);
80
81 double ti = timer_start();
82
83 Bmd* md = NULL;
84 Bstring filename;
85
86 if ( optind < argc ) {
87 filename = argv[optind];
88 md = read_md_parameters(filename);
89 if ( !md ) {
90 cerr << "Error: Parameter file " << argv[optind] << " not read!" << endl;
91 bexit(-1);
92 }
93 }
94
95 Bmolgroup* molgroup = NULL;
96 if ( atomfile.length() ) {
97 molgroup = read_molecule(atomfile, atom_select, paramfile);
98 if ( !molgroup ) {
99 cerr << "Error: Coordinate file not read!" << endl;
100 bexit(-1);
101 }
102 md_kill(md);
103 if ( length_cutoff ) {
104 bond_kill(molgroup->bond);
105 molgroup->bond = NULL;
106 molgroup_bond_list_generate(molgroup, length_cutoff, 0);
107 }
108 md = md_calculate_parameters(molgroup, elements, show_bonds, show_angles);
109 molgroup_kill(molgroup);
110 }
111
112 if ( outfile.length() ) {
113 // molecule_update_comment(molgroup, argc, argv);
114 // if ( write_molecule(argv[optind], molgroup) < 1 )
115 // cerr << "Error: %s not written!\n", argv[optind]);
116 write_md_parameters(outfile, md);
117 }
118
119 md_kill(md);
120
121 if ( verbose & VERB_TIME )
122 timer_report(ti);
123
124 bexit(0);
125 }
126
Bstring::real
double real()
Definition: Bstring.cpp:545
utilities.h
Header file for general utilities.
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
use
const char * use[]
Definition: bparam.cpp:20
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bmd
Definition: rwmd.h:56
write_md_parameters
int write_md_parameters(Bstring &filename, Bmd *md)
Writing molecular dynamics parameters to a STAR file.
Definition: rwmd.cpp:237
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_bond_list_generate
Bbond * molgroup_bond_list_generate(Bmolgroup *molgroup, double maxlength, int wrap)
Generates a bond list based on atom separation.
Definition: rwmolecule.cpp:1555
Boption::filename
Bstring filename()
Definition: options.h:85
main
int main(int argc, char **argv)
Definition: bparam.cpp:46
timer.h
Utilities for timing functions.
rwmolecule.h
Header file for reading reflection files.
Bmolgroup
Definition: rwmolecule.h:170
verbose
int verbose
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
bond_kill
int bond_kill(Bbond *bond)
Dealocates a list of bonds.
Definition: rwmolecule.cpp:480
mol_param.h
Header for functions to extract parameters from coordinate files.
read_md_parameters
Bmd * read_md_parameters(Bstring &filename)
Reading molecular dynamics parameters from STAR files.
Definition: rwmd.cpp:80
Bmolgroup::bond
Bbond * bond
Definition: rwmolecule.h:190
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
md_calculate_parameters
Bmd * md_calculate_parameters(Bmolgroup *molgroup, int elements, int show_bond, int show_angle)
Calculates atomic parameters from molecule groups.
Definition: mol_param.cpp:73
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
rwmd.h
Header to read and write molecular dynamics parameters in STAR format.
options.h
Header file for option handlers.
md_kill
int md_kill(Bmd *md)
Deallocates a molecular dynamics structure.
Definition: rwmd.cpp:417
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