IMP logo
IMP Reference Guide  develop.e004443c3b,2024/04/25
The Integrative Modeling Platform
pdb.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/pdb.h
3  * \brief Functions to read PDBs
4  *
5  * Copyright 2007-2023 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_PDB_H
10 #define IMPATOM_PDB_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include "Hierarchy.h"
14 #include "Atom.h"
15 #include "element.h"
16 #include "internal/pdb.h"
17 #include "atom_macros.h"
18 #include <IMP/file.h>
19 #include "Selection.h"
20 #include <IMP/Model.h>
21 #include <IMP/Particle.h>
22 #include <IMP/OptimizerState.h>
23 #include <IMP/internal/utility.h>
24 #include <IMP/internal/pdb.h>
25 #include <boost/format.hpp>
26 #include <boost/algorithm/string.hpp>
27 #include <cereal/access.hpp>
28 #include <cereal/types/base_class.hpp>
29 #include <cereal/types/polymorphic.hpp>
30 
31 IMPATOM_BEGIN_NAMESPACE
32 
33 //! Represent a single ATOM/HETATM "line" in PDB or mmCIF format
34 class IMPATOMEXPORT PDBRecord : public Value {
35  const std::string *line_;
36  internal::CifKeyword *group_, *element_, *atom_name_, *alt_loc_id_,
37  *residue_name_, *auth_chain_, *chain_, *auth_seq_id_;
38  bool use_line_, use_keywords_;
39 public:
40  PDBRecord() : use_line_(false), use_keywords_(false) {}
41 
42 #ifndef SWIG
43  //! Point the record to a line of text from a PDB file
44  /** This uses a pointer to `line` so should not be used after line is freed */
45  void set_line(const std::string &line);
46 
47  //! Point the record to a single atom_site loop row from an mmCIF file
48  /** This uses pointers to the CIF keywords, so should not be used after
49  the keywords are freed. */
50  void set_keywords(internal::CifKeyword &group,
51  internal::CifKeyword &element,
52  internal::CifKeyword &atom_name,
53  internal::CifKeyword &alt_loc_id,
54  internal::CifKeyword &residue_name,
55  internal::CifKeyword &auth_chain,
56  internal::CifKeyword &chain,
57  internal::CifKeyword &auth_seq_id);
58 #endif
59 
60  //! Returns the alternative location indicator
61  /** This is a single character in PDB, but can be longer in mmCIF. */
62  std::string get_alt_loc_indicator() const;
63 
64  //! Returns true if the record is an ATOM record
65  bool get_is_atom() const;
66 
67  //! Returns the atom type as a string with no leading or trailing whitespace
68  std::string get_trimmed_atom_name() const;
69 
70  //! Returns the atom type in a PDB-style padded string
71  /** The atom type is at least a 4 character long field.
72  The first character is space in many cases, but not always. */
73  std::string get_padded_atom_name() const;
74 
75  //! Returns the residue type
76  std::string get_residue_name() const;
77 
78  //! Returns the chain ID
79  /** This is a single character in PDB format, but can be longer in mmCIF.
80  In mmCIF, the author-provided chain ID is provided if available;
81  otherwise, the mmCIF asym_id is returned. */
82  std::string get_chain_id() const;
83 
84  //! Returns the element as a string
85  std::string get_element() const;
86 
87  IMP_SHOWABLE_INLINE(PDBRecord, { out << "PDBRecord"; });
88 };
90 
91 
92 //! Select which atoms to read from a PDB file
93 /** Selector is a general purpose class used to select records from a PDB
94  file. Using descendants of this class one may implement arbitrary
95  selection functions and pass them to PDB reading functions
96  for object selection. Simple selectors can be used to build more complicated
97  ones. Inheritance means "AND" unless otherwise noted (that is, the
98  CAlphaPDBSelector takes all non-alternate C-alphas since it inherits from
99  NonAlternativePDBSelector).
100 
101  \see read_pdb, read_mmcif
102 */
103 class IMPATOMEXPORT PDBSelector : public IMP::Object {
104  public:
105  PDBSelector(std::string name) : Object(name) {}
106  //! Return true if the line should be processed
107  virtual bool get_is_selected(const PDBRecord &record) const = 0;
108 
109  virtual ~PDBSelector();
110 };
111 
113 
114 //! Select all ATOM and HETATM records which are not alternatives
116  public:
117  NonAlternativePDBSelector(std::string name = "NonAlternativePDBSelector%1%")
118  : PDBSelector(name) {}
119 
120  bool get_is_selected(const PDBRecord &record) const override {
121  std::string alt_loc = record.get_alt_loc_indicator();
122  return (alt_loc == " " || alt_loc == "" || alt_loc == "A");
123  }
125 };
126 
127 //! Select all non-alternative ATOM records
129  public:
130  ATOMPDBSelector(std::string name = "ATOMPDBSelector%1%")
131  : NonAlternativePDBSelector(name) {}
132 
133  bool get_is_selected(const PDBRecord &record) const override
134  {
135  return (NonAlternativePDBSelector::get_is_selected(record) &&
136  record.get_is_atom());
137  }
139 };
140 
141 //! Select all CA ATOM records
143  public:
144  CAlphaPDBSelector(std::string name = "CAlphaPDBSelector%1%")
145  : NonAlternativePDBSelector(name) {}
146 
147  bool get_is_selected(const PDBRecord &record) const override {
148  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
149  const std::string type = record.get_padded_atom_name();
150  return (type[1] == 'C' && type[2] == 'A' && type[3] == ' ');
151  }
153 };
154 
155 //! Select all CB ATOM records
157  public:
158  CBetaPDBSelector(std::string name = "CBetaPDBSelector%1%")
159  : NonAlternativePDBSelector(name) {}
160 
161  bool get_is_selected(const PDBRecord &record) const override {
162  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
163  const std::string type = record.get_padded_atom_name();
164  return (type[1] == 'C' && type[2] == 'B' && type[3] == ' ');
165  }
167 };
168 
169 //! Select all atoms of the given types
170 /** Note that unlike CAlphaPDBSelector and similar classes, this selects all
171  atoms, even those in alternative locations (combine with
172  a NonAlternativePDBSelector if necessary).
173  */
175  Strings atom_types_;
176  public:
177  AtomTypePDBSelector(Strings atom_types,
178  std::string name = "AtomTypePDBSelector%1%")
179  : PDBSelector(name), atom_types_(atom_types) {
180  std::sort(atom_types_.begin(), atom_types_.end());
181  }
182 
183  bool get_is_selected(const PDBRecord &record) const override {
184  std::string type = record.get_trimmed_atom_name();
185  return std::binary_search(atom_types_.begin(), atom_types_.end(), type);
186  }
188 };
189 
190 //! Select all atoms in residues of the given types
191 /** Note that unlike CAlphaPDBSelector and similar classes, this selects all
192  atoms, even those in alternative locations (combine with
193  a NonAlternativePDBSelector if necessary).
194  */
196  Strings residue_types_;
197  public:
198  ResidueTypePDBSelector(Strings residue_types,
199  std::string name = "ResidueTypePDBSelector%1%")
200  : PDBSelector(name), residue_types_(residue_types) {
201  std::sort(residue_types_.begin(), residue_types_.end());
202  }
203 
204  bool get_is_selected(const PDBRecord &record) const override {
205  std::string type = record.get_residue_name();
206  return std::binary_search(residue_types_.begin(), residue_types_.end(),
207  type);
208  }
210 };
211 
212 //! Select all C (not CA or CB) ATOM records
214  public:
215  CPDBSelector(std::string name = "CPDBSelector%1%")
216  : NonAlternativePDBSelector(name) {}
217 
218  bool get_is_selected(const PDBRecord &record) const override {
219  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
220  const std::string type = record.get_padded_atom_name();
221  return (type[1] == 'C' && type[2] == ' ' && type[3] == ' ');
222  }
224 };
225 
226 //! Select all N ATOM records
228  public:
229  NPDBSelector(std::string name = "NPDBSelector%1%")
230  : NonAlternativePDBSelector(name) {}
231 
232  bool get_is_selected(const PDBRecord &record) const override {
233  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
234  const std::string type = record.get_padded_atom_name();
235  return (type[1] == 'N' && type[2] == ' ' && type[3] == ' ');
236  }
238 };
239 
240 //! Defines a selector that will pick every ATOM and HETATM record
241 class AllPDBSelector : public PDBSelector {
242  public:
243  AllPDBSelector(std::string name = "AllPDBSelector%1%") : PDBSelector(name) {}
244 
245  bool get_is_selected(const PDBRecord &) const override {
246  return true;
247  }
249 };
250 
251 //! Select all ATOM and HETATM records with the given chain ids
252 /** When reading mmCIF format, this will use the author-provided chain
253  ID, if available; otherwise the mmCIF "chain" ID, label_asym_id,
254  will be used.
255  */
257  public:
258  bool get_is_selected(const PDBRecord &record) const override {
259  if (!NonAlternativePDBSelector::get_is_selected(record)) {
260  return false;
261  }
262  std::string cid = record.get_chain_id();
263  return std::binary_search(chains_.begin(), chains_.end(), cid);
264  }
266 
267  //! Allow any of the named chains
268  /** Chain IDs here, and in mmCIF files, can be any length,
269  although chains in legacy PDB files are restricted to
270  a single character.
271  */
273  std::string name = "ChainPDBSelector%1%")
274  : NonAlternativePDBSelector(name), chains_(chains) {
275  std::sort(chains_.begin(), chains_.end());
276  }
277 
278  private:
279  Strings chains_;
280 };
281 
282 //! Select all non-water ATOM and HETATM records
284  public:
285  WaterPDBSelector(std::string name = "WaterPDBSelector%1%")
286  : NonAlternativePDBSelector(name) {}
287 
288  bool get_is_selected(const PDBRecord &record) const override {
289  if (!NonAlternativePDBSelector::get_is_selected(record)) {
290  return false;
291  }
292  std::string res_name = record.get_residue_name();
293  return (res_name == "HOH" || res_name == "DOD");
294  }
296 };
297 
298 //! Select all hydrogen ATOM and HETATM records
299 class IMPATOMEXPORT HydrogenPDBSelector : public NonAlternativePDBSelector {
300  bool is_hydrogen(const PDBRecord &record) const;
301 
302  public:
303  HydrogenPDBSelector(std::string name = "HydrogenPDBSelector%1%")
304  : NonAlternativePDBSelector(name) {}
305 
306  bool get_is_selected(const PDBRecord &record) const override {
307  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
308  return is_hydrogen(record);
309  }
311 };
312 
313 //! Select non water and non hydrogen atoms
316 
317  public:
318  bool get_is_selected(const PDBRecord &record) const override {
319  if (!NonAlternativePDBSelector::get_is_selected(record)) {
320  return false;
321  }
322  return (!ws_->get_is_selected(record) && !hs_->get_is_selected(record));
323  }
325  NonWaterNonHydrogenPDBSelector(std::string name)
327  ws_(new WaterPDBSelector()),
328  hs_(new HydrogenPDBSelector()) {}
330  : NonAlternativePDBSelector("NonWaterPDBSelector%1%"),
331  ws_(new WaterPDBSelector()),
332  hs_(new HydrogenPDBSelector()) {}
333 };
334 
335 //! Select non hydrogen atoms
338 
339  public:
340  bool get_is_selected(const PDBRecord &record) const override {
341  if (!NonAlternativePDBSelector::get_is_selected(record)) {
342  return false;
343  }
344  return (!hs_->get_is_selected(record));
345  }
347  NonHydrogenPDBSelector(std::string name)
349  hs_(new HydrogenPDBSelector()) {}
351  : NonAlternativePDBSelector("NonHydrogenPDBSelector%1%"),
352  hs_(new HydrogenPDBSelector()) {}
353 };
354 
355 //! Select all non-water non-alternative ATOM and HETATM records
358 
359  public:
360  bool get_is_selected(const PDBRecord &record) const override {
361  if (!NonAlternativePDBSelector::get_is_selected(record)) {
362  return false;
363  }
364  return (!ws_->get_is_selected(record));
365  }
367  NonWaterPDBSelector(std::string name)
368  : NonAlternativePDBSelector(name), ws_(new WaterPDBSelector()) {}
370  : NonAlternativePDBSelector("NonWaterPDBSelector%1%"),
371  ws_(new WaterPDBSelector()) {}
372 };
373 
374 //! Select all backbone (N,CA,C,O) ATOM records
376  public:
377  BackbonePDBSelector(std::string name = "BackbonePDBSelector%1%")
379 
380  bool get_is_selected(const PDBRecord &record) const override {
381  if (!NonWaterNonHydrogenPDBSelector::get_is_selected(record))
382  return false;
383  const std::string type = record.get_padded_atom_name();
384  return ((type[1] == 'N' && type[2] == ' ' && type[3] == ' ') ||
385  (type[1] == 'C' && type[2] == 'A' && type[3] == ' ') ||
386  (type[1] == 'C' && type[2] == ' ' && type[3] == ' ') ||
387  (type[1] == 'O' && type[2] == ' ' && type[3] == ' '));
388  }
390 };
391 
392 //! Select all P (= phosphate) ATOM records
394  public:
395  PPDBSelector(std::string name = "PPDBSelector%1%")
396  : NonAlternativePDBSelector(name) {}
397 
398  bool get_is_selected(const PDBRecord &record) const override {
399  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
400  const std::string type = record.get_padded_atom_name();
401  return (type[1] == 'P' && type[2] == ' ' && type[3] == ' ');
402  }
404 };
405 
406 //! Select atoms which are selected by both selectors
407 /** To use do something like
408  \code
409  read_pdb(name, m, AndPDBSelector(PPDBSelector(), WaterPDBSelector()));
410  \endcode
411 
412  In Python, the and operator (&) can be used to the same effect:
413  \code
414  read_pdb(name, m, PPDBSelector() & WaterPDBSelector());
415  \endcode
416  */
417 class AndPDBSelector : public PDBSelector {
418  const IMP::PointerMember<PDBSelector> a_, b_;
419 
420  public:
421  bool get_is_selected(const PDBRecord &record) const override {
422  return a_->get_is_selected(record) && b_->get_is_selected(record);
423  }
426  : PDBSelector("AndPDBSelector%1%"), a_(a), b_(b) {}
427 };
428 
429 //! Select atoms which are selected by either or both selectors
430 /** To use do something like
431  \code
432  read_pdb(name, m, OrPDBSelector(PPDBSelector(), WaterPDBSelector()));
433  \endcode
434 
435  In Python, the or operator (|) can be used to the same effect:
436  \code
437  read_pdb(name, m, PPDBSelector() | WaterPDBSelector());
438  \endcode
439  */
440 class OrPDBSelector : public PDBSelector {
441  const IMP::PointerMember<PDBSelector> a_, b_;
442 
443  public:
444  bool get_is_selected(const PDBRecord &record) const override {
445  return a_->get_is_selected(record) || b_->get_is_selected(record);
446  }
449  : PDBSelector("OrPDBSelector%1%"), a_(a), b_(b) {}
450 };
451 
452 //! Select atoms which are selected by either selector but not both
453 /** To use do something like
454  \code
455  read_pdb(name, m, XorPDBSelector(HydrogenPDBSelector(),
456  WaterPDBSelector()));
457  \endcode
458 
459  In Python, the xor operator (^) can be used to the same effect:
460  \code
461  read_pdb(name, m, HydrogenPDBSelector() ^ WaterPDBSelector());
462  \endcode
463  */
464 class XorPDBSelector : public PDBSelector {
465  const IMP::PointerMember<PDBSelector> a_, b_;
466 
467  public:
468  bool get_is_selected(const PDBRecord &record) const override {
469  return a_->get_is_selected(record) != b_->get_is_selected(record);
470  }
473  : PDBSelector("XorPDBSelector%1%"), a_(a), b_(b) {}
474 };
475 
476 //! Select atoms which are not selected by a given selector
477 /** To use do something like
478  \code
479  read_pdb(name, m, NotPDBSelector(PPDBSelector()));
480  \endcode
481 
482  In Python, the inversion operator (~) can be used to the same effect:
483  \code
484  read_pdb(name, m, ~PPDBSelector());
485  \endcode
486  */
487 class NotPDBSelector : public PDBSelector {
489 
490  public:
491  bool get_is_selected(const PDBRecord &record) const override {
492  return !a_->get_is_selected(record);
493  }
495  NotPDBSelector(PDBSelector *a) : PDBSelector("NotPDBSelector%1%"), a_(a) {}
496 };
497 
498 /** @name PDB Reading
499  \anchor pdb_in
500  The read PDB methods produce a hierarchy that looks as follows:
501  - One Atom per ATOM or HETATM record in the PDB.
502  - All Atom particles have a parent which is a Residue.
503  - All Residue particles have a parent which is a Chain.
504 
505  Waters are currently dropped if they are ATOM records. This can be fixed.
506 
507  The read_pdb() functions should successfully parse all valid PDB files. It
508  can produce warnings on files which are not valid. It will attempt to read
509  such files, but all bets are off.
510 
511  In order to track the provenance of IMP-generated models, the provenance
512  of any PDB files read in here - for example, the PDB id, or detail about
513  a comparative model - needs to also be tracked. This is done using the
514  PDB headers:
515  - Structures stored in the PDB database should keep the standard
516  `HEADER` record stating their PDB ID.
517  - Comparative models generated using MODELLER should include the
518  MODELLER-generated `EXPDTA` and `REMARK` records.
519  - Structures that are trivial modifications of an existing PDB structure
520  or comparative model should use the `TITLE` record to describe the
521  nature of the modification (e.g. rotation and translation) and one of
522  the two following custom `EXPDTA` record formats to point to the original
523  structure:
524  - `EXPDTA DERIVED FROM PDB:1XYZ`
525  - `EXPDTA DERIVED FROM COMPARATIVE MODEL, DOI:x.y/z`
526  - Structures generated from multiple sources (e.g. two structures that
527  have been docked and then concatenated into a single PDB file) are not
528  allowed. Store each constituent structure in its own file and annotate
529  each one with a suitable `EXPDTA` record, as above.
530  Note that while provenance of PDB files is not currently enforced, it
531  likely will be in future IMP releases.
532 
533  When reading PDBs, PDBSelector objects can be used to choose to only process
534  certain record types. See the class documentation for more information.
535  When no PDB selector is supplied for reading, the
536  NonWaterPDBSelector is used.
537 
538  Set the IMP::LogLevel to VERBOSE to see details of parse errors.
539 */
540 //!@{
541 
542 inline PDBSelector *get_default_pdb_selector() {
543  return new NonWaterPDBSelector();
544 }
545 
546 //! Read all the molecules in the first model of the PDB file.
547 /** \param[in] input The file or stream to read the model from.
548  \param[in] model The IMP::Model object to read into.
549  \param[in] selector A PDBSelector object used to read only
550  part of the model (e.g. only a single chain).
551  \param[in] select_first_model When reading a multi-model file (with
552  multiple MODEL/ENDMDL records) read only the first model if
553  set true. If set false, combine all models into a single
554  hierarchy (see read_multimodel_pdb to read each model into
555  a separate hierarchy).
556  \return a molecular hierarchy corresponding to the PDB model
557  */
558 IMPATOMEXPORT Hierarchy
559  read_pdb(TextInput input, Model *model,
560  PDBSelector *selector = get_default_pdb_selector(),
561  bool select_first_model = true
562 #ifndef IMP_DOXYGEN
563  ,
564  bool no_radii = false
565 #endif
566  );
567 
568 /** Rewrite the coordinates of the passed hierarchy based
569  on the contents of the first model in the PDB file.
570 
571  The hierarchy must have been created by reading from a PDB
572  file and the atom numbers must correspond between the files.
573  These are not really checked.
574 
575  A ValueException is thrown if there are insufficient models
576  in the file.
577 
578  core::RigidMember particles are handled by updating the
579  core::RigidBody algebra::ReferenceFrame3D to align with the
580  loaded particles. Bad things will happen if the loaded coordinates
581  are not a rigid transform of the prior coordinates.
582  */
583 IMPATOMEXPORT void read_pdb(TextInput input, int model, Hierarchy h);
584 
585 /** Read all models from the PDB file.
586  */
587 IMPATOMEXPORT Hierarchies
588  read_multimodel_pdb(TextInput input, Model *model,
589  PDBSelector *selector = get_default_pdb_selector()
590 #ifndef IMP_DOXYGEN
591  ,
592  bool noradii = false
593 #endif
594  );
595 
596 /** @name PDB Writing
597  \anchor pdb_out
598  The methods to write a PDB expects a Hierarchy that looks as follows:
599  - all leaves are Atom particles
600  - all Atom particles have Residue particles as parents
601 
602  All Residue particles that have a Chain particle as an ancestor
603  are considered part of a protein, DNA or RNA, ones without are
604  considered heterogens.
605 
606  The functions produce files that are not valid PDB files,
607  eg only ATOM/HETATM lines are printed for all Atom particles
608  in the hierarchy. Complain if your favorite program can't read them and
609  we might fix it.
610 */
611 //!@{
612 
613 /** Write some atoms to a PDB.
614 */
615 IMPATOMEXPORT void write_pdb(const Selection &mhd, TextOutput out,
616  unsigned int model = 1);
617 
618 /** \brief Write a hierarchy to a PDB as C_alpha atoms.
619 
620  This method is used to write a non-atomic hierarchy into a PDB in a way
621  that can be read by most programs. If the leaves are Residue particles
622  then the index and residue type will be read from them. Otherwise default
623  values will be used so that each leaf ends up in a separate residue.
624 */
625 IMPATOMEXPORT void write_pdb_of_c_alphas(const Selection &mhd,
626  TextOutput out,
627  unsigned int model = 1);
628 
629 /** Write the hierarchies one per frame.
630 */
631 IMPATOMEXPORT void write_multimodel_pdb(const Hierarchies &mhd,
632  TextOutput out);
633 /** @} */
634 
635 #ifndef IMP_DOXYGEN
636 
637 /**
638  This function returns a string in PDB ATOM format
639 */
640 IMPATOMEXPORT std::string get_pdb_string(
641  const algebra::Vector3D &v, int index = -1, AtomType at = AT_CA,
642  ResidueType rt = atom::ALA, char chain = ' ', int res_index = 1,
643  char res_icode = ' ', double occupancy = 1.00, double tempFactor = 0.00,
644  Element e = C);
645 
646 /**
647  This function returns a connectivity string in PDB format
648  \note The CONECT records specify connectivity between atoms for which
649  coordinates are supplied. The connectivity is described using
650  the atom serial number as found in the entry.
651  \note http://www.bmsc.washington.edu/CrystaLinks/man/pdb/guide2.2_frame.html
652 */
653 IMPATOMEXPORT std::string get_pdb_conect_record_string(int, int);
654 #endif
655 
656 /** \class WritePDBOptimizerState
657  This writes a PDB file at the specified interval during optimization.
658  If the file name contains %1% then a new file is written each time
659  with the %1% replaced by the index. Otherwise a new model is written
660  each time to the same file.
661 */
662 class IMPATOMEXPORT WritePDBOptimizerState : public OptimizerState {
663  std::string filename_;
664  ParticleIndexes pis_;
665 
666  friend class cereal::access;
667 
668  template<class Archive> void serialize(Archive &ar) {
669  ar(cereal::base_class<OptimizerState>(this), filename_, pis_);
670  }
672 
673  public:
675  const ParticleIndexesAdaptor &pis,
676  std::string filename);
677  WritePDBOptimizerState(const atom::Hierarchies mh, std::string filename);
679 
680  protected:
681  virtual void do_update(unsigned int call) override;
682  virtual ModelObjectsTemp do_get_inputs() const override;
684 };
685 
686 IMPATOM_END_NAMESPACE
687 
688 #endif /* IMPATOM_PDB_H */
ChainPDBSelector(Strings chains, std::string name="ChainPDBSelector%1%")
Allow any of the named chains.
Definition: pdb.h:272
Select non water and non hydrogen atoms.
Definition: pdb.h:314
std::string get_chain_id() const
Returns the chain ID.
Define the elements used in IMP.
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
Select all backbone (N,CA,C,O) ATOM records.
Definition: pdb.h:375
Represent a single ATOM/HETATM "line" in PDB or mmCIF format.
Definition: pdb.h:34
Select all non-water ATOM and HETATM records.
Definition: pdb.h:283
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:398
Select all P (= phosphate) ATOM records.
Definition: pdb.h:393
Select non hydrogen atoms.
Definition: pdb.h:336
const AtomType AT_CA
Select atoms which are selected by both selectors.
Definition: pdb.h:417
std::string get_trimmed_atom_name() const
Returns the atom type as a string with no leading or trailing whitespace.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Simple atom decorator.
Storage of a model, its restraints, constraints and particles.
Select all N ATOM records.
Definition: pdb.h:227
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
Handling of file input/output.
virtual void do_update(unsigned int)
bool get_is_selected(const PDBRecord &) const override
Return true if the line should be processed.
Definition: pdb.h:245
std::string get_alt_loc_indicator() const
Returns the alternative location indicator.
Select all atoms in residues of the given types.
Definition: pdb.h:195
void read_pdb(TextInput input, int model, Hierarchy h)
A more IMP-like version of the std::vector.
Definition: Vector.h:50
Take Decorator, Particle or ParticleIndex.
Select all C (not CA or CB) ATOM records.
Definition: pdb.h:213
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:380
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
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.
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:491
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:306
Decorator for helping deal with a hierarchy of molecules.
Base class for a simple primitive-like type.
Definition: Value.h:23
Select all CB ATOM records.
Definition: pdb.h:156
Select all ATOM and HETATM records which are not alternatives.
Definition: pdb.h:115
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.
Definition: value_macros.h:23
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:204
Select all non-alternative ATOM records.
Definition: pdb.h:128
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:421
Common base class for heavy weight IMP objects.
Definition: Object.h:111
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:161
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:288
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:120
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:468
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
A smart pointer to a ref-counted Object that is a class member.
Definition: Pointer.h:143
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:232
bool get_is_atom() const
Returns true if the record is an ATOM record.
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:360
Select all atoms of the given types.
Definition: pdb.h:174
virtual ModelObjectsTemp do_get_inputs() const override
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:444
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:318
#define IMP_OBJECTS(Name, PluralName)
Define the types for storing lists of object pointers.
Definition: object_macros.h:44
Defines a selector that will pick every ATOM and HETATM record.
Definition: pdb.h:241
Macros for maintaining molecular hierarchies.
Select atoms which are not selected by a given selector.
Definition: pdb.h:487
Hierarchies read_multimodel_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector())
std::string get_padded_atom_name() const
Returns the atom type in a PDB-style padded string.
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:218
Object(std::string name)
Construct an object with the given name.
VectorD< 3 > Vector3D
Definition: VectorD.h:408
Shared optimizer state that is invoked upon commitment of new coordinates.
Select all non-water non-alternative ATOM and HETATM records.
Definition: pdb.h:356
Select atoms which are selected by either or both selectors.
Definition: pdb.h:440
Shared optimizer state.
void write_multimodel_pdb(const Hierarchies &mhd, TextOutput out)
Select all hydrogen ATOM and HETATM records.
Definition: pdb.h:299
Select all CA ATOM records.
Definition: pdb.h:142
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:183
std::string get_chain_id(Hierarchy h)
Walk up the hierarchy to determine the chain id.
Element
The various elements currently supported/known.
Definition: element.h:23
Select which atoms to read from a PDB file.
Definition: pdb.h:103
std::string get_residue_name() const
Returns the residue type.
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:258
Select a subset of a hierarchy.
Select atoms which are selected by either selector but not both.
Definition: pdb.h:464
Select all ATOM and HETATM records with the given chain ids.
Definition: pdb.h:256
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:147
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:340
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:133