IMP logo
IMP Reference Guide  2.20.2
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 #ifndef IMP_DOXYGEN
279  //! The chain id can be any character in chains
280  /** \note This limits the selection to single-character chain IDs
281  (mmCIF files support multiple-character chain names) */
282  IMPATOM_DEPRECATED_METHOD_DECL(2.20)
283  ChainPDBSelector(const std::string &chains,
284  std::string name = "ChainPDBSelector%1%")
285  : NonAlternativePDBSelector(name) {
286  IMPATOM_DEPRECATED_METHOD_DEF(
287  2.20, "Pass a list of chain ID strings instead");
288  for (size_t i = 0; i < chains.length(); ++i) {
289  chains_.push_back(std::string(1, chains[i]));
290  }
291  std::sort(chains_.begin(), chains_.end());
292  }
293 #endif
294 
295  private:
296  Strings chains_;
297 };
298 
299 //! Select all non-water ATOM and HETATM records
301  public:
302  WaterPDBSelector(std::string name = "WaterPDBSelector%1%")
303  : NonAlternativePDBSelector(name) {}
304 
305  bool get_is_selected(const PDBRecord &record) const override {
306  if (!NonAlternativePDBSelector::get_is_selected(record)) {
307  return false;
308  }
309  std::string res_name = record.get_residue_name();
310  return (res_name == "HOH" || res_name == "DOD");
311  }
313 };
314 
315 //! Select all hydrogen ATOM and HETATM records
316 class IMPATOMEXPORT HydrogenPDBSelector : public NonAlternativePDBSelector {
317  bool is_hydrogen(const PDBRecord &record) const;
318 
319  public:
320  HydrogenPDBSelector(std::string name = "HydrogenPDBSelector%1%")
321  : NonAlternativePDBSelector(name) {}
322 
323  bool get_is_selected(const PDBRecord &record) const override {
324  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
325  return is_hydrogen(record);
326  }
328 };
329 
330 //! Select non water and non hydrogen atoms
333 
334  public:
335  bool get_is_selected(const PDBRecord &record) const override {
336  if (!NonAlternativePDBSelector::get_is_selected(record)) {
337  return false;
338  }
339  return (!ws_->get_is_selected(record) && !hs_->get_is_selected(record));
340  }
342  NonWaterNonHydrogenPDBSelector(std::string name)
344  ws_(new WaterPDBSelector()),
345  hs_(new HydrogenPDBSelector()) {}
347  : NonAlternativePDBSelector("NonWaterPDBSelector%1%"),
348  ws_(new WaterPDBSelector()),
349  hs_(new HydrogenPDBSelector()) {}
350 };
351 
352 //! Select non hydrogen atoms
355 
356  public:
357  bool get_is_selected(const PDBRecord &record) const override {
358  if (!NonAlternativePDBSelector::get_is_selected(record)) {
359  return false;
360  }
361  return (!hs_->get_is_selected(record));
362  }
364  NonHydrogenPDBSelector(std::string name)
366  hs_(new HydrogenPDBSelector()) {}
368  : NonAlternativePDBSelector("NonHydrogenPDBSelector%1%"),
369  hs_(new HydrogenPDBSelector()) {}
370 };
371 
372 //! Select all non-water non-alternative ATOM and HETATM records
375 
376  public:
377  bool get_is_selected(const PDBRecord &record) const override {
378  if (!NonAlternativePDBSelector::get_is_selected(record)) {
379  return false;
380  }
381  return (!ws_->get_is_selected(record));
382  }
384  NonWaterPDBSelector(std::string name)
385  : NonAlternativePDBSelector(name), ws_(new WaterPDBSelector()) {}
387  : NonAlternativePDBSelector("NonWaterPDBSelector%1%"),
388  ws_(new WaterPDBSelector()) {}
389 };
390 
391 //! Select all backbone (N,CA,C,O) ATOM records
393  public:
394  BackbonePDBSelector(std::string name = "BackbonePDBSelector%1%")
396 
397  bool get_is_selected(const PDBRecord &record) const override {
398  if (!NonWaterNonHydrogenPDBSelector::get_is_selected(record))
399  return false;
400  const std::string type = record.get_padded_atom_name();
401  return ((type[1] == 'N' && type[2] == ' ' && type[3] == ' ') ||
402  (type[1] == 'C' && type[2] == 'A' && type[3] == ' ') ||
403  (type[1] == 'C' && type[2] == ' ' && type[3] == ' ') ||
404  (type[1] == 'O' && type[2] == ' ' && type[3] == ' '));
405  }
407 };
408 
409 //! Select all P (= phosphate) ATOM records
411  public:
412  PPDBSelector(std::string name = "PPDBSelector%1%")
413  : NonAlternativePDBSelector(name) {}
414 
415  bool get_is_selected(const PDBRecord &record) const override {
416  if (!NonAlternativePDBSelector::get_is_selected(record)) return false;
417  const std::string type = record.get_padded_atom_name();
418  return (type[1] == 'P' && type[2] == ' ' && type[3] == ' ');
419  }
421 };
422 
423 //! Select atoms which are selected by both selectors
424 /** To use do something like
425  \code
426  read_pdb(name, m, AndPDBSelector(PPDBSelector(), WaterPDBSelector()));
427  \endcode
428 
429  In Python, the and operator (&) can be used to the same effect:
430  \code
431  read_pdb(name, m, PPDBSelector() & WaterPDBSelector());
432  \endcode
433  */
434 class AndPDBSelector : public PDBSelector {
435  const IMP::PointerMember<PDBSelector> a_, b_;
436 
437  public:
438  bool get_is_selected(const PDBRecord &record) const override {
439  return a_->get_is_selected(record) && b_->get_is_selected(record);
440  }
443  : PDBSelector("AndPDBSelector%1%"), a_(a), b_(b) {}
444 };
445 
446 //! Select atoms which are selected by either or both selectors
447 /** To use do something like
448  \code
449  read_pdb(name, m, OrPDBSelector(PPDBSelector(), WaterPDBSelector()));
450  \endcode
451 
452  In Python, the or operator (|) can be used to the same effect:
453  \code
454  read_pdb(name, m, PPDBSelector() | WaterPDBSelector());
455  \endcode
456  */
457 class OrPDBSelector : public PDBSelector {
458  const IMP::PointerMember<PDBSelector> a_, b_;
459 
460  public:
461  bool get_is_selected(const PDBRecord &record) const override {
462  return a_->get_is_selected(record) || b_->get_is_selected(record);
463  }
466  : PDBSelector("OrPDBSelector%1%"), a_(a), b_(b) {}
467 };
468 
469 //! Select atoms which are selected by either selector but not both
470 /** To use do something like
471  \code
472  read_pdb(name, m, XorPDBSelector(HydrogenPDBSelector(),
473  WaterPDBSelector()));
474  \endcode
475 
476  In Python, the xor operator (^) can be used to the same effect:
477  \code
478  read_pdb(name, m, HydrogenPDBSelector() ^ WaterPDBSelector());
479  \endcode
480  */
481 class XorPDBSelector : public PDBSelector {
482  const IMP::PointerMember<PDBSelector> a_, b_;
483 
484  public:
485  bool get_is_selected(const PDBRecord &record) const override {
486  return a_->get_is_selected(record) != b_->get_is_selected(record);
487  }
490  : PDBSelector("XorPDBSelector%1%"), a_(a), b_(b) {}
491 };
492 
493 //! Select atoms which are not selected by a given selector
494 /** To use do something like
495  \code
496  read_pdb(name, m, NotPDBSelector(PPDBSelector()));
497  \endcode
498 
499  In Python, the inversion operator (~) can be used to the same effect:
500  \code
501  read_pdb(name, m, ~PPDBSelector());
502  \endcode
503  */
504 class NotPDBSelector : public PDBSelector {
506 
507  public:
508  bool get_is_selected(const PDBRecord &record) const override {
509  return !a_->get_is_selected(record);
510  }
512  NotPDBSelector(PDBSelector *a) : PDBSelector("NotPDBSelector%1%"), a_(a) {}
513 };
514 
515 /** @name PDB Reading
516  \anchor pdb_in
517  The read PDB methods produce a hierarchy that looks as follows:
518  - One Atom per ATOM or HETATM record in the PDB.
519  - All Atom particles have a parent which is a Residue.
520  - All Residue particles have a parent which is a Chain.
521 
522  Waters are currently dropped if they are ATOM records. This can be fixed.
523 
524  The read_pdb() functions should successfully parse all valid PDB files. It
525  can produce warnings on files which are not valid. It will attempt to read
526  such files, but all bets are off.
527 
528  In order to track the provenance of IMP-generated models, the provenance
529  of any PDB files read in here - for example, the PDB id, or detail about
530  a comparative model - needs to also be tracked. This is done using the
531  PDB headers:
532  - Structures stored in the PDB database should keep the standard
533  `HEADER` record stating their PDB ID.
534  - Comparative models generated using MODELLER should include the
535  MODELLER-generated `EXPDTA` and `REMARK` records.
536  - Structures that are trivial modifications of an existing PDB structure
537  or comparative model should use the `TITLE` record to describe the
538  nature of the modification (e.g. rotation and translation) and one of
539  the two following custom `EXPDTA` record formats to point to the original
540  structure:
541  - `EXPDTA DERIVED FROM PDB:1XYZ`
542  - `EXPDTA DERIVED FROM COMPARATIVE MODEL, DOI:x.y/z`
543  - Structures generated from multiple sources (e.g. two structures that
544  have been docked and then concatenated into a single PDB file) are not
545  allowed. Store each constituent structure in its own file and annotate
546  each one with a suitable `EXPDTA` record, as above.
547  Note that while provenance of PDB files is not currently enforced, it
548  likely will be in future IMP releases.
549 
550  When reading PDBs, PDBSelector objects can be used to choose to only process
551  certain record types. See the class documentation for more information.
552  When no PDB selector is supplied for reading, the
553  NonWaterPDBSelector is used.
554 
555  Set the IMP::LogLevel to VERBOSE to see details of parse errors.
556 */
557 //!@{
558 
559 inline PDBSelector *get_default_pdb_selector() {
560  return new NonWaterPDBSelector();
561 }
562 
563 //! Read all the molecules in the first model of the PDB file.
564 /** \param[in] input The file or stream to read the model from.
565  \param[in] model The IMP::Model object to read into.
566  \param[in] selector A PDBSelector object used to read only
567  part of the model (e.g. only a single chain).
568  \param[in] select_first_model When reading a multi-model file (with
569  multiple MODEL/ENDMDL records) read only the first model if
570  set true. If set false, combine all models into a single
571  hierarchy (see read_multimodel_pdb to read each model into
572  a separate hierarchy).
573  \return a molecular hierarchy corresponding to the PDB model
574  */
575 IMPATOMEXPORT Hierarchy
576  read_pdb(TextInput input, Model *model,
577  PDBSelector *selector = get_default_pdb_selector(),
578  bool select_first_model = true
579 #ifndef IMP_DOXYGEN
580  ,
581  bool no_radii = false
582 #endif
583  );
584 
585 /** Rewrite the coordinates of the passed hierarchy based
586  on the contents of the first model in the PDB file.
587 
588  The hierarchy must have been created by reading from a PDB
589  file and the atom numbers must correspond between the files.
590  These are not really checked.
591 
592  A ValueException is thrown if there are insufficient models
593  in the file.
594 
595  core::RigidMember particles are handled by updating the
596  core::RigidBody algebra::ReferenceFrame3D to align with the
597  loaded particles. Bad things will happen if the loaded coordinates
598  are not a rigid transform of the prior coordinates.
599  */
600 IMPATOMEXPORT void read_pdb(TextInput input, int model, Hierarchy h);
601 
602 /** Read all models from the PDB file.
603  */
604 IMPATOMEXPORT Hierarchies
605  read_multimodel_pdb(TextInput input, Model *model,
606  PDBSelector *selector = get_default_pdb_selector()
607 #ifndef IMP_DOXYGEN
608  ,
609  bool noradii = false
610 #endif
611  );
612 
613 /** @name PDB Writing
614  \anchor pdb_out
615  The methods to write a PDB expects a Hierarchy that looks as follows:
616  - all leaves are Atom particles
617  - all Atom particles have Residue particles as parents
618 
619  All Residue particles that have a Chain particle as an ancestor
620  are considered part of a protein, DNA or RNA, ones without are
621  considered heterogens.
622 
623  The functions produce files that are not valid PDB files,
624  eg only ATOM/HETATM lines are printed for all Atom particles
625  in the hierarchy. Complain if your favorite program can't read them and
626  we might fix it.
627 */
628 //!@{
629 
630 /** Write some atoms to a PDB.
631 */
632 IMPATOMEXPORT void write_pdb(const Selection &mhd, TextOutput out,
633  unsigned int model = 1);
634 
635 /** \brief Write a hierarchy to a PDB as C_alpha atoms.
636 
637  This method is used to write a non-atomic hierarchy into a PDB in a way
638  that can be read by most programs. If the leaves are Residue particles
639  then the index and residue type will be read from them. Otherwise default
640  values will be used so that each leaf ends up in a separate residue.
641 */
642 IMPATOMEXPORT void write_pdb_of_c_alphas(const Selection &mhd,
643  TextOutput out,
644  unsigned int model = 1);
645 
646 /** Write the hierarchies one per frame.
647 */
648 IMPATOMEXPORT void write_multimodel_pdb(const Hierarchies &mhd,
649  TextOutput out);
650 /** @} */
651 
652 #ifndef IMP_DOXYGEN
653 
654 /**
655  This function returns a string in PDB ATOM format
656 */
657 IMPATOMEXPORT std::string get_pdb_string(
658  const algebra::Vector3D &v, int index = -1, AtomType at = AT_CA,
659  ResidueType rt = atom::ALA, char chain = ' ', int res_index = 1,
660  char res_icode = ' ', double occupancy = 1.00, double tempFactor = 0.00,
661  Element e = C);
662 
663 /**
664  This function returns a connectivity string in PDB format
665  \note The CONECT records specify connectivity between atoms for which
666  coordinates are supplied. The connectivity is described using
667  the atom serial number as found in the entry.
668  \note http://www.bmsc.washington.edu/CrystaLinks/man/pdb/guide2.2_frame.html
669 */
670 IMPATOMEXPORT std::string get_pdb_conect_record_string(int, int);
671 #endif
672 
673 /** \class WritePDBOptimizerState
674  This writes a PDB file at the specified interval during optimization.
675  If the file name contains %1% then a new file is written each time
676  with the %1% replaced by the index. Otherwise a new model is written
677  each time to the same file.
678 */
679 class IMPATOMEXPORT WritePDBOptimizerState : public OptimizerState {
680  std::string filename_;
681  ParticleIndexes pis_;
682 
683  friend class cereal::access;
684 
685  template<class Archive> void serialize(Archive &ar) {
686  ar(cereal::base_class<OptimizerState>(this), filename_, pis_);
687  }
689 
690  public:
692  const ParticleIndexesAdaptor &pis,
693  std::string filename);
694  WritePDBOptimizerState(const atom::Hierarchies mh, std::string filename);
696 
697  protected:
698  virtual void do_update(unsigned int call) override;
699  virtual ModelObjectsTemp do_get_inputs() const override;
701 };
702 
703 IMPATOM_END_NAMESPACE
704 
705 #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:331
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:392
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:300
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:415
IMP::Vector< String > Strings
Standard way to pass a bunch of String values.
Definition: types.h:50
Select all P (= phosphate) ATOM records.
Definition: pdb.h:410
Select non hydrogen atoms.
Definition: pdb.h:353
const AtomType AT_CA
Select atoms which are selected by both selectors.
Definition: pdb.h:434
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:42
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:397
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:508
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:323
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:438
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:305
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:485
#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:377
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:461
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:335
#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:504
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:425
Shared optimizer state that is invoked upon commitment of new coordinates.
Select all non-water non-alternative ATOM and HETATM records.
Definition: pdb.h:373
Select atoms which are selected by either or both selectors.
Definition: pdb.h:457
Shared optimizer state.
void write_multimodel_pdb(const Hierarchies &mhd, TextOutput out)
Select all hydrogen ATOM and HETATM records.
Definition: pdb.h:316
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:481
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:357
bool get_is_selected(const PDBRecord &record) const override
Return true if the line should be processed.
Definition: pdb.h:133