| Bsoft 2.0.5 Bernard's software package

bcrystal.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 "options.h"
14 #include "utilities.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: bcrystal [options] in.pdb out.pdb",
24 "----------------------------------------",
25 "Calculates coordinates for multiple unit cells.",
26 " ",
27 "Actions:",
28 "-translate 0,-50,22 Translate (angstrom)",
29 "-cells 2,5,3 Number of unit cells in each lattice direction",
30 " ",
31 "Parameters:",
32 "-verbose 7 Verbose output",
33 "-rename D Rename molecules from the given letter.",
34 "-symmetry 1 Space group",
35 "-unitcell 50,50,50,90,90,90 Unit cell parameters (angstrom & degrees)",
36 " ",
37 "Input:",
38 "-parameters parm.star Atomic properties parameter file (default atom_prop.star)",
39 " ",
40 NULL
41 };
42
43 int main(int argc, char **argv)
44 {
45 /* Initialize variables */
46 char first_name(0); // First molecule name for renaming
47 Vector3<double> t; // Shift
48 Vector3<long> number(1,1,1); // Number of unit cells in the 3 directions
49 int spacegroup(1);
50 UnitCell uc(0,0,0,M_PI_2,M_PI_2,M_PI_2);
51 Bstring atom_select("all");
52 Bstring paramfile; // Use default parameter file
53
54 int optind;
55 Boption* option = get_option_list(use, argc, argv, optind);
56 Boption* curropt;
57 for ( curropt = option; curropt; curropt = curropt->next ) {
58 if ( curropt->tag == "rename" )
59 if ( ( first_name = curropt->value[0] ) < 1 )
60 cerr << "-rename: The first molecule name must be specified!" << endl;
61 if ( curropt->tag == "translate" ) {
62 t = curropt->vector3();
63 if ( t.length() < 1 )
64 cerr << "-translate: Three values must be specified!" << endl;
65 }
66 if ( curropt->tag == "cells" ) {
67 number = curropt->vector3();
68 if ( number.volume() < 1 )
69 cerr << "-cells: Three values must be specified" << endl;
70 }
71 if ( curropt->tag == "unitcell" )
72 uc = curropt->unit_cell();
73 if ( curropt->tag == "symmetry" )
74 if ( ( spacegroup = curropt->value.integer() ) < 1 )
75 cerr << "-symmetry: The space group number must be specified!" << endl;
76 if ( curropt->tag == "parameters" )
77 paramfile = curropt->filename();
78 }
79 option_kill(option);
80
81 double ti = timer_start();
82
83 Bstring filename = argv[optind++];
84 Bmolgroup* molgroup = read_molecule(filename, atom_select, paramfile);
85 if ( molgroup == NULL ) {
86 cerr << "Error: No coordinate file given!" << endl;
87 bexit(-1);
88 }
89
90 if ( t[0] != 0 || t[1] != 0 || t[2] != 0 )
91 molgroup_coor_shift(molgroup, t);
92
93 if ( number.volume() > 1 )
94 molgroup_generate_crystal(molgroup, uc, number);
95
96 if ( first_name )
97 molgroup_rename(molgroup, first_name);
98
99 if ( optind < argc ) {
100 molecule_update_comment(molgroup, argc, argv);
101 write_molecule(argv[optind], molgroup);
102 }
103
104 molgroup_kill(molgroup);
105
106 if ( verbose & VERB_TIME )
107 timer_report(ti);
108
109 bexit(0);
110 }
111
112
113
Boption::unit_cell
UnitCell unit_cell()
Definition: options.h:291
M_PI_2
#define M_PI_2
Definition: utilities.h:62
UnitCell
Definition: UnitCell.h:22
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
molgroup_generate_crystal
int molgroup_generate_crystal(Bmolgroup *molgroup, UnitCell unit_cell, Vector3< int > number)
Generates unit cells from a set of coordinates.
Definition: mol_symmetry.cpp:963
utilities.h
Header file for general utilities.
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
mol_transform.h
Library routines used for atomic coordinate transformations.
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.
mol_util.h
Library routines used for atomic coordinates.
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
main
int main(int argc, char **argv)
Definition: bcrystal.cpp:43
molgroup_kill
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
Definition: rwmolecule.cpp:374
verbose
int verbose
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
Boption::vector3
Vector3< double > vector3()
Definition: options.h:148
use
const char * use[]
Definition: bcrystal.cpp:21
Vector3< double >
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
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
Bstring::integer
long integer()
Definition: Bstring.cpp:539
options.h
Header file for option handlers.
Vector3::volume
double volume()
Definition: Vector3.h:235
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