12 #include <IMP/atom/atom_config.h>
16 #include "internal/pdb.h"
23 #include <IMP/internal/utility.h>
24 #include <boost/format.hpp>
26 IMPATOM_BEGIN_NAMESPACE
44 virtual bool get_is_selected(
const std::string& pdb_line)
const=0;
54 return (internal::atom_alt_loc_indicator(pdb_line) ==
' '
55 || internal::atom_alt_loc_indicator(pdb_line)
63 return NonAlternativePDBSelector::get_is_selected(pdb_line)
64 && internal::is_ATOM_rec(pdb_line),out <<
"");
72 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
75 const std::string type = internal::atom_type(pdb_line);
76 return (type[1] ==
'C' && type[2] ==
'A'
77 && type[3] ==
' '),out <<
"");
84 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)){
87 const std::string type = internal::atom_type(pdb_line);
88 return (type[1] ==
'C' && type[2] ==
'B'
89 && type[3] ==
' '),out <<
"");
96 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
99 const std::string type = internal::atom_type(pdb_line);
100 return (type[1] ==
'C' && type[2] ==
' ' && type[3] ==
' '),
109 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
112 const std::string type = internal::atom_type(pdb_line);
113 return (type[1] ==
'N' && type[2] ==
' ' && type[3] ==
' '),
122 return true || pdb_line.empty(),
130 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
133 for(
int i=0; i < (int)chains_.length(); i++) {
134 if(internal::atom_chain_id(pdb_line) == chains_[i])
142 std::string name=
"ChainPDBSelector%1%"):
152 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
155 const std::string res_name
156 = internal::atom_residue_name(pdb_line);
157 return ((res_name[0]==
'H' && res_name[1] ==
'O'
158 && res_name[2]==
'H') ||
159 (res_name[0]==
'D' && res_name[1] ==
'O'
160 && res_name[2]==
'D')),
167 bool is_hydrogen(std::string pdb_line)
const;
170 return is_hydrogen(pdb_line);,
176 IMP::OwnerPointer<PDBSelector> ws_, hs_;
179 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
182 return (! ws_->get_is_selected(pdb_line)
183 && ! hs_->get_is_selected(pdb_line));
190 NonWaterNonHydrogenPDBSelector():
191 NonAlternativePDBSelector(
"NonWaterPDBSelector%1%"),
192 ws_(new WaterPDBSelector()),
193 hs_(new HydrogenPDBSelector()){}
198 IMP::OwnerPointer<PDBSelector> ws_;
201 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
204 return( ! ws_->get_is_selected(pdb_line));
209 NonWaterPDBSelector(): NonAlternativePDBSelector(
"NonWaterPDBSelector%1%"),
210 ws_(new WaterPDBSelector()){}
218 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
221 const std::string type = internal::atom_type(pdb_line);
222 return (type[1] ==
'P' && type[2] ==
' '),
234 const IMP::OwnerPointer<PDBSelector> a_, b_;
237 return a_->get_is_selected(pdb_line)
238 && b_->get_is_selected(pdb_line);
252 const IMP::OwnerPointer<PDBSelector> a_, b_;
255 return a_->get_is_selected(pdb_line)
256 || b_->get_is_selected(pdb_line);
270 const IMP::OwnerPointer<PDBSelector> a_;
273 return !a_->get_is_selected(pdb_line);
306 IMPATOMEXPORT Hierarchy
read_pdb(base::TextInput input,
324 IMPATOMEXPORT
void read_pdb(base::TextInput input,
331 IMPATOMEXPORT Hierarchy
334 PDBSelector* selector,
335 bool select_first_model =
true
337 ,
bool no_radii=
false
347 PDBSelector* selector
377 IMPATOMEXPORT
void write_pdb(
const Selection& mhd,
378 base::TextOutput out,
379 unsigned int model=0);
389 base::TextOutput out,
390 unsigned int model=0);
395 base::TextOutput out);
409 ResidueType rt = atom::ALA,
412 char res_icode =
' ',
413 double occpancy = 1.00,
414 double tempFactor = 0.00,
424 IMPATOMEXPORT std::string get_pdb_conect_record_string(
int,
int);
435 IMP_MODEL_SAVE(WritePDB, (
const atom::Hierarchies& mh, std::string file_name),
436 atom::Hierarchies mh_;,
440 base::TextOutput to(file_name, append);
441 IMP_LOG_TERSE(
"Writing pdb file " << file_name << std::endl);
446 IMPATOM_END_NAMESPACE