00001 //------------------------------------------------------------------------------ 00002 // This file is part of the OpenStructure project <www.openstructure.org> 00003 // 00004 // Copyright (C) 2008-2015 by the OpenStructure authors 00005 // 00006 // This library is free software; you can redistribute it and/or modify it under 00007 // the terms of the GNU Lesser General Public License as published by the Free 00008 // Software Foundation; either version 3.0 of the License, or (at your option) 00009 // any later version. 00010 // This library is distributed in the hope that it will be useful, but WITHOUT 00011 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00012 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00013 // details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public License 00016 // along with this library; if not, write to the Free Software Foundation, Inc., 00017 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 //------------------------------------------------------------------------------ 00019 00020 #ifndef OST_MM_HEURISTIC_BLOCK_MODIFIERS_HH 00021 #define OST_MM_HEURISTIC_BLOCK_MODIFIERS_HH 00022 00023 00024 #include <boost/shared_ptr.hpp> 00025 00026 #include <ost/message.hh> 00027 #include <ost/mol/bond_handle.hh> 00028 #include <ost/mol/residue_handle.hh> 00029 #include <ost/mol/entity_handle.hh> 00030 #include <ost/mol/atom_handle.hh> 00031 #include <ost/mol/xcs_editor.hh> 00032 #include <ost/geom/vec3.hh> 00033 #include <ost/mol/mm/block_modifiers.hh> 00034 #include <ost/mol/mm/buildingblock.hh> 00035 00036 00037 namespace ost{ namespace mol{ namespace mm{ 00038 00039 class HeuristicHydrogenConstructor; 00040 class HeuristicTerminiConstructor; 00041 class HeuristicBlockModifier; 00042 00043 typedef boost::shared_ptr<HeuristicHydrogenConstructor> HeuristicHydrogenConstructorPtr; 00044 typedef boost::shared_ptr<HeuristicTerminiConstructor> HeuristicTerminiConstructorPtr; 00045 typedef boost::shared_ptr<HeuristicBlockModifier> HeuristicBlockModifierPtr; 00046 00047 00048 class HeuristicHydrogenConstructor : public HydrogenConstructor{ 00049 00050 public: 00051 00052 HeuristicHydrogenConstructor(BuildingBlockPtr block); 00053 00054 virtual void ApplyOnBuildingBlock(BuildingBlockPtr); 00055 00056 virtual void ApplyOnResidue(ost::mol::ResidueHandle& res, ost::mol::XCSEditor& ed); 00057 00058 virtual void OnSave(ost::io::BinaryDataSink& ds) { ds << *this; } 00059 00060 virtual BlockModifierType GetBlockModifierType() { return HeuristicBlockModifiers; } 00061 00062 template <typename DS> 00063 00064 void Serialize(DS& ds){ 00065 00066 if(ds.IsSource()){ 00067 int num_anchor_atoms = 0; 00068 int num_antecendents = 0; 00069 int num_hydrogens = 0; 00070 String loaded_string; 00071 00072 ds & num_anchor_atoms; 00073 00074 for(int i = 0; i < num_anchor_atoms; ++i){ 00075 ds & num_antecendents; 00076 ds & num_hydrogens; 00077 00078 ds & loaded_string; 00079 anchor_atom_names_.push_back(loaded_string); 00080 00081 antecedent_names_.push_back(std::vector<String>()); 00082 for(int j = 0; j < num_antecendents; ++j){ 00083 ds & loaded_string; 00084 antecedent_names_[i].push_back(loaded_string); 00085 } 00086 00087 hydrogen_names_.push_back(std::vector<String>()); 00088 for(int j = 0; j < num_hydrogens; ++j){ 00089 ds & loaded_string; 00090 hydrogen_names_[i].push_back(loaded_string); 00091 } 00092 } 00093 } 00094 else{ 00095 int num_anchor_atoms = anchor_atom_names_.size(); 00096 int num_antecendents = 0; 00097 int num_hydrogens = 0; 00098 00099 ds & num_anchor_atoms; 00100 00101 for(int i = 0; i < num_anchor_atoms; ++i){ 00102 00103 num_antecendents = antecedent_names_[i].size(); 00104 num_hydrogens = hydrogen_names_[i].size(); 00105 ds & num_antecendents; 00106 ds & num_hydrogens; 00107 ds & anchor_atom_names_[i]; 00108 00109 00110 for(std::vector<String>::iterator j = antecedent_names_[i].begin(); 00111 j != antecedent_names_[i].end(); ++j){ 00112 ds & *j; 00113 } 00114 00115 for(std::vector<String>::iterator j = hydrogen_names_[i].begin(); 00116 j != hydrogen_names_[i].end(); ++j){ 00117 ds & *j; 00118 } 00119 } 00120 00121 } 00122 } 00123 00124 private: 00125 std::vector<String> anchor_atom_names_; 00126 std::vector<std::vector<String> > antecedent_names_; 00127 std::vector<std::vector<String> > hydrogen_names_; 00128 }; 00129 00130 00131 class HeuristicBlockModifier : public BlockModifier{ 00132 00133 public: 00134 00135 HeuristicBlockModifier() { } 00136 00137 virtual void ApplyOnBuildingBlock(BuildingBlockPtr p); 00138 00139 virtual void ApplyOnResidue(ost::mol::ResidueHandle& res, ost::mol::XCSEditor& ed); 00140 00141 virtual BlockModifierType GetBlockModifierType() { return HeuristicBlockModifiers; } 00142 00143 virtual void OnSave(ost::io::BinaryDataSink& ds) { ds << *this; } 00144 00145 template <typename DS> 00146 00147 void Serialize(DS& ds){ 00148 00149 } 00150 00151 }; 00152 00153 00154 00155 }}} 00156 00157 #endif