| Bsoft 2.0.5 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 *************************************************************************/
64 enum SecondaryType {
65 RightHandedAlpha = 1,
66 RightHandedOmega = 2,
67 RightHandedPi = 3,
68 RightHandedGamma = 4,
69 RightHanded310 = 5,
70 LeftHandedAlpha = 6,
71 LeftHandedOmega = 7,
72 LeftHandedGamma = 8,
73 TwoSevenRibbon = 9,
74 Polyproline = 10,
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 */
197 Bmolgroup* molgroup_init();
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);
215 Bmolgroup* molgroup_list_copy(Bmolgroup* molgroup);
216 Bmolgroup* molgroup_copy(Bmolgroup* molgroup);
217 Bmolecule* molecule_copy(Bmolecule* mol);
218 Bmolecule* mol_copy_and_add_to_molgroup(Bmolgroup* molgroup, Bmolecule* mol);
219 Bbond* molgroup_bond_list_copy(Bmolgroup* molgroup, Bmolgroup* molgroupcopy);
220 int molgroup_from_molgroup_list(Bmolgroup* molgroup);
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
Bmolgroup::id
Bstring id
Definition: rwmolecule.h:174
Bmolgroup::angle
Bangle * angle
Definition: rwmolecule.h:191
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
Bmolecule::id
Bstring id
Definition: rwmolecule.h:110
Bmolecule::num
int num
Definition: rwmolecule.h:109
UnitCell
Definition: UnitCell.h:22
Bmolgroup::mol
Bmolecule * mol
Definition: rwmolecule.h:189
Bmolgroup::sgstring
Bstring sgstring
Definition: rwmolecule.h:178
write_molecule
int write_molecule(char *filename, Bmolgroup *molgroup)
Writes a molecule group.
Definition: rwmolecule.cpp:975
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
Batom::F
Vector3< double > F
Definition: rwmolecule.h:36
angle_kill
int angle_kill(Bangle *angle)
Dealocates a list of angles.
Definition: rwmolecule.cpp:501
Bmolecule::nres
long nres
Definition: rwmolecule.h:111
Bsecondary::sense
int sense
Definition: rwmolecule.h:92
molgroup_list_copy
Bmolgroup * molgroup_list_copy(Bmolgroup *molgroup)
Copies a molecule group list.
Definition: rwmolecule.cpp:522
molecule_kill
int molecule_kill(Bmolecule *mol)
Destroys a molecule.
Definition: rwmolecule.cpp:417
Bmolgroup::seqflag
int * seqflag
Definition: rwmolecule.h:188
Bmolecule::res
Bresidue * res
Definition: rwmolecule.h:122
molgroup_count_residues
long molgroup_count_residues(Bmolgroup *molgroup)
Counts the total number of residues in a molecule group.
Definition: rwmolecule.cpp:1085
Bmolgroup::unitcell
UnitCell unitcell
Definition: rwmolecule.h:179
Bmolecule::Bmin
double Bmin
Definition: rwmolecule.h:118
LeftHandedOmega
Definition: rwmolecule.h:71
Bbond::k
double k
Definition: rwmolecule.h:139
Bangle::next
Bangle * next
Definition: rwmolecule.h:151
Bresidue::insert
char insert[2]
Definition: rwmolecule.h:52
molecules_to_molgroups
int molecules_to_molgroups(Bmolgroup *molgroup)
Converts molecules in a molecule group to individual molecule groups.
Definition: rwmolecule.cpp:1739
molecule_get_masses
int molecule_get_masses(Bmolgroup *molgroup, Bstring &paramfile)
Gets atomic masses from a parameter file.
Definition: rwmolecule.cpp:1486
TwoSevenRibbon
Definition: rwmolecule.h:73
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:1675
Bsecondary::num
int num
Definition: rwmolecule.h:90
Bmolecule::min
Vector3< double > min
Definition: rwmolecule.h:116
molecule_copy
Bmolecule * molecule_copy(Bmolecule *mol)
Copies a molecule.
Definition: rwmolecule.cpp:599
mol_count_residues
long mol_count_residues(Bmolecule *mol)
Counts the total number of residues in a molecule.
Definition: rwmolecule.cpp:1101
Bresidue::type
char type[6]
Definition: rwmolecule.h:53
Bmolgroup::select
Bstring select
Definition: rwmolecule.h:185
LeftHandedAlpha
Definition: rwmolecule.h:70
Bsecondary::next
Bsecondary * next
Definition: rwmolecule.h:88
Bmolecule::Bave
double Bave
Definition: rwmolecule.h:119
Turn
Definition: rwmolecule.h:76
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
Bangle
Definition: rwmolecule.h:150
molgroup_list_write
int molgroup_list_write(Bstring &filename, Bmolgroup *molgroup)
Writes a molecule group list.
Definition: rwmolecule.cpp:1048
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
Batom::q
double q
Definition: rwmolecule.h:31
atom_count
long atom_count(Bmolgroup *molgroup)
Counts the number of atoms in a molecule group.
Definition: rwmolecule.cpp:205
Bmolgroup::maxnalen
long maxnalen
Definition: rwmolecule.h:181
Bsecondary::nstrands
int nstrands
Definition: rwmolecule.h:93
residue_add
Bresidue * residue_add(Bresidue **res, const char *type)
Adds a residue to a linked list.
Definition: rwmolecule.cpp:113
Batom::sel
int sel
Definition: rwmolecule.h:34
Bmolgroup::box
Vector3< double > box
Definition: rwmolecule.h:184
Bmolecule::sec
Bsecondary * sec
Definition: rwmolecule.h:123
Batom::type
char type[8]
Definition: rwmolecule.h:28
Bbond::atom2
Batom * atom2
Definition: rwmolecule.h:137
Batom::num
int num
Definition: rwmolecule.h:26
Bmolgroup::sel
int sel
Definition: rwmolecule.h:186
Bmolecule::seq
Bstring seq
Definition: rwmolecule.h:114
Bsecondary::last
Bresidue * last
Definition: rwmolecule.h:95
Bmolgroup
Definition: rwmolecule.h:170
Bmolecule::nbase
long nbase
Definition: rwmolecule.h:112
molgroup_stats
long molgroup_stats(Bmolgroup *molgroup, int show)
Calculates the statistics of a molecule group.
Definition: rwmolecule.cpp:1291
RightHanded310
Definition: rwmolecule.h:69
molgroup_count_molecules
long molgroup_count_molecules(Bmolgroup *molgroup)
Counts the total number of molecules in a molecule group.
Definition: rwmolecule.cpp:1070
molgroup_count_atoms
long molgroup_count_atoms(Bmolgroup *molgroup)
Counts the total number of atoms in a molecule group.
Definition: rwmolecule.cpp:1119
Bmolecule::Bstd
double Bstd
Definition: rwmolecule.h:119
molgroup_copy
Bmolgroup * molgroup_copy(Bmolgroup *molgroup)
Copies a molecule group.
Definition: rwmolecule.cpp:547
molgroup_consolidate_gaps
int molgroup_consolidate_gaps(Bmolgroup *molgroup)
Removes redundant gaps from an alignment.
Definition: rwmolecule.cpp:1244
Bbond::l
double l
Definition: rwmolecule.h:138
Bmolgroup::comment
Bstring comment
Definition: rwmolecule.h:175
residue_count
long residue_count(Bmolgroup *molgroup)
Counts the number of residues in a molecule group.
Definition: rwmolecule.cpp:188
molgroup_kill
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
Definition: rwmolecule.cpp:374
molgroup_init
Bmolgroup * molgroup_init()
Initializes and allocates a new molecule group.
Definition: rwmolecule.cpp:45
RightHandedGamma
Definition: rwmolecule.h:68
Bmolecule::next
Bmolecule * next
Definition: rwmolecule.h:108
molecule_add
Bmolecule * molecule_add(Bmolecule **mol, char *name)
Adds a molecule to a linked list.
Definition: rwmolecule.cpp:76
RightHandedAlpha
Definition: rwmolecule.h:65
bond_kill
int bond_kill(Bbond *bond)
Dealocates a list of bonds.
Definition: rwmolecule.cpp:480
molgroup_bond_list_copy
Bbond * molgroup_bond_list_copy(Bmolgroup *molgroup, Bmolgroup *molgroupcopy)
Copies a bond list.
Definition: rwmolecule.cpp:706
Bmolecule::naseq
Bstring naseq
Definition: rwmolecule.h:115
Bmolgroup::maxlen
long maxlen
Definition: rwmolecule.h:180
Batom::b
double b
Definition: rwmolecule.h:31
Bmolgroup::max
Vector3< double > max
Definition: rwmolecule.h:183
Polyproline
Definition: rwmolecule.h:74
Bmolgroup::filename
Bstring filename
Definition: rwmolecule.h:172
Bmolgroup::next
Bmolgroup * next
Definition: rwmolecule.h:171
Bangle::atom2
Batom * atom2
Definition: rwmolecule.h:153
Bmolecule::Bmax
double Bmax
Definition: rwmolecule.h:118
residue_kill
int residue_kill(Bresidue *res)
Destroys a residue.
Definition: rwmolecule.cpp:453
mol_count_atoms
long mol_count_atoms(Bmolecule *mol)
Counts the total number of atoms in a molecule.
Definition: rwmolecule.cpp:1135
Bresidue::atom
Batom * atom
Definition: rwmolecule.h:54
Bmolecule
Definition: rwmolecule.h:107
molgroup_list_kill
int molgroup_list_kill(Bmolgroup *molgroup)
Destroys a molecule group linked list.
Definition: rwmolecule.cpp:347
atom_add
Batom * atom_add(Batom **atom, const char *type)
Adds an atom to a linked list.
Definition: rwmolecule.cpp:152
Bmolgroup::bond
Bbond * bond
Definition: rwmolecule.h:190
Bresidue::next
Bresidue * next
Definition: rwmolecule.h:50
Bresidue
Definition: rwmolecule.h:49
SecondaryType
SecondaryType
Definition: rwmolecule.h:64
Bstring
Definition: Bstring.h:29
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
Batom
Definition: rwmolecule.h:24
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
Bsecondary::first
Bresidue * first
Definition: rwmolecule.h:94
LeftHandedGamma
Definition: rwmolecule.h:72
Bbond::atom1
Batom * atom1
Definition: rwmolecule.h:136
UnitCell.h
Header file for unit cell functions.
Bmolecule::sel
int sel
Definition: rwmolecule.h:120
Bmolecule::fom
double fom
Definition: rwmolecule.h:121
Vector3< double >
Bangle::a
double a
Definition: rwmolecule.h:155
Bresidue::num
int num
Definition: rwmolecule.h:51
Bstring.h
Header file for the string class.
Vector3.h
Class for 3-value vectors.
show
int show(0)
Bmolgroup::pointgroup
Bstring pointgroup
Definition: rwmolecule.h:177
Batom::coord
Vector3< double > coord
Definition: rwmolecule.h:30
Bmolgroup::fom
double fom
Definition: rwmolecule.h:187
Bmolecule::max
Vector3< double > max
Definition: rwmolecule.h:117
Bbond
Definition: rwmolecule.h:134
Bbond::next
Bbond * next
Definition: rwmolecule.h:135
Batom::el
char el[4]
Definition: rwmolecule.h:27
Bmolgroup::min
Vector3< double > min
Definition: rwmolecule.h:182
Bmolgroup::num
int num
Definition: rwmolecule.h:173
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
Bangle::atom1
Batom * atom1
Definition: rwmolecule.h:152
Bmolgroup::spacegroup
int spacegroup
Definition: rwmolecule.h:176
Bangle::k
double k
Definition: rwmolecule.h:156
RightHandedOmega
Definition: rwmolecule.h:66
Batom::chrg
double chrg
Definition: rwmolecule.h:33
Bangle::atom3
Batom * atom3
Definition: rwmolecule.h:154
Strand
Definition: rwmolecule.h:75
Bsecondary::type
SecondaryType type
Definition: rwmolecule.h:89
Batom::tnum
int tnum
Definition: rwmolecule.h:29
mol_stats
long mol_stats(Bmolecule *mol, int show)
Calculates the statistics of a molecule.
Definition: rwmolecule.cpp:1357
Bmolecule::first_codon
long first_codon
Definition: rwmolecule.h:113
Batom::next
Batom * next
Definition: rwmolecule.h:25
Batom::mass
double mass
Definition: rwmolecule.h:32
Batom::vel
Vector3< double > vel
Definition: rwmolecule.h:35
RightHandedPi
Definition: rwmolecule.h:67
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
Bsecondary
Definition: rwmolecule.h:87