IMP logo
IMP Reference Guide  develop.298718d020,2025/02/22
The Integrative Modeling Platform
mmcif.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/mmcif.h
3  * \brief Functions to read PDBs in mmCIF or BinaryCIF format
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_MMCIF_H
10 #define IMPATOM_MMCIF_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include <IMP/atom/Hierarchy.h>
14 #include <IMP/atom/pdb.h>
15 
16 IMPATOM_BEGIN_NAMESPACE
17 
18 //! Read all models from the mmCIF file.
19 IMPATOMEXPORT Hierarchies read_multimodel_mmcif(TextInput input, Model *model,
20  PDBSelector *selector = get_default_pdb_selector()
21 #ifndef IMP_DOXYGEN
22  , bool noradii = false
23 #endif
24  );
25 
26 //! Read all the molecules in the first model of the mmCIF file.
27 IMPATOMEXPORT Hierarchy read_mmcif(TextInput input, Model *model,
28  PDBSelector *selector = get_default_pdb_selector(),
29  bool select_first_model = true
30 #ifndef IMP_DOXYGEN
31  , bool noradii = false
32 #endif
33  );
34 
35 
36 //! Read all models from the BinaryCIF file.
37 IMPATOMEXPORT Hierarchies read_multimodel_bcif(TextInput input, Model *model,
38  PDBSelector *selector = get_default_pdb_selector()
39 #ifndef IMP_DOXYGEN
40  , bool noradii = false
41 #endif
42  );
43 
44 //! Read all the molecules in the first model of the BinaryCIF file.
45 IMPATOMEXPORT Hierarchy read_bcif(TextInput input, Model *model,
46  PDBSelector *selector = get_default_pdb_selector(),
47  bool select_first_model = true
48 #ifndef IMP_DOXYGEN
49  , bool noradii = false
50 #endif
51  );
52 
53 //! Read all the molecules in the first model of the PDB-like file.
54 /** This should handle reading coordinates from any of the file formats
55  used by the PDB database, i.e. legacy "PDB" format, mmCIF, or BinaryCIF.
56  If the filename ends in '.cif' it is treated as an mmCIF file;
57  if the filename ends in '.bcif' it is treated as a BinaryCIF file;
58  otherwise a legacy PDB file is read.
59  Note that TextInputs created from streams don't have a name and so
60  will always be treated as legacy PDB. */
61 inline Hierarchy read_pdb_any(TextInput input, Model *model,
62  PDBSelector *selector = get_default_pdb_selector(),
63  bool select_first_model = true
64 #ifndef IMP_DOXYGEN
65  , bool noradii = false
66 #endif
67  ) {
68  std::string filename = input.get_name();
69  if (filename.find(".cif") == filename.size() - 4) {
70  return read_mmcif(input, model, selector, select_first_model, noradii);
71  } else if (filename.find(".bcif") == filename.size() - 5) {
72  return read_bcif(input, model, selector, select_first_model, noradii);
73  } else {
74  return read_pdb(input, model, selector, select_first_model, noradii);
75  }
76 }
77 
78 //! Read all models from the PDB-like file.
79 /** This should handle reading coordinates from any of the file formats
80  used by the PDB database, i.e. legacy "PDB" format, mmCIF, or BinaryCIF.
81  If the filename ends in '.cif' it is treated as an mmCIF file;
82  if the filename ends in '.bcif' it is treated as a BinaryCIF file;
83  otherwise a legacy PDB file is read.
84  Note that TextInputs created from streams don't have a name and so
85  will always be treated as legacy PDB. */
87  PDBSelector *selector = get_default_pdb_selector()
88 #ifndef IMP_DOXYGEN
89  , bool noradii = false
90 #endif
91  ) {
92  std::string filename = input.get_name();
93  if (filename.find(".cif") == filename.size() - 4) {
94  return read_multimodel_mmcif(input, model, selector, noradii);
95  } else if (filename.find(".bcif") == filename.size() - 5) {
96  return read_multimodel_bcif(input, model, selector, noradii);
97  } else {
98  return read_multimodel_pdb(input, model, selector, noradii);
99  }
100 }
101 
102 #ifndef IMP_DOXYGEN
103 IMPATOM_DEPRECATED_FUNCTION_DECL(2.23)
104 inline Hierarchy read_pdb_or_mmcif(TextInput input, Model *model,
105  PDBSelector *selector = get_default_pdb_selector(),
106  bool select_first_model = true
107  , bool noradii = false
108  ) {
109  IMPATOM_DEPRECATED_FUNCTION_DEF(2.23, "Use read_pdb_any() instead");
110  std::string filename = input.get_name();
111  if (filename.find(".cif") == filename.size() - 4) {
112  return read_mmcif(input, model, selector, select_first_model, noradii);
113  } else {
114  return read_pdb(input, model, selector, select_first_model, noradii);
115  }
116 }
117 
118 IMPATOM_DEPRECATED_FUNCTION_DECL(2.23)
119 inline Hierarchies read_multimodel_pdb_or_mmcif(TextInput input, Model *model,
120  PDBSelector *selector = get_default_pdb_selector()
121  , bool noradii = false
122  ) {
123  IMPATOM_DEPRECATED_FUNCTION_DEF(
124  2.23, "Use read_multimodel_pdb_any() instead");
125  std::string filename = input.get_name();
126  if (filename.find(".cif") == filename.size() - 4) {
127  return read_multimodel_mmcif(input, model, selector, noradii);
128  } else {
129  return read_multimodel_pdb(input, model, selector, noradii);
130  }
131 }
132 #endif
133 
134 IMPATOM_END_NAMESPACE
135 
136 #endif /* IMPATOM_MMCIF_H */
Hierarchy read_mmcif(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the mmCIF file.
Functions to read PDBs.
Hierarchies read_multimodel_pdb_any(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector())
Read all models from the PDB-like file.
Definition: mmcif.h:86
Hierarchies read_multimodel_bcif(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector())
Read all models from the BinaryCIF file.
Hierarchy read_bcif(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the BinaryCIF file.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Hierarchies read_multimodel_mmcif(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector())
Read all models from the mmCIF file.
Decorator for helping deal with a hierarchy of molecules.
Hierarchy read_pdb_any(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB-like file.
Definition: mmcif.h:61
The standard decorator for manipulating molecular structures.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
Hierarchies read_multimodel_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector())
Select which atoms to read from a PDB file.
Definition: pdb.h:103