coarse_classifier.h
Go to the documentation of this file.
00001 // Copyright (c) 2009-2010  INRIA Sophia-Antipolis (France).
00002 // All rights reserved.
00003 //
00004 //This file is part of ESBTL.
00005 //
00006 //ESBTL is free software: you can redistribute it and/or modify
00007 //it under the terms of the GNU General Public License as published by
00008 //the Free Software Foundation, either version 3 of the License, or
00009 //(at your option) any later version.
00010 //
00011 //ESBTL is distributed in the hope that it will be useful,
00012 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //GNU General Public License for more details.
00015 //
00016 //You should have received a copy of the GNU General Public License
00017 //along with ESBTL.  If not, see <http://www.gnu.org/licenses/>.
00018 //
00019 //
00020 //Additional permission under GNU GPL version 3 section 7
00021 //
00022 //If you modify this Library, or any covered work, by linking or
00023 //combining it with CGAL (or a modified version of that library), the
00024 //licensors of this Library grant you additional permission to convey
00025 //the resulting work. Corresponding Source for a non-source form of
00026 //such a combination shall include the source code for the parts of CGAL
00027 //used as well as that of the covered work. 
00028 //
00029 //
00030 //
00031 // Author(s)     :  Sébastien Loriot
00032 
00033 
00034 
00035 #ifndef ESBTL_COARSE_CLASSIFIER_H
00036 #define ESBTL_COARSE_CLASSIFIER_H
00037 
00038 
00039 #include <ESBTL/atom_classifier.h>
00040 
00041 namespace ESBTL{
00042 
00043 
00050 template <class NT,class Coarse_atom>
00051 class Radius_of_coarse_atom{
00052 private:
00053   typedef Radius_of_coarse_atom<NT,Coarse_atom>  Self;
00054   NT radius_;
00055 public:
00056   typedef Coarse_atom           Query_type;
00057   typedef std::string           Key_type;
00058   typedef NT                    Value_type;
00059   
00060 
00061   Radius_of_coarse_atom(const NT& radius):radius_(radius){}
00062   NT value() const {return radius_;}
00063   
00064     
00065   template <class Dictionary,class Vector_properties>
00066   static unsigned default_loader(Dictionary& dict,Vector_properties& vect)
00067   {
00069     #include <ESBTL/properties/default_coarse_radii.h>
00071   }
00072   
00074   static std::string make_key(const Coarse_atom& atom)
00075   {
00076     return atom.residue().residue_name();
00077   }
00078   
00079   static
00080   int& index_of_default(){
00081     static int index_of_default=-1;
00082     return index_of_default;
00083   }  
00084 };
00085 
00087 template <class NT,class Coarse_atom>
00088 NT get_radius(const Radius_of_coarse_atom<NT,Coarse_atom>& property){
00089   return property.value();
00090 }
00091 
00102 template<class Atom>
00103 struct Color_of_atom{
00107   std::string operator() (const Atom& atm) const{
00108     std::string name=atm.residue().residue_name();
00109     if ( name == "ALA" || name == "CYS" || name == "GLY" ||
00110           name == "PRO" || name == "SER" || name == "THR" )
00111       return std::string("1,1,0"); // yellow: normal
00112     
00113     if ( name == "VAL" || name == "LEU" || name == "ILE" ||
00114            name == "MET" || name == "MSE" || name == "PHE" ||
00115            name == "TYR" || name == "TRP" )
00116         return std::string("0,0.80,0");// green: hydrophobic
00117     
00118     if ( name == "HIS" || name == "LYS" || name == "ARG")
00119       return std::string("0,0,0.93");//blue: positive charge
00120     
00121     if ( name == "ASN" || name == "GLN" )
00122       return std::string("0.54,0.04,0.31 ");//purple: +/- charge
00123     
00124     if ( name == "GLU" || name == "ASP" )
00125         return std::string("0.77,0,0 ");//red: negative charge
00126     return std::string("0.5,0.5,0.5 ");//unknown residue
00127   }    
00128 };
00129 
00136 template <class Atom>
00137 class Color_of_residues{
00138   std::string color_;
00139 public:  
00140   static
00141   int& index_of_default(){
00142     static int index_of_default=-1;
00143     return index_of_default;
00144   }
00145   
00146   
00147   //~ typedef std::pair<unsigned,unsigned> Key_type;
00148   typedef std::string Key_type;
00149   typedef Atom Query_type;
00150 
00151   Color_of_residues(const std::string& color):color_(color){}
00152     
00153   template <class Dictionary,class Vector_properties>
00154   static unsigned default_loader(Dictionary& dict,Vector_properties& vect)
00155   {
00156     dict["ALA"]=0;
00157     dict["CYS"]=0;
00158     dict["GLY"]=0;
00159     dict["PRO"]=0;
00160     dict["SER"]=0;
00161     dict["THR"]=0;
00162     vect.push_back(std::string("1,1,0")); // yellow: normal
00163     dict["VAL"]=1;
00164     dict["LEU"]=1;
00165     dict["ILE"]=1;
00166     dict["MET"]=1;
00167     dict["MSE"]=1;
00168     dict["PHE"]=1;
00169     dict["TYR"]=1;
00170     dict["TRP"]=1;
00171     vect.push_back(std::string("0,0.80,0"));// green: hydrophobic
00172     dict["HIS"]=2;
00173     dict["LYS"]=2;
00174     dict["ARG"]=2;
00175     vect.push_back(std::string("0,0,0.93"));//blue: positive charge
00176     dict["ASN"]=3;
00177     dict["GLN"]=3;
00178     vect.push_back(std::string("0.54,0.04,0.31 "));//purple: +/- charge
00179     dict["GLU"]=4;
00180     dict["ASP"]=4;
00181     vect.push_back(std::string("0.77,0,0 "));//red: negative charge
00182     vect.push_back(std::string("0.5,0.5,0.5 "));//unknown residue
00183     index_of_default()=4;
00184     return 5;
00185   }
00186   
00187   static Key_type make_key(const Query_type& atom)
00188   {
00189     return get_residue_name(atom);
00190   }
00191 };
00192 
00193 }//namespace ESBTL
00194 
00195 #endif //ESBTL_COARSE_CLASSIFIER_H