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

geometry.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_GEOMETRY_H
00022 #define DSR_PDB_GEOMETRY_H
00023 
00024 #include <dsrpdb/Protein.h>
00025 #include <dsrpdb/iterator.h>
00026 #include <vector>
00027 #include <cassert>
00028 #include <dsrpdb/geometry_internal.h>
00029 
00030 namespace dsrpdb {
00032 
00036   template <class Ait, class Voit>
00037   inline void coordinates(Ait ab, Ait ae, Voit out){
00038     internal::filtered_coordinates(ab, ae, Yes(), out);
00039   }
00040   
00042 
00046   template <class Ait, class Voit>
00047   inline void backbone_coordinates(Ait ab, Ait ae, Voit out){
00048     internal::filtered_coordinates(ab, ae, Is_backbone(), out);
00049   }
00050   
00052 
00056   template <class Ait, class Voit>
00057   inline void ca_coordinates(Ait ab, Ait ae, Voit out){
00058     internal::filtered_coordinates(ab, ae, Is_CA(), out);
00059   }
00060   
00061   
00062 
00063 
00065 
00069   template <class Voit, class Boit>
00070   inline void coordinates_and_bonds(const Protein &p, Voit out, Boit bout){
00071     internal::filtered_coordinates_and_bonds(p, Yes(), out, bout);
00072   }
00073 
00075 
00079   template <class Voit, class Boit>
00080   inline void backbone_coordinates_and_bonds(const Protein &p, Voit out, Boit bout){
00081     internal::filtered_coordinates_and_bonds(p, Is_backbone(), out, bout);
00082   }
00083 
00084 
00086 
00090   template <class Voit, class Boit>
00091   inline void ca_coordinates_and_bonds(const Protein &p,Voit out, Boit bout){
00092     internal::filtered_coordinates_and_bonds(p, Is_CA(), out, bout);
00093   }
00094 
00095 
00097 
00101   template <class Voit, class Boit>
00102   inline int simplified_coordinates_and_bonds(const Protein &p,Voit out, Boit bout){
00103     int index=-1;
00104     std::vector<int> ca_indices;
00105     //const Residue::Atom_label als[]={ Residue::AL_CA};
00106     for (Protein::Const_residues_iterator rit= p.residues_begin(); 
00107          rit != p.residues_end(); ++rit){
00108       //for (unsigned int i=0; i< 3; ++i){
00109       if (rit->has_atom(Residue::AL_N)){
00110         *out= rit->atom(Residue::AL_N).cartesian_coords();
00111         ++out;
00112         ++index;
00113         if (index != 0) {
00114           *bout = std::pair<int,int>(index-1, index);
00115           ++bout;
00116         }
00117       }
00118       if (rit->has_atom(Residue::AL_CA)){
00119         *out= rit->atom(Residue::AL_CA).cartesian_coords();
00120         ++out;
00121         
00122         ++index;
00123         if (index != 0) {
00124           *bout = std::pair<int,int>(index-1, index);
00125           ++bout;
00126         }
00127         ca_indices.push_back(index);
00128       }
00129       if (rit->has_atom(Residue::AL_C)){
00130         *out= rit->atom(Residue::AL_C).cartesian_coords();
00131         ++out;
00132         ++index;
00133         if (index != 0) {
00134           *bout = std::pair<int,int>(index-1, index);
00135           ++bout;
00136         }
00137       }
00138     }
00139     int nbackbone=index+1;
00140     int rindex=0;
00141     for (Protein::Const_residues_iterator rit= p.residues_begin(); 
00142          rit != p.residues_end(); ++rit){
00143       //for (unsigned int i=0; i< 3; ++i){
00144       if (rit->has_atom(Residue::AL_CA)){
00145         
00146         *out = rit->sidechain_point();
00147         ++out;
00148         
00149         ++index;
00150 
00151         *bout = std::pair<int,int>(ca_indices[rindex], index);
00152         ++bout;
00153         
00154         ++rindex;
00155       }
00156     }
00157     return nbackbone;
00158   }
00159 }
00160 
00161 #endif