Bsoft  2.1.0
Bernard's software package
rwmolecule.h
Go to the documentation of this file.
1 
9 #include "UnitCell.h"
10 #include "Vector3.h"
11 #include "Bstring.h"
12 
13 /* Constants */
14 #define MAXSEQLEN 1000000 // Maximum sequence length
15 
16 #ifndef _Bmolecule_
17 /************************************************************************
18 @Object: struct Batom
19 @Description:
20  Atom property structure.
21 @Features:
22  PDB line data structure: items labeled extra not in the PDB specification.
23 *************************************************************************/
24 struct Batom {
25  Batom* next; // Next atom in linked list
26  int num; // Atom number
27  char el[4]; // Atom type
28  char type[8]; // Atom type
29  int tnum; // Atom type number (for reference purposes)
30  Vector3<double> coord; // Coordinates
31  double q,b; // Occupancy and temperature factor
32  double mass; // Atom mass
33  double chrg; // Charge on atom
34  int sel; // Select flag - extra
35  Vector3<double> vel; // Velocities (for molecular dynamics)
36  Vector3<double> F; // Force vector (for molecular dynamics)
37 } ;
38 
39 /************************************************************************
40 @Object: struct Bresidue
41 @Description:
42  Residue definition and property structure.
43 @Features:
44  A residue is viewed as equivalent to the monomeric units incorportated
45  into a polymer (amino acids for proteins and nucleotides for nucleic
46  acids). For small molecules, the residue and molecule definitions
47  are identical.
48 *************************************************************************/
49 struct Bresidue {
50  Bresidue* next; // Next residue in linked list
51  int num; // Residue number
52  char insert[2]; // Insertion code
53  char type[6]; // Residue type
54  Batom* atom; // First atom in residue
55 } ;
56 
57 /************************************************************************
58 @Object: enum SecondaryType
59 @Description:
60  Protein secondary structure type specifier.
61 @Features:
62  This is derived from the PDB definitions of secondary structure.
63 *************************************************************************/
75  Strand = 11,
76  Turn = 12
77 } ;
78 
79 /************************************************************************
80 @Object: struct Bsecondary
81 @Description:
82  Protein secondary structure definition.
83 @Features:
84  Every definition of a secondary structure element includes a type
85  and the sequence range.
86 *************************************************************************/
87 struct Bsecondary {
88  Bsecondary* next; // Next secondary structure item in linked list
89  SecondaryType type; // Class
90  int num; // Serial number
91  char id[4]; // Identifier: Different series for helix, sheet and turn
92  int sense; // Strand direction
93  int nstrands; // Number of strands in the sheet
94  Bresidue* first; // First residue
95  Bresidue* last; // Last residue
96 } ;
97 
98 /************************************************************************
99 @Object: struct Bmolecule
100 @Description:
101  Molecule definition and property structure.
102 @Features:
103  A molecule is viewed as a single covalently bound set of atoms with
104  properties such as gene and protein sequences, and composed
105  of a set of residues containing atoms.
106 *************************************************************************/
107 struct Bmolecule {
108  Bmolecule* next; // Next molecule in linked list
109  int num; // Molecule number
110  Bstring id; // Molecule identifier
111  long nres; // Number of residues
112  long nbase; // Number of bases
113  long first_codon; // First amino acid codon in NA sequence
114  Bstring seq; // Protein sequence
115  Bstring naseq; // Nucleic acid sequence
116  Vector3<double> min; // Coordinate minima
117  Vector3<double> max; // Coordinate maxima
118  double Bmin,Bmax; // B-factor statistics
119  double Bave,Bstd;
120  int sel; // Selection flag
121  double fom; // Figure-of-merit for molecule
122  Bresidue* res; // First residue in molecule
123  Bsecondary* sec; // Secondary structure
124 } ;
125 
126 /************************************************************************
127 @Object: struct Bbond
128 @Description:
129  All bonds defined for a molecule group.
130 @Features:
131  Intra- and intermolecular bonds are defined by pointers to two atoms each.
132  The structure also holds bond length and strength properties.
133 *************************************************************************/
134 struct Bbond {
135  Bbond* next; // Next bond in linked list
136  Batom* atom1; // First atom
137  Batom* atom2; // Second atom
138  double l; // Reference bond length
139  double k; // Bond strength
140 } ;
141 
142 /************************************************************************
143 @Object: struct Bangle
144 @Description:
145  All angles defined for a molecule group.
146 @Features:
147  The angle between two bonds are defined by the three connected atoms.
148  The structure also holds reference angle length and strength properties.
149 *************************************************************************/
150 struct Bangle {
151  Bangle* next; // Next angle in linked list
152  Batom* atom1; // First atom
153  Batom* atom2; // Second atom
154  Batom* atom3; // Third atom
155  double a; // Reference angle
156  double k; // Angle strength
157 } ;
158 
159 
160 /************************************************************************
161 @Object: struct Bmolgroup
162 @Description:
163  A collection of molecules.
164 @Features:
165  This holds any set of molecules such as:
166  1. Members of a complex.
167  2. Homologues used for sequence or structural similarity analysis.
168  3. All molecules in a molecular dynamics setup.
169 *************************************************************************/
170 struct Bmolgroup {
171  Bmolgroup* next; // Next molecule group in linked list
172  Bstring filename; // File name
173  int num; // Molecule group number
174  Bstring id; // Molecule group identifier
175  Bstring comment; // Comment string
176  int spacegroup; // Crystallographic space group number
177  Bstring pointgroup; // Point group symmetry for molecule group
178  Bstring sgstring; // Crystallographic space group notation
179  UnitCell unitcell; // Crystallographic unit cell
180  long maxlen; // Maximum protein sequence length
181  long maxnalen; // Maximum nucleic acid sequence length
182  Vector3<double> min; // Coordinate minima
183  Vector3<double> max; // Coordinate maxima
184  Vector3<double> box; // Bounding box details
185  Bstring select; // Selection options
186  int sel; // Select flag
187  double fom; // Figure-of-merit for molecule group
188  int* seqflag; // Position selection flag
189  Bmolecule* mol; // First molecule in group
190  Bbond* bond; // First bond for group
191  Bangle* angle; // First angle for group
192 } ;
193 #define _Bmolecule_
194 #endif
195 
196 /* Function prototypes */
198 Bmolecule* molecule_add(Bmolecule** mol, char* name);
199 Bmolecule* molecule_add(Bmolecule** mol, Bstring& name);
200 Bresidue* residue_add(Bresidue** res, const char* type);
201 Bresidue* residue_add(Bresidue** res, Bstring& type);
202 Batom* atom_add(Batom** atom, const char* type);
203 Batom* atom_add(Batom** atom, Bstring& type);
204 long residue_count(Bmolgroup* molgroup);
205 long atom_count(Bmolgroup* molgroup);
206 int atom_clean_type(Batom* atom, const char* type);
207 Bbond* bond_add(Bbond** bond, Batom* atom1, Batom* atom2, double l, double k);
208 Bangle* angle_add(Bangle** angle, Batom* atom1, Batom* atom2, Batom* atom3, double a, double k);
209 int molgroup_list_kill(Bmolgroup* molgroup);
210 int molgroup_kill(Bmolgroup* molgroup);
211 int molecule_kill(Bmolecule* mol);
212 int residue_kill(Bresidue* res);
213 int bond_kill(Bbond* bond);
214 int angle_kill(Bangle* angle);
216 Bmolgroup* molgroup_copy(Bmolgroup* molgroup);
219 Bbond* molgroup_bond_list_copy(Bmolgroup* molgroup, Bmolgroup* molgroupcopy);
221 Bmolgroup* read_molecule(const char *filename, const char *select, const char* paramfile);
222 Bmolgroup* read_molecule(Bstring& filename, Bstring& atom_select, Bstring& paramfile);
223 Bmolgroup* read_molecule(Bstring* file_list, int set_pbc, Vector3<double> box,
224  Bstring atom_select, Bstring paramfile);
225 int write_molecule(char *filename, Bmolgroup* molgroup);
226 int write_molecule(Bstring& filename, Bmolgroup *molgroup);
227 int molgroup_list_write(Bstring& filename, Bmolgroup* molgroup);
228 long molgroup_count_molecules(Bmolgroup* molgroup);
229 long molgroup_count_residues(Bmolgroup* molgroup);
230 long mol_count_residues(Bmolecule *mol);
231 long molgroup_count_atoms(Bmolgroup* molgroup);
232 long mol_count_atoms(Bmolecule *mol);
233 int molgroup_consolidate_gaps(Bmolgroup* molgroup);
234 long molgroup_stats(Bmolgroup* molgroup, int show);
235 long molgroup_stats(Bmolgroup* molgroup);
236 long mol_stats(Bmolecule* mol, int show);
237 long mol_stats(Bmolecule* mol);
238 int molecule_update_comment(Bmolgroup* molgroup, int n, char** strings);
239 int molecule_get_masses(Bmolgroup* molgroup, Bstring& paramfile);
240 Bbond* molgroup_bond_list_generate(Bmolgroup* molgroup, double maxlength, int wrap);
241 Bbond* mol_bond_list_generate(Bmolgroup* molgroup, double bondlength, int wrap);
242 int molecules_to_molgroups(Bmolgroup* molgroup);
243 
molgroup_init
Bmolgroup * molgroup_init()
Initializes and allocates a new molecule group.
Definition: rwmolecule.cpp:45
Bmolecule::Bmin
double Bmin
Definition: rwmolecule.h:118
RightHandedPi
@ RightHandedPi
Definition: rwmolecule.h:67
molgroup_stats
long molgroup_stats(Bmolgroup *molgroup, int show)
Calculates the statistics of a molecule group.
Definition: rwmolecule.cpp:1296
atom_add
Batom * atom_add(Batom **atom, const char *type)
Adds an atom to a linked list.
Definition: rwmolecule.cpp:152
residue_add
Bresidue * residue_add(Bresidue **res, const char *type)
Adds a residue to a linked list.
Definition: rwmolecule.cpp:113
SecondaryType
SecondaryType
Definition: rwmolecule.h:64
molgroup_kill
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
Definition: rwmolecule.cpp:374
Bsecondary::next
Bsecondary * next
Definition: rwmolecule.h:88
Bmolgroup::select
Bstring select
Definition: rwmolecule.h:185
Bbond::l
double l
Definition: rwmolecule.h:138
Bmolgroup::seqflag
int * seqflag
Definition: rwmolecule.h:188
Bmolecule::first_codon
long first_codon
Definition: rwmolecule.h:113
Bresidue::next
Bresidue * next
Definition: rwmolecule.h:50
residue_kill
int residue_kill(Bresidue *res)
Destroys a residue.
Definition: rwmolecule.cpp:453
LeftHandedOmega
@ LeftHandedOmega
Definition: rwmolecule.h:71
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:1467
Bstring
Definition: Bstring.h:29
Bangle::a
double a
Definition: rwmolecule.h:155
Bbond::next
Bbond * next
Definition: rwmolecule.h:135
molgroup_count_molecules
long molgroup_count_molecules(Bmolgroup *molgroup)
Counts the total number of molecules in a molecule group.
Definition: rwmolecule.cpp:1075
Bbond::atom1
Batom * atom1
Definition: rwmolecule.h:136
molgroup_list_kill
int molgroup_list_kill(Bmolgroup *molgroup)
Destroys a molecule group linked list.
Definition: rwmolecule.cpp:347
Bresidue::atom
Batom * atom
Definition: rwmolecule.h:54
Bangle
Definition: rwmolecule.h:150
Batom::num
int num
Definition: rwmolecule.h:26
Bmolecule::num
int num
Definition: rwmolecule.h:109
Bmolgroup::sgstring
Bstring sgstring
Definition: rwmolecule.h:178
Bmolgroup::mol
Bmolecule * mol
Definition: rwmolecule.h:189
TwoSevenRibbon
@ TwoSevenRibbon
Definition: rwmolecule.h:73
Vector3< double >
Batom::tnum
int tnum
Definition: rwmolecule.h:29
Batom::el
char el[4]
Definition: rwmolecule.h:27
UnitCell.h
Header file for unit cell functions.
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
Turn
@ Turn
Definition: rwmolecule.h:76
Bbond::atom2
Batom * atom2
Definition: rwmolecule.h:137
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
Bmolecule::min
Vector3< double > min
Definition: rwmolecule.h:116
Bmolecule::Bstd
double Bstd
Definition: rwmolecule.h:119
Batom::q
double q
Definition: rwmolecule.h:31
Bmolecule::nres
long nres
Definition: rwmolecule.h:111
mol_copy_and_add_to_molgroup
Bmolecule * mol_copy_and_add_to_molgroup(Bmolgroup *molgroup, Bmolecule *mol)
Copies a molecule and assign to a new pointer in the molgroup.
Definition: rwmolecule.cpp:664
atom_clean_type
int atom_clean_type(Batom *atom, const char *type)
Cleans up the type string and assigns an element code to an atom.
Definition: rwmolecule.cpp:229
Batom::next
Batom * next
Definition: rwmolecule.h:25
Bresidue::num
int num
Definition: rwmolecule.h:51
LeftHandedAlpha
@ LeftHandedAlpha
Definition: rwmolecule.h:70
Bmolecule::res
Bresidue * res
Definition: rwmolecule.h:122
Bmolecule::seq
Bstring seq
Definition: rwmolecule.h:114
Bmolgroup::unitcell
UnitCell unitcell
Definition: rwmolecule.h:179
mol_count_atoms
long mol_count_atoms(Bmolecule *mol)
Counts the total number of atoms in a molecule.
Definition: rwmolecule.cpp:1140
RightHanded310
@ RightHanded310
Definition: rwmolecule.h:69
Bangle::atom1
Batom * atom1
Definition: rwmolecule.h:152
Bmolecule::nbase
long nbase
Definition: rwmolecule.h:112
Bmolgroup::maxnalen
long maxnalen
Definition: rwmolecule.h:181
Bsecondary::num
int num
Definition: rwmolecule.h:90
mol_stats
long mol_stats(Bmolecule *mol, int show)
Calculates the statistics of a molecule.
Definition: rwmolecule.cpp:1362
RightHandedGamma
@ RightHandedGamma
Definition: rwmolecule.h:68
RightHandedAlpha
@ RightHandedAlpha
Definition: rwmolecule.h:65
Bbond
Definition: rwmolecule.h:134
angle_add
Bangle * angle_add(Bangle **angle, Batom *atom1, Batom *atom2, Batom *atom3, double a, double k)
Adds an angle to a linked list.
Definition: rwmolecule.cpp:312
Bmolecule::Bave
double Bave
Definition: rwmolecule.h:119
Bmolecule::next
Bmolecule * next
Definition: rwmolecule.h:108
Bmolecule
Definition: rwmolecule.h:107
Bmolgroup::box
Vector3< double > box
Definition: rwmolecule.h:184
Bsecondary::first
Bresidue * first
Definition: rwmolecule.h:94
Bmolgroup::bond
Bbond * bond
Definition: rwmolecule.h:190
Polyproline
@ Polyproline
Definition: rwmolecule.h:74
Bangle::next
Bangle * next
Definition: rwmolecule.h:151
Bmolgroup::filename
Bstring filename
Definition: rwmolecule.h:172
Bmolecule::sec
Bsecondary * sec
Definition: rwmolecule.h:123
show
int show(0)
Batom::type
char type[8]
Definition: rwmolecule.h:28
Vector3.h
Class for 3-value vectors.
Batom::vel
Vector3< double > vel
Definition: rwmolecule.h:35
Bmolgroup::next
Bmolgroup * next
Definition: rwmolecule.h:171
Bsecondary::nstrands
int nstrands
Definition: rwmolecule.h:93
Bstring.h
Header file for the string class.
Bsecondary::last
Bresidue * last
Definition: rwmolecule.h:95
Bmolgroup::sel
int sel
Definition: rwmolecule.h:186
molecules_to_molgroups
int molecules_to_molgroups(Bmolgroup *molgroup)
Converts molecules in a molecule group to individual molecule groups.
Definition: rwmolecule.cpp:1744
molgroup_list_write
int molgroup_list_write(Bstring &filename, Bmolgroup *molgroup)
Writes a molecule group list.
Definition: rwmolecule.cpp:1053
Bmolgroup::maxlen
long maxlen
Definition: rwmolecule.h:180
Batom::b
double b
Definition: rwmolecule.h:31
atom_count
long atom_count(Bmolgroup *molgroup)
Counts the number of atoms in a molecule group.
Definition: rwmolecule.cpp:205
angle_kill
int angle_kill(Bangle *angle)
Dealocates a list of angles.
Definition: rwmolecule.cpp:501
Bmolgroup::comment
Bstring comment
Definition: rwmolecule.h:175
mol_count_residues
long mol_count_residues(Bmolecule *mol)
Counts the total number of residues in a molecule.
Definition: rwmolecule.cpp:1106
Batom::mass
double mass
Definition: rwmolecule.h:32
Bsecondary::type
SecondaryType type
Definition: rwmolecule.h:89
molgroup_count_residues
long molgroup_count_residues(Bmolgroup *molgroup)
Counts the total number of residues in a molecule group.
Definition: rwmolecule.cpp:1090
molecule_kill
int molecule_kill(Bmolecule *mol)
Destroys a molecule.
Definition: rwmolecule.cpp:417
Batom::F
Vector3< double > F
Definition: rwmolecule.h:36
Bmolgroup::max
Vector3< double > max
Definition: rwmolecule.h:183
bond_add
Bbond * bond_add(Bbond **bond, Batom *atom1, Batom *atom2, double l, double k)
Adds a bond to a linked list.
Definition: rwmolecule.cpp:269
Bangle::atom2
Batom * atom2
Definition: rwmolecule.h:153
write_molecule
int write_molecule(char *filename, Bmolgroup *molgroup)
Writes a molecule group.
Definition: rwmolecule.cpp:975
Bmolgroup::num
int num
Definition: rwmolecule.h:173
Bmolgroup::min
Vector3< double > min
Definition: rwmolecule.h:182
Bmolecule::naseq
Bstring naseq
Definition: rwmolecule.h:115
Bresidue::type
char type[6]
Definition: rwmolecule.h:53
Batom::sel
int sel
Definition: rwmolecule.h:34
molgroup_consolidate_gaps
int molgroup_consolidate_gaps(Bmolgroup *molgroup)
Removes redundant gaps from an alignment.
Definition: rwmolecule.cpp:1249
Bresidue::insert
char insert[2]
Definition: rwmolecule.h:52
LeftHandedGamma
@ LeftHandedGamma
Definition: rwmolecule.h:72
Bresidue
Definition: rwmolecule.h:49
Bmolecule::Bmax
double Bmax
Definition: rwmolecule.h:118
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:1560
molgroup_bond_list_copy
Bbond * molgroup_bond_list_copy(Bmolgroup *molgroup, Bmolgroup *molgroupcopy)
Copies a bond list.
Definition: rwmolecule.cpp:706
molgroup_count_atoms
long molgroup_count_atoms(Bmolgroup *molgroup)
Counts the total number of atoms in a molecule group.
Definition: rwmolecule.cpp:1124
Bmolgroup
Definition: rwmolecule.h:170
UnitCell
Definition: UnitCell.h:22
molecule_get_masses
int molecule_get_masses(Bmolgroup *molgroup, Bstring &paramfile)
Gets atomic masses from a parameter file.
Definition: rwmolecule.cpp:1491
Strand
@ Strand
Definition: rwmolecule.h:75
RightHandedOmega
@ RightHandedOmega
Definition: rwmolecule.h:66
Batom::chrg
double chrg
Definition: rwmolecule.h:33
Bbond::k
double k
Definition: rwmolecule.h:139
molgroup_list_copy
Bmolgroup * molgroup_list_copy(Bmolgroup *molgroup)
Copies a molecule group list.
Definition: rwmolecule.cpp:522
Bsecondary
Definition: rwmolecule.h:87
Bmolgroup::fom
double fom
Definition: rwmolecule.h:187
Bangle::atom3
Batom * atom3
Definition: rwmolecule.h:154
Bmolgroup::id
Bstring id
Definition: rwmolecule.h:174
Bmolecule::sel
int sel
Definition: rwmolecule.h:120
bond_kill
int bond_kill(Bbond *bond)
Dealocates a list of bonds.
Definition: rwmolecule.cpp:480
Bmolecule::fom
double fom
Definition: rwmolecule.h:121
molecule_add
Bmolecule * molecule_add(Bmolecule **mol, char *name)
Adds a molecule to a linked list.
Definition: rwmolecule.cpp:76
Bangle::k
double k
Definition: rwmolecule.h:156
Bsecondary::sense
int sense
Definition: rwmolecule.h:92
Bmolgroup::pointgroup
Bstring pointgroup
Definition: rwmolecule.h:177
Bmolgroup::spacegroup
int spacegroup
Definition: rwmolecule.h:176
molgroup_copy
Bmolgroup * molgroup_copy(Bmolgroup *molgroup)
Copies a molecule group.
Definition: rwmolecule.cpp:547
Batom::coord
Vector3< double > coord
Definition: rwmolecule.h:30
mol_bond_list_generate
Bbond * mol_bond_list_generate(Bmolgroup *molgroup, double bondlength, int wrap)
Generates an intramolecular distance-based bond list.
Definition: rwmolecule.cpp:1680
Bmolgroup::angle
Bangle * angle
Definition: rwmolecule.h:191
Bmolecule::max
Vector3< double > max
Definition: rwmolecule.h:117
molecule_copy
Bmolecule * molecule_copy(Bmolecule *mol)
Copies a molecule.
Definition: rwmolecule.cpp:599
Batom
Definition: rwmolecule.h:24
residue_count
long residue_count(Bmolgroup *molgroup)
Counts the number of residues in a molecule group.
Definition: rwmolecule.cpp:188
Bmolecule::id
Bstring id
Definition: rwmolecule.h:110