IMP logo
IMP Reference Guide  2.19.0
The Integrative Modeling Platform
SecondaryStructureResidue.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/SecondaryStructureResidue.h
3  * \brief A decorator for storing secondary structure probabilities.
4  *
5  * Copyright 2007-2022 IMP Inventors. All rights reserved.
6  *
7  */
8 
9 #ifndef IMPATOM_SECONDARY_STRUCTURE_RESIDUE_H
10 #define IMPATOM_SECONDARY_STRUCTURE_RESIDUE_H
11 
12 #include <IMP/atom/atom_config.h>
13 #include <IMP/atom/atom_macros.h>
14 #include <IMP/atom/Hierarchy.h>
15 
16 #include <IMP/base_types.h>
17 #include <IMP/Particle.h>
18 #include <IMP/Model.h>
19 #include <IMP/Decorator.h>
20 
21 IMPATOM_BEGIN_NAMESPACE
22 
23 //! A decorator for a residue with probability of secondary structure
24 /**
25  Contains probabilities for each sse type (helix, strand, coil)
26  */
27 class IMPATOMEXPORT SecondaryStructureResidue : public Decorator {
28  static void do_setup_particle(Model *m, ParticleIndex pi,
29  Float prob_helix, Float prob_strand,
30  Float prob_coil) {
31  m->add_attribute(get_prob_helix_key(), pi, prob_helix);
32  m->add_attribute(get_prob_strand_key(), pi, prob_strand);
33  m->add_attribute(get_prob_coil_key(), pi, prob_coil);
34  if (!Hierarchy::get_is_setup(m, pi)) {
35  Hierarchy::setup_particle(m, pi);
36  }
37  // seems redundant
38  SecondaryStructureResidue ssr(m, pi);
39  ssr.set_prob_helix(prob_helix);
40  ssr.set_prob_strand(prob_strand);
41  ssr.set_prob_coil(prob_coil);
42  }
43 
44  public:
47  prob_strand, Float, prob_coil);
48 
49  //! Set up SecondaryStructureResidue with default probabilities
51  Float prob_helix = 1.0 / 3.0, prob_strand = 1.0 / 3.0,
52  prob_coil = 1.0 / 3.0;
54  setup_particle(res_p, prob_helix, prob_strand, prob_coil);
55  return ssr;
56  }
57 
58  //! Return true if the particle is a secondary structure residue
59  static bool get_is_setup(Model *m, ParticleIndex pi) {
60  if (m->get_has_attribute(get_prob_helix_key(), pi) &&
61  (m->get_has_attribute(get_prob_strand_key(), pi)) &&
62  (m->get_has_attribute(get_prob_coil_key(), pi)))
63  return true;
64  return false;
65  }
66 
67  Particle *get_particle() const { return Decorator::get_particle(); }
68 
69  //! Return all probabilities in one vector
71  Floats res;
72  res.push_back(get_prob_helix());
73  res.push_back(get_prob_strand());
74  res.push_back(get_prob_coil());
75  return res;
76  }
77 
78  IMP_DECORATOR_GET_SET_OPT(prob_helix, get_prob_helix_key(), Float, Float,
79  0.333);
80  IMP_DECORATOR_GET_SET_OPT(prob_strand, get_prob_strand_key(), Float, Float,
81  0.333);
82  IMP_DECORATOR_GET_SET_OPT(prob_coil, get_prob_coil_key(), Float, Float,
83  0.333);
84 
85  static FloatKey get_prob_helix_key();
86  static FloatKey get_prob_strand_key();
87  static FloatKey get_prob_coil_key();
88 };
91 
92 //! Coarsen some SecondaryStructureResidues.
93 /** \returns a SecondaryStructureResidue whose probabilities reflect those
94  of the underlying residues. Useful if you want to represent the secondary
95  structure contents at a coarser level.
96  \param[in] ssr_ps The SSR-decorated particles to be combined
97  \param[in] mdl The IMP Model
98  \param[in] winner_takes_all_per_res Whether to set prob=1.0 for top
99  scoring secondary structure type
100  */
101 IMPATOMEXPORT SecondaryStructureResidue
103  Model *mdl,
104  bool winner_takes_all_per_res =
105  false);
106 
107 /** Groups SecondaryStructureResidues into segments and then coarsens them.
108  Useful if you have a long sequence and want to make several coarse nodes.
109  \param[in] ssr_ps The SSR-decorated particles to be combined
110  \param[in] mdl The IMP Model
111  \param[in] coarse_factor Group size
112  \param[in] start_res_num Starting residue number for the provided sequence
113  \param[in] winner_takes_all_per_res Whether to set prob=1.0 for top
114  scoring secondary structure type
115  */
116 IMPATOMEXPORT SecondaryStructureResidues
118  const Particles &ssr_ps, Model *mdl, int coarse_factor,
119  int start_res_num, bool winner_takes_all_per_res = false);
120 
121 //! Compares the secondary structure probabilities of two residues.
122 /** \returns the RMSD of the three probabilities (lower is better match).
123  */
124 IMPATOMEXPORT Float
127 
128 IMPATOM_END_NAMESPACE
129 
130 #endif /* IMPATOM_SECONDARY_STRUCTURE_RESIDUE_H */
The base class for decorators.
Float get_secondary_structure_match_score(SecondaryStructureResidue ssr1, SecondaryStructureResidue ssr2)
Compares the secondary structure probabilities of two residues.
Basic types used by IMP.
#define IMP_DECORATOR_GET_SET_OPT(name, AttributeKey, Type, ReturnType, default_value)
Define methods for getting and setting an optional simple field.
Storage of a model, its restraints, constraints and particles.
Class for storing model, its restraints, constraints, and particles.
Definition: Model.h:86
Floats get_all_probabilities()
Return all probabilities in one vector.
Decorator for helping deal with a hierarchy of molecules.
void add_attribute(TypeKey attribute_key, ParticleIndex particle, Type value)
add particle atribute with the specied key and initial value
SecondaryStructureResidue setup_coarse_secondary_structure_residue(const Particles &ssr_ps, Model *mdl, bool winner_takes_all_per_res=false)
Coarsen some SecondaryStructureResidues.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Definition: Decorator.h:194
SecondaryStructureResidues setup_coarse_secondary_structure_residues(const Particles &ssr_ps, Model *mdl, int coarse_factor, int start_res_num, bool winner_takes_all_per_res=false)
Interface to specialized Particle types (e.g. atoms)
Definition: Decorator.h:119
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
A decorator for a residue with probability of secondary structure.
Macros for maintaining molecular hierarchies.
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
Class to handle individual particles of a Model object.
Definition: Particle.h:43
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
static bool get_is_setup(Model *m, ParticleIndex pi)
Return true if the particle is a secondary structure residue.
static SecondaryStructureResidue setup_particle(Particle *res_p)
Set up SecondaryStructureResidue with default probabilities.
bool get_has_attribute(TypeKey attribute_key, ParticleIndex particle) const
return true if particle has attribute with the specified key
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name)