1 // SEQBUILD.H : a sequence builder class for building and identifying sequences. 2 3 // Copyright (C) 1998 Tommi Hassinen, Geoff Hutchison. 4 5 // This package is free software; you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation; either version 2 of the License, or 8 // (at your option) any later version. 9 10 // This package is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 15 // You should have received a copy of the GNU General Public License 16 // along with this package; if not, write to the Free Software 17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 19 /*################################################################################################*/ 20 21 #ifndef SEQBUILD_H 22 #define SEQBUILD_H 23 24 #include "libghemicaldefine.h" 25 26 struct sb_constraint_crd; 27 struct sb_constraint_tor; 28 29 class sb_chain_descriptor; 30 31 class sequencebuilder; 32 33 class sb_data_td; // for internal use only... 34 class sb_data_atm; // for internal use only... 35 class sb_data_bnd; // for internal use only... 36 37 class sb_data_res; // for internal use only... 38 39 struct sb_tdata; // for internal use only... 40 41 /*################################################################################################*/ 42 43 #include "atom.h" 44 #include "bond.h" 45 46 #include "chn_info.h" 47 #include "typerule.h" 48 49 typedef vector<atom *> atmr_vector; 50 51 /*################################################################################################*/ 52 53 struct sb_constraint_crd 54 { 55 int pos; 56 57 int atm_id; 58 float crdX; 59 float crdY; 60 float crdZ; 61 }; 62 63 struct sb_constraint_tor 64 { 65 int pos; 66 67 int tor_ind; 68 float tor_val; 69 }; 70 71 /** A sb_chain_descriptor object describes the chain to be built for the Build() method of 72 the sequence builder class. It describes the chain using either 1-letter or 3-letter codes 73 and it can optionally contain information about 3D-structure as well. 74 */ 75 76 class sb_chain_descriptor 77 { 78 protected: 79 80 bool mode_1_letter; 81 82 vector<char> * seq1; 83 vector<char *> * seq3; 84 85 int curr_res; 86 87 int c_crd_BGN; int c_crd_END; 88 vector<sb_constraint_crd> c_crd_v; 89 90 int c_tor_BGN; int c_tor_END; 91 vector<sb_constraint_tor> c_tor_v; 92 93 friend class sequencebuilder; 94 95 public: 96 97 vector<f64> def_tor; 98 99 public: 100 101 sb_chain_descriptor(bool); 102 ~sb_chain_descriptor(void); 103 104 int AddRes1(char); // return value is the current chain length. 105 int AddRes3(const char *); // return value is the current chain length. 106 107 void AddCRD(int, float, float, float); 108 void AddTOR(int, float); 109 }; 110 111 /*################################################################################################*/ 112 113 /** A generic sequence builder class. This same code will handle both peptides/proteins 114 and nucleic acids. Only the input file read in ctor is different. The sequence builders 115 can both build sequences and identify them. 116 117 Sequence builders will handle only heavy atoms. You must add the hydrogens separately. 118 At least for peptides/proteins this is a complicated (and pH-dependent) job... 119 120 How to handle the histidine case with various tautomeric forms??? 121 */ 122 123 class sequencebuilder 124 { 125 protected: 126 127 chn_info::chn_type type; 128 129 vector<sb_data_atm> main_vector; 130 vector<sb_data_atm> conn_vector; 131 132 vector<sb_data_td> td_mc_store; 133 134 vector<sb_data_res> resi_vector; 135 136 vector<typerule> head_vector; 137 vector<typerule> tail_vector; 138 139 sb_data_res * mod[3]; 140 141 char buffer[256]; 142 143 vector<i32s> id_vector; // the builder 144 atmr_vector atom_vector; // the builder 145 atmr_vector allatm_vector; // the builder 146 vector<sb_data_td> td_v; // the builder 147 148 atmr_vector tmpatm_vector; // the identifier 149 vector<atmr_vector> path_vector; // the identifier 150 151 friend class model; 152 friend class setup1_sf; 153 154 public: 155 156 sequencebuilder(chn_info::chn_type, const char *); 157 ~sequencebuilder(void); 158 159 void Build(model *, sb_chain_descriptor *, bool = true); 160 161 void Identify(model *); 162 163 private: 164 165 // the builder 166 167 void BuildResidue(sb_chain_descriptor *, model *, sb_data_res *); 168 void Convert(sb_chain_descriptor *, sb_data_atm *, fGL *); 169 170 // the identifier 171 172 void BuildTemplate(vector<sb_tdata> &, i32s, bool, bool); 173 void BuildPartialT(vector<sb_tdata> &, vector<sb_data_atm> &); 174 void FindPath(model *, atom *, atom *, i32u = 0); 175 bool CheckTemplate(vector<sb_tdata> &, i32s); 176 }; 177 178 /*################################################################################################*/ 179 180 class sb_data_td 181 { 182 protected: 183 184 i32s id[4]; 185 bool flag; 186 187 friend class sequencebuilder; 188 189 public: 190 191 sb_data_td(void); 192 ~sb_data_td(void); 193 194 friend istream & operator>>(istream &, sb_data_td &); 195 }; 196 197 /*################################################################################################*/ 198 199 class sb_data_atm 200 { 201 protected: 202 203 i32s id; 204 i32s prev[3]; 205 206 element el; 207 int f_chrg; 208 209 bondtype bt; 210 211 typerule * tr; 212 213 f64 ic1[3]; 214 i32s ic2; 215 216 friend class sequencebuilder; 217 218 public: 219 220 sb_data_atm(void); 221 sb_data_atm(const sb_data_atm &); 222 ~sb_data_atm(void); 223 224 friend istream & operator>>(istream &, sb_data_atm &); 225 }; 226 227 /*################################################################################################*/ 228 229 class sb_data_bnd 230 { 231 protected: 232 233 i32s atm[2]; 234 bondtype bt; 235 236 friend class sequencebuilder; 237 238 public: 239 240 sb_data_bnd(void); 241 ~sb_data_bnd(void); 242 243 friend istream & operator>>(istream &, sb_data_bnd &); 244 }; 245 246 /*################################################################################################*/ 247 248 class sb_data_res 249 { 250 protected: 251 252 i32s id; 253 254 char symbol1; // a single-char symbol 255 char symbol3[4]; // a three-char string symbol 256 257 char * description; 258 259 vector<sb_data_td> td_vector; 260 vector<sb_data_atm> atm_vector; 261 vector<sb_data_bnd> bnd_vector; 262 263 friend class sequencebuilder; 264 265 friend class model; // old??? 266 friend class setup1_sf; // new!!! 267 268 public: 269 270 sb_data_res(void); 271 sb_data_res(const sb_data_res &); 272 ~sb_data_res(void); 273 274 void ReadModification(istream &); 275 276 friend istream & operator>>(istream &, sb_data_res &); 277 }; 278 279 /*################################################################################################*/ 280 281 struct sb_tdata 282 { 283 element el; bondtype bt; 284 i32s id[2]; atom * ref; 285 }; 286 287 /*################################################################################################*/ 288 289 #endif // SEQBUILD_H 290 291 // eof 292