12 #include <IMP/atom/atom_config.h>
16 #include "internal/pdb.h"
23 #include <IMP/internal/utility.h>
24 #include <boost/format.hpp>
25 #include <boost/algorithm/string.hpp>
26 #include <cereal/access.hpp>
27 #include <cereal/types/base_class.hpp>
28 #include <cereal/types/polymorphic.hpp>
30 IMPATOM_BEGIN_NAMESPACE
47 virtual bool get_is_selected(
const std::string &pdb_line)
const = 0;
60 return (internal::atom_alt_loc_indicator(pdb_line) ==
' ' ||
61 internal::atom_alt_loc_indicator(pdb_line) ==
'A');
73 return (NonAlternativePDBSelector::get_is_selected(pdb_line) &&
74 internal::is_ATOM_rec(pdb_line));
86 if (!NonAlternativePDBSelector::get_is_selected(pdb_line))
return false;
87 const std::string type = internal::atom_type(pdb_line);
88 return (type[1] ==
'C' && type[2] ==
'A' && type[3] ==
' ');
100 if (!NonAlternativePDBSelector::get_is_selected(pdb_line))
return false;
101 const std::string type = internal::atom_type(pdb_line);
102 return (type[1] ==
'C' && type[2] ==
'B' && type[3] ==
' ');
116 std::string name =
"AtomTypePDBSelector%1%")
118 std::sort(atom_types_.begin(), atom_types_.end());
122 std::string type = internal::atom_type(pdb_line);
124 return std::binary_search(atom_types_.begin(), atom_types_.end(), type);
138 std::string name =
"ResidueTypePDBSelector%1%")
139 :
PDBSelector(name), residue_types_(residue_types) {
140 std::sort(residue_types_.begin(), residue_types_.end());
144 std::string type = internal::atom_residue_name(pdb_line);
146 return std::binary_search(residue_types_.begin(), residue_types_.end(),
159 if (!NonAlternativePDBSelector::get_is_selected(pdb_line))
return false;
160 const std::string type = internal::atom_type(pdb_line);
161 return (type[1] ==
'C' && type[2] ==
' ' && type[3] ==
' ');
173 if (!NonAlternativePDBSelector::get_is_selected(pdb_line))
return false;
174 const std::string type = internal::atom_type(pdb_line);
175 return (type[1] ==
'N' && type[2] ==
' ' && type[3] ==
' ');
186 return (
true || pdb_line.empty());
195 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
198 for (
int i = 0; i < (int)chains_.length(); i++) {
199 if (internal::atom_chain_id(pdb_line) == chains_[i])
return true;
208 std::string name =
"ChainPDBSelector%1%")
222 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
225 const std::string res_name = internal::atom_residue_name(pdb_line);
226 return ((res_name[0] ==
'H' && res_name[1] ==
'O' && res_name[2] ==
'H') ||
227 (res_name[0] ==
'D' && res_name[1] ==
'O' && res_name[2] ==
'D'));
234 bool is_hydrogen(std::string pdb_line)
const;
241 if (!NonAlternativePDBSelector::get_is_selected(pdb_line))
return false;
242 return is_hydrogen(pdb_line);
253 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
256 return (!ws_->get_is_selected(pdb_line) && !hs_->get_is_selected(pdb_line));
275 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
278 return (!hs_->get_is_selected(pdb_line));
295 if (!NonAlternativePDBSelector::get_is_selected(pdb_line)) {
298 return (!ws_->get_is_selected(pdb_line));
315 if (!NonWaterNonHydrogenPDBSelector::get_is_selected(pdb_line))
317 const std::string type = internal::atom_type(pdb_line);
318 return ((type[1] ==
'N' && type[2] ==
' ' && type[3] ==
' ') ||
319 (type[1] ==
'C' && type[2] ==
'A' && type[3] ==
' ') ||
320 (type[1] ==
'C' && type[2] ==
' ' && type[3] ==
' ') ||
321 (type[1] ==
'O' && type[2] ==
' ' && type[3] ==
' '));
333 if (!NonAlternativePDBSelector::get_is_selected(pdb_line))
return false;
334 const std::string type = internal::atom_type(pdb_line);
335 return (type[1] ==
'P' && type[2] ==
' ' && type[3] ==
' ');
356 return a_->get_is_selected(pdb_line) && b_->get_is_selected(pdb_line);
360 :
PDBSelector(
"AndPDBSelector%1%"), a_(a), b_(b) {}
379 return a_->get_is_selected(pdb_line) || b_->get_is_selected(pdb_line);
403 return a_->get_is_selected(pdb_line) != b_->get_is_selected(pdb_line);
407 :
PDBSelector(
"XorPDBSelector%1%"), a_(a), b_(b) {}
426 return !a_->get_is_selected(pdb_line);
476 inline PDBSelector *get_default_pdb_selector() {
477 return new NonWaterPDBSelector();
492 IMPATOMEXPORT Hierarchy
493 read_pdb(TextInput input, Model *model,
494 PDBSelector *selector = get_default_pdb_selector(),
495 bool select_first_model =
true
498 bool no_radii =
false
517 IMPATOMEXPORT
void read_pdb(TextInput input,
int model, Hierarchy h);
521 IMPATOMEXPORT Hierarchies
523 PDBSelector *selector = get_default_pdb_selector()
549 IMPATOMEXPORT
void write_pdb(
const Selection &mhd, TextOutput out,
550 unsigned int model = 1);
561 unsigned int model = 1);
574 IMPATOMEXPORT std::string get_pdb_string(
576 ResidueType rt = atom::ALA,
char chain =
' ',
int res_index = 1,
577 char res_icode =
' ',
double occupancy = 1.00,
double tempFactor = 0.00,
587 IMPATOMEXPORT std::string get_pdb_conect_record_string(
int,
int);
597 std::string filename_;
600 friend class cereal::access;
602 template<
class Archive>
void serialize(Archive &ar) {
603 ar(cereal::base_class<OptimizerState>(
this), filename_, pis_);
610 std::string filename);
615 virtual void do_update(
unsigned int call)
override;
620 IMPATOM_END_NAMESPACE
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Select non water and non hydrogen atoms.
ChainPDBSelector(const std::string &chains, std::string name="ChainPDBSelector%1%")
The chain id can be any character in chains.
Define the elements used in IMP.
Select all backbone (N,CA,C,O) ATOM records.
Select all non-water ATOM and HETATM records.
Select all P (= phosphate) ATOM records.
Select non hydrogen atoms.
Select atoms which are selected by both selectors.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Select all N ATOM records.
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
Handling of file input/output.
virtual void do_update(unsigned int)
Select all atoms in residues of the given types.
void read_pdb(TextInput input, int model, Hierarchy h)
A more IMP-like version of the std::vector.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Take Decorator, Particle or ParticleIndex.
Select all C (not CA or CB) ATOM records.
Class for storing model, its restraints, constraints, and particles.
void write_pdb_of_c_alphas(const Selection &mhd, TextOutput out, unsigned int model=1)
Write a hierarchy to a PDB as C_alpha atoms.
Decorator for helping deal with a hierarchy of molecules.
Select all CB ATOM records.
Select all ATOM and HETATM records which are not alternatives.
Select all non-alternative ATOM records.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Common base class for heavy weight IMP objects.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
A smart pointer to a ref-counted Object that is a class member.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Select all atoms of the given types.
virtual ModelObjectsTemp do_get_inputs() const override
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Defines a selector that will pick every ATOM and HETATM record.
Macros for maintaining molecular hierarchies.
Select atoms which are not selected by a given selector.
Hierarchies read_multimodel_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector())
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Object(std::string name)
Construct an object with the given name.
Shared optimizer state that is invoked upon commitment of new coordinates.
Select all non-water non-alternative ATOM and HETATM records.
Select atoms which are selected by either or both selectors.
void write_multimodel_pdb(const Hierarchies &mhd, TextOutput out)
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Select all hydrogen ATOM and HETATM records.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Select all CA ATOM records.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
Element
The various elements currently supported/known.
Select which atoms to read from a PDB file.
Select a subset of a hierarchy.
Select atoms which are selected by either selector but not both.
Select all ATOM and HETATM records with the given chain ids.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.
bool get_is_selected(const std::string &pdb_line) const override
Return true if the line should be processed.