Main Page | Namespace List | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Examples

Residue.h

00001 /* Copyright 2004
00002 Stanford University
00003 
00004 This file is part of the DSR PDB Library.
00005 
00006 The DSR PDB Library is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU Lesser General Public License as published by
00008 the Free Software Foundation; either version 2.1 of the License, or (at your
00009 option) any later version.
00010 
00011 The DSR PDB Library is distributed in the hope that it will be useful, but
00012 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00013 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00014 License for more details.
00015 
00016 You should have received a copy of the GNU Lesser General Public License
00017 along with the DSR PDB Library; see the file COPYING.LIB.  If not, write to
00018 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00019 MA 02111-1307, USA. */
00020 
00021 #ifndef DSR_PDB_RESIDUE_H
00022 #define DSR_PDB_RESIDUE_H
00023 
00024 #include <dsrpdb/Point.h>
00025 //#include <dsr/pdb/Protein.h>
00026 #include <dsrpdb/Atom.h>
00027 #include <vector>
00028 #include <map>
00029 #include <dsrpdb/small_map.h>
00030 //#include <dsrpdb/label.h>
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, //AL_HG1, 
00075                      AL_1HG1, AL_2HG1, AL_3HG1, AL_1HG2,
00076                      
00077                      AL_2HG2, AL_3HG2, AL_OG, AL_OG1, AL_SG,
00078                      
00079                      // AL_HD1, AL_HD2,
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, //AL_HE1, AL_HE2, AL_HE3, 
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, // AL_HZ2, AL_HZ3,
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     //----- Static functions
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     /*Residue( Label al, 
00256              std::vector<Residue::Atom_label> * atoms,
00257              std::vector<std::pair<Residue::Atom_label,
00258              Residue::Atom_label> > *bonds);*/
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     /*--------------- Data members-----------------------------------*/
00270     Atoms atoms_;
00271     std::vector<Bond> bonds_;
00272     Type label_;
00273     Index index_;
00274     Atom::Index min_atom_index_;
00275   };
00276 }
00277 #endif