00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef DSR_PDB_RESIDUE_H
00022 #define DSR_PDB_RESIDUE_H
00023
00024 #include <dsrpdb/Point.h>
00025
00026 #include <dsrpdb/Atom.h>
00027 #include <vector>
00028 #include <map>
00029 #include <dsrpdb/small_map.h>
00030
00031
00032 namespace dsrpdb {
00033
00034 class Protein;
00035
00037
00042 class Residue {
00043 friend class Protein;
00044 struct Residue_type_tag{};
00045 struct Atom_type_tag{};
00046 public:
00048 typedef PDB_index<Residue> Index;
00049
00051 enum Type { GLY=0, ALA, VAL, LEU, ILE,
00052 SER, THR, CYS, MET, PRO,
00053 ASP, ASN, GLU, GLN, LYS,
00054 ARG, HIS, PHE, TYR, TRP,
00055 ACE, NH2, INV };
00056
00057
00059
00064 enum Atom_label {AL_OTHER, AL_INVALID,
00065 AL_N, AL_H, AL_1H, AL_2H, AL_3H,
00066
00067
00068 AL_CA, AL_HA, AL_1HA, AL_2HA,
00069
00070 AL_CB, AL_HB, AL_1HB, AL_2HB, AL_3HB,
00071
00072 AL_C, AL_O, AL_OXT, AL_CH3,
00073
00074 AL_CG, AL_CG1, AL_CG2, AL_HG, AL_1HG, AL_2HG,
00075 AL_1HG1, AL_2HG1, AL_3HG1, AL_1HG2,
00076
00077 AL_2HG2, AL_3HG2, AL_OG, AL_OG1, AL_SG,
00078
00079
00080 AL_CD, AL_CD1, AL_CD2, AL_HD, AL_1HD, AL_2HD, AL_3HD, AL_1HD1,
00081 AL_2HD1, AL_3HD1, AL_1HD2, AL_2HD2, AL_3HD2, AL_SD,
00082 AL_OD1, AL_OD2, AL_ND1, AL_ND2,
00083
00084 AL_CE, AL_CE1, AL_CE2, AL_CE3, AL_HE, AL_1HE, AL_2HE,
00085 AL_3HE,
00086 AL_1HE2, AL_2HE2,
00087 AL_OE1, AL_OE2, AL_NE, AL_NE1, AL_NE2,
00088
00089 AL_CZ, AL_CZ2, AL_CZ3, AL_NZ, AL_HZ, AL_1HZ, AL_2HZ,
00090 AL_3HZ,
00091
00092 AL_CH2, AL_NH1, AL_NH2, AL_OH, AL_HH, AL_1HH1,
00093 AL_2HH1, AL_HH2, AL_1HH2, AL_2HH2,
00094 AL_1HH3, AL_2HH3, AL_3HH3};
00095
00096
00097
00099
00102 typedef std::pair<Atom::Index,Atom::Index> Bond;
00103
00104 typedef small_map<Atom_label, Atom> Atoms;
00105
00107 Residue(){}
00108
00110 Residue(Type al);
00111
00113 Type type() const;
00114
00115
00117 typedef std::vector<Bond>::const_iterator Bonds_iterator;
00118
00120
00125 Bonds_iterator bonds_begin() const {
00126 return bonds_.begin();
00127 }
00129 Bonds_iterator bonds_end() const {
00130 return bonds_.end();
00131 }
00133 unsigned int number_of_bonds() const;
00134
00135
00137 typedef Atoms::iterator Atoms_iterator;
00138
00140 Atoms_iterator atoms_begin() {
00141 return atoms_.begin();
00142 }
00143
00145 Atoms_iterator atoms_end() {
00146 return atoms_.end();
00147 }
00148
00150 typedef Atoms::const_iterator Const_atoms_iterator;
00151
00153 Const_atoms_iterator atoms_begin() const {
00154 return atoms_.begin();
00155 }
00156
00158 Const_atoms_iterator atoms_end() const {
00159 return atoms_.end();
00160 }
00161
00162
00163
00165 unsigned int number_of_atoms() const;
00166
00167
00169 bool has_atom(Atom_label al) const;
00170
00172 bool can_have_atom(Atom_label al) const;
00173
00174
00176 const Atom& atom(Atom_label al) const;
00177
00179 Atom_label atom_label(Atom::Index model_index) const;
00180
00182
00185 void set_atom(Atom_label al, const Atom &a);
00186
00188 void set_atom_from_string(const char *str, const Atom &a) {
00189 set_atom(atom_label(str), a);
00190 }
00192 Atom::Index last_atom_index() const;
00193
00195
00198 Index index() const {
00199 return index_;
00200 }
00201
00203 void set_index(Index i);
00204
00205
00207 void dump(std::ostream &out) const;
00209 void write(char chain, std::ostream &out) const;
00210
00211
00212
00214
00218 Point sidechain_point() const;
00219
00220
00222
00225 void set_has_bonds(bool tf);
00226
00228 bool has_bonds() const {
00229 return !bonds_.empty();
00230 }
00231
00232
00233
00234
00236 static Type type(const std::string &st);
00238 static std::string type_string(Type rl);
00239
00241 static Atom::Type element(Atom_label al);
00242
00244 static std::string atom_label_string(Atom_label al);
00246
00249 static Atom_label atom_label(const char *c);
00250
00251
00252
00253
00254 protected:
00255
00256
00257
00258
00259 Atom::Index index(Residue::Atom_label al) const;
00260
00261 Atom::Index min_atom_index() const {
00262 return min_atom_index_;
00263 }
00264
00265 Atoms_iterator atoms_iterator_from_index(Atom::Index ind);
00266 Const_atoms_iterator atoms_iterator_from_index(Atom::Index ind) const;
00267 private:
00268
00269
00270 Atoms atoms_;
00271 std::vector<Bond> bonds_;
00272 Type label_;
00273 Index index_;
00274 Atom::Index min_atom_index_;
00275 };
00276 }
00277 #endif