forked from 3dem/relion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassembly.h
253 lines (196 loc) · 5.56 KB
/
assembly.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
* assembly.h
*
* Created on: Apr 16, 2013
* Author: "Sjors H.W. Scheres"
*/
#ifndef ASSEMBLY_H_
#define ASSEMBLY_H_
#include <cstdlib>
#include <cstdio>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include "src/args.h"
#include "src/matrix2d.h"
/*
* Hierarchical model for a macromolecular assembly, e.g. a DNA origami object
*
* Assembly
* -> Molecule
* -> Residue
* -> Atom (either a true one or a coarse-grain pseudo-atom)
*
*
*/
class Atom
{
public:
// Name of this Atom
std::string name;
// Coordinates
Matrix1D<RFLOAT> coords;
// Occupancy
RFLOAT occupancy;
// B-factor
RFLOAT bfactor;
// Empty constructor
Atom()
{
clear();
}
// Named constructor
Atom(std::string in_name)
{
clear();
name = in_name;
}
// Destructor needed for work with vectors
~Atom()
{
clear();
}
// Initialize
void clear();
// Get the 3D corrdinates as a POint3D
Matrix1D<RFLOAT> getCoordinates();
};
class Residue
{
public:
// Name of this Residue
std::string name;
// Number of this Residue
int number;
// All the Atoms in this Residue
std::vector<Atom> atoms;
// Empty Constructor
Residue()
{
clear();
}
// Constructor
Residue(std::string in_name, int in_number)
{
clear();
name = in_name;
number = in_number;
}
// Destructor needed for work with vectors
~Residue()
{
clear();
}
// Initialize
void clear();
// Add an Atom to this Residue;
long int addAtom(std::string atomname, RFLOAT x, RFLOAT y, RFLOAT z, RFLOAT occ = 1.0, RFLOAT bfac = 0.0);
int numberOfAtoms()
{
return atoms.size();
}
};
class Molecule
{
public:
// Name of this Molecule
std::string name;
// Alternative name of this Molecule (either chainID or segID)
std::string alt_name;
// All the Residues in this Molecule
std::vector<Residue> residues;
// Empty Constructor
Molecule()
{
clear();
}
// Constructor
Molecule(std::string in_name, std::string in_alt_name="")
{
clear();
name = in_name;
alt_name = in_alt_name;
}
// Destructor needed for work with vectors
~Molecule()
{
clear();
}
// Initialize
void clear();
// Number of residues in the molecule
long int numberOfResidues()
{
return residues.size();
}
// Insert a Residue at the specified position in this Molecule
long int insertResidue(Residue &res, int pos);
// Add a Residue to this Molecule
long int addResidue(Residue &res);
// Add a Residue to this Molecule
long int addResidue(std::string name, int resnum);
// Insert a stretch of residues from another Molecule based on consecutive residue numbering
// If start and end residues are negative: just add the entire molecule
void insertResidues(Molecule add, int residue_start = -1, int residue_end = -1);
};
class Assembly
{
public:
// Name of this Assembly
std::string name;
// All the Molecules in this Assembly
std::vector<Molecule> molecules;
// Empty Constructor
Assembly()
{
clear();
}
// Named Constructor
Assembly(std::string in_name)
{
clear();
name = in_name;
}
// Copy constructor
Assembly(const Assembly& op)
{
clear();
*this = op;
}
// Destructor needed for work with vectors
~Assembly()
{
clear();
}
// Initialize
void clear();
// Add a Molecule to this Assembly
long int addMolecule(std::string name, std::string alt_name);
// Add a Molecule to this Assembly
long int addMolecule(Molecule &toadd);
// return number of Molecules in the Assembly
long int numberOfMolecules() const;
// Total number of Atoms
long int numberOfAtoms() const;
// Total number of Residues
long int numberOfResidues() const;
// Print some information about the assembly
void printInformation(std::ostream& out = std::cout) const;
// Read PDB format
void readPDB(std::string filename, bool use_segid_instead_of_chainid = false, bool do_sort = true);
// Write the Assembly to a PDB file
void writePDB(std::string filename);
// Combine this Assembly with another one
// If there are identical Molecule.name instances, add a number-suffix to the new Assembly's Molecule.name (in the segID)
void join(Assembly &tojoin);
// Make sure that all Residues within each Molecule are in order w.r.t. their residue number
void sortResidues();
// Break Molecules into separate ones if a break larger than maximum_residue_break occurs in the residue numbering
// TODO
void checkBreaksInResidueNumbering(int maximum_residue_break = 500);
// Apply a transformation (first rotation, then shift)
void applyTransformation(Matrix2D<RFLOAT> &mat, Matrix1D<RFLOAT> &shift);
};
#endif /* ASSEMBLY_H_ */