Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef ESBTL_GLOBAL_FUNCTIONS_H
00036 #define ESBTL_GLOBAL_FUNCTIONS_H
00037
00038 #include <fstream>
00039
00040 namespace ESBTL {
00041
00042
00051 template <class Atom>
00052 bool is_backbone(const Atom& atom){
00053 if (get_is_hetatm(atom))
00054 return false;
00055 std::string atomname=get_atom_name(atom);
00056 return atomname=="N" ||
00057 atomname=="CA" ||
00058 atomname=="C" ||
00059 atomname=="O" ||
00060 atomname=="OXT";
00061 }
00062
00071 template <class Atom>
00072 bool is_side_chain_or_CA(const Atom& atom){
00073 if (atom.is_hetatm())
00074 return false;
00075 return !is_backbone(atom) || get_atom_name(atom)=="CA";
00076 }
00077
00084 template <class Atom>
00085 bool is_hydrogen(const Atom& atom){
00086 return get_element(atom) == std::string("H");
00087 }
00088
00096 template <class Atom>
00097 bool is_water(const Atom& atom){
00098 std::string resname=get_residue_name(atom);
00099 return resname=="HOH" || resname=="SOL" || resname=="WAT";
00100 }
00101
00102
00115 template<class Atom_iterator,class Classifier_with_radius,class Color_of>
00116 void write_to_cgo(const std::string& filename,Atom_iterator first, Atom_iterator last,
00117 const Classifier_with_radius& classifier,const Color_of& color_of)
00118 {
00119 std::ofstream st(filename.c_str());
00120 st << "from pymol.cgo import *\n";
00121 st << "from pymol import cmd\n";
00122 st << "obj=[\n";
00123
00124 for (Atom_iterator it=first;it!=last;++it){
00125 st << "COLOR," << color_of(*it);
00126 st << ",SPHERE, " <<it->x() << ", " << it->y() << ", " << it->z() << ", ";
00127 st << get_radius(classifier.get_properties(*it)) << ",\n";
00128 }
00129
00130 st << "]\ncmd.load_cgo(obj,\'cgo01\')\n";
00131 }
00132
00133 }
00134
00135 #endif //ESBTL_GLOBAL_FUNCTIONS_H