00001
00002
00003
00004
00005
00006
00007
00008 #ifndef IMPATOM_PDB_H
00009 #define IMPATOM_PDB_H
00010
00011 #include "atom_config.h"
00012 #include "Hierarchy.h"
00013 #include "Atom.h"
00014 #include "element.h"
00015 #include "internal/pdb.h"
00016 #include <IMP/file.h>
00017 #include <IMP/Model.h>
00018 #include <IMP/Particle.h>
00019
00020 IMPATOM_BEGIN_NAMESPACE
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class IMPATOMEXPORT PDBSelector {
00037 public:
00038
00039 virtual bool operator()(const std::string& pdb_line) const=0;
00040 virtual ~PDBSelector();
00041 };
00042
00043
00044 class NonAlternativePDBSelector : public PDBSelector {
00045 public:
00046 bool operator()(const std::string& pdb_line) const {
00047 return ((internal::atom_alt_loc_indicator(pdb_line) == ' ') ||
00048 (internal::atom_alt_loc_indicator(pdb_line) == 'A'));
00049 }
00050 };
00051
00052
00053 class ATOMPDBSelector: public NonAlternativePDBSelector {
00054 public:
00055 bool operator()(const std::string& pdb_line) const {
00056 return NonAlternativePDBSelector::operator()(pdb_line)
00057 && internal::is_ATOM_rec(pdb_line);
00058 }
00059 };
00060
00061
00062
00063 class CAlphaPDBSelector : public NonAlternativePDBSelector {
00064 public:
00065 bool operator() (const std::string& pdb_line) const {
00066 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00067 const std::string type = internal::atom_type(pdb_line);
00068 return (type[1] == 'C' && type[2] == 'A' && type[3] == ' ');
00069 }
00070 };
00071
00072
00073 class CBetaPDBSelector: public NonAlternativePDBSelector {
00074 public:
00075 bool operator() (const std::string& pdb_line) const {
00076 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00077 const std::string type = internal::atom_type(pdb_line);
00078 return (type[1] == 'C' && type[2] == 'B' && type[3] == ' ');
00079 }
00080 };
00081
00082
00083 class CPDBSelector: public NonAlternativePDBSelector {
00084 public:
00085 bool operator()(const std::string& pdb_line) const {
00086 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00087 const std::string type = internal::atom_type(pdb_line);
00088 return (type[1] == 'C' && type[2] == ' ' && type[3] == ' ');
00089 }
00090 };
00091
00092
00093 class NPDBSelector: public NonAlternativePDBSelector {
00094 public:
00095 bool operator()(const std::string& pdb_line) const {
00096 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00097 const std::string type = internal::atom_type(pdb_line);
00098 return (type[1] == 'N' && type[2] == ' ' && type[3] == ' ');
00099 }
00100 };
00101
00102
00103 class AllPDBSelector : public PDBSelector {
00104 public:
00105 bool operator()(const std::string& pdb_line) const { return true; }
00106 };
00107
00108
00109 class ChainPDBSelector : public NonAlternativePDBSelector {
00110 public:
00111
00112 ChainPDBSelector(const std::string &chains): chains_(chains) {}
00113 bool operator()(const std::string& pdb_line) const {
00114 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00115 for(int i=0; i < (int)chains_.length(); i++) {
00116 if(internal::atom_chain_id(pdb_line) == chains_[i])
00117 return true;
00118 }
00119 return false;
00120 }
00121 private:
00122 std::string chains_;
00123 };
00124
00125
00126 class WaterPDBSelector : public NonAlternativePDBSelector {
00127 public:
00128 bool operator()(const std::string& pdb_line) const {
00129 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00130 const std::string res_name = internal::atom_residue_name(pdb_line);
00131 return ((res_name[0]=='H' && res_name[1] =='O' && res_name[2]=='H') ||
00132 (res_name[0]=='D' && res_name[1] =='O' && res_name[2]=='D'));
00133 }
00134 };
00135
00136
00137 class HydrogenPDBSelector : public NonAlternativePDBSelector {
00138 public:
00139 bool operator()(const std::string& pdb_line) const {
00140 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00141 std::string elem = internal::atom_element(pdb_line);
00142 boost::trim(elem);
00143
00144
00145
00146
00147
00148
00149 return ((elem.length() == 1 && elem[0]=='H') ||
00150 pdb_line[internal::atom_type_field_+1] == 'H' ||
00151 pdb_line[internal::atom_type_field_+1] == 'D');
00152 }
00153 };
00154
00155
00156 class NonWaterNonHydrogenPDBSelector : public NonAlternativePDBSelector {
00157 public:
00158 bool operator()(const std::string& pdb_line) const {
00159 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00160 WaterPDBSelector w;
00161 HydrogenPDBSelector h;
00162 return (! w(pdb_line) && ! h(pdb_line));
00163 }
00164 };
00165
00166
00167 class NonWaterPDBSelector : public NonAlternativePDBSelector {
00168 public:
00169 bool operator()(const std::string& pdb_line) const {
00170 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00171 WaterPDBSelector w;
00172 return( ! w(pdb_line));
00173 }
00174 };
00175
00176
00177 class PPDBSelector : public NonAlternativePDBSelector {
00178 public:
00179 bool operator()(const std::string& pdb_line) const {
00180 if (!NonAlternativePDBSelector::operator()(pdb_line)) return false;
00181 const std::string type = internal::atom_type(pdb_line);
00182 return (type[1] == 'P' && type[2] == ' ');
00183 }
00184 };
00185
00186 #if 0
00187
00188
00189
00190 class AndPDBSelector: public NonAlternativePDBSelector {
00191 const PDBSelector &a, &b;
00192 public:
00193 AndPDBSelector(const PDBSelector &a,
00194 const PDBSelector &b): a_(a), b_(b) {
00195 }
00196 bool operator()(const std::string& pdb_line) const {
00197 return a_(pdb_line)&& b_(pdb_line);
00198 }
00199 };
00200 #endif
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229 IMPATOMEXPORT Hierarchy read_pdb(TextInput in,
00230 Model* model);
00231
00232
00233
00234 IMPATOMEXPORT Hierarchy
00235 read_pdb(TextInput in,
00236 Model* model,
00237 const PDBSelector& selector,
00238 bool select_first_model = true);
00239
00240
00241
00242
00243
00244 IMPATOMEXPORT Hierarchies read_multimodel_pdb(TextInput in,
00245 Model *model,
00246 const PDBSelector& selector);
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 IMPATOMEXPORT void write_pdb(Hierarchy mhd,
00269 TextOutput out);
00270
00271
00272 IMPATOMEXPORT void write_pdb(const Hierarchies &mhd,
00273 TextOutput out);
00274
00275
00276
00277 IMPATOMEXPORT void write_multimodel_pdb(
00278 const Hierarchies& mhd, TextOutput out);
00279
00280
00281
00282
00283 #ifndef IMP_DOXYGEN
00284
00285
00286
00287
00288 IMPATOMEXPORT std::string pdb_string(const algebra::VectorD<3>& v,
00289 int index = -1,
00290 AtomType at = AT_C,
00291 ResidueType rt = atom::ALA,
00292 char chain = ' ',
00293 int res_index = 1,
00294 char res_icode = ' ',
00295 Element e = C);
00296
00297
00298
00299
00300
00301
00302
00303
00304 IMPATOMEXPORT std::string conect_record_string(int,int);
00305 #endif
00306
00307
00308
00309
00310
00311 IMPATOM_END_NAMESPACE
00312
00313 #endif