IMP logo
IMP Reference Guide  2.6.2
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  * Copyright 2007-2016 IMP Inventors. All rights reserved.
5  *
6  */
7 
8 #ifndef IMPATOM_SECONDARY_STRUCTURE_RESIDUE_H
9 #define IMPATOM_SECONDARY_STRUCTURE_RESIDUE_H
10 
11 #include "atom_config.h"
12 #include "atom_macros.h"
13 #include "Hierarchy.h"
14 
15 #include <IMP/base_types.h>
16 #include <IMP/Particle.h>
17 #include <IMP/Model.h>
18 #include <IMP/Decorator.h>
19 
20 IMPATOM_BEGIN_NAMESPACE
21 
22 //! A decorator for a residue with probability of secondary structure
23 /**
24  Contains probabilities for each sse type (helix, strand, coil)
25  */
26 class IMPATOMEXPORT SecondaryStructureResidue : public Decorator {
27  static void do_setup_particle(Model *m, ParticleIndex pi,
28  Float prob_helix, Float prob_strand,
29  Float prob_coil) {
30  m->add_attribute(get_prob_helix_key(), pi, prob_helix);
31  m->add_attribute(get_prob_strand_key(), pi, prob_strand);
32  m->add_attribute(get_prob_coil_key(), pi, prob_coil);
33  if (!Hierarchy::get_is_setup(m, pi)) {
34  Hierarchy::setup_particle(m, pi);
35  }
36  // seems redundant
37  SecondaryStructureResidue ssr(m, pi);
38  ssr.set_prob_helix(prob_helix);
39  ssr.set_prob_strand(prob_strand);
40  ssr.set_prob_coil(prob_coil);
41  }
42 
43  public:
46  prob_strand, Float, prob_coil);
47 
48  //! Set up SecondaryStructureResidue with default probabilities
50  Float prob_helix = 1.0 / 3.0, prob_strand = 1.0 / 3.0,
51  prob_coil = 1.0 / 3.0;
53  setup_particle(res_p, prob_helix, prob_strand, prob_coil);
54  return ssr;
55  }
56 
57  //! Return true if the particle is a secondary structure residue
58  static bool get_is_setup(Model *m, ParticleIndex pi) {
59  if (m->get_has_attribute(get_prob_helix_key(), pi) &&
60  (m->get_has_attribute(get_prob_strand_key(), pi)) &&
61  (m->get_has_attribute(get_prob_coil_key(), pi)))
62  return true;
63  return false;
64  }
65 
66  Particle *get_particle() const { return Decorator::get_particle(); }
67 
68  //! Return all probabilities in one vector
70  Floats res;
71  res.push_back(get_prob_helix());
72  res.push_back(get_prob_strand());
73  res.push_back(get_prob_coil());
74  return res;
75  }
76 
77  IMP_DECORATOR_GET_SET_OPT(prob_helix, get_prob_helix_key(), Float, Float,
78  0.333);
79  IMP_DECORATOR_GET_SET_OPT(prob_strand, get_prob_strand_key(), Float, Float,
80  0.333);
81  IMP_DECORATOR_GET_SET_OPT(prob_coil, get_prob_coil_key(), Float, Float,
82  0.333);
83 
84  static FloatKey get_prob_helix_key();
85  static FloatKey get_prob_strand_key();
86  static FloatKey get_prob_coil_key();
87 };
88 IMP_DECORATORS(SecondaryStructureResidue, SecondaryStructureResidues,
90 
91 //! Coarsen some SecondaryStructureResidues.
92 /** \returns a SecondaryStructureResidue whose probabilities reflect those
93  of the underlying residues. Useful if you want to represent the secondary
94  structure contents at a coarser level.
95  \param[in] ssr_ps The SSR-decorated particles to be combined
96  \param[in] mdl The IMP Model
97  \param[in] winner_takes_all_per_res Whether to set prob=1.0 for top
98  scoring secondary structure type
99  */
100 IMPATOMEXPORT SecondaryStructureResidue
102  Model *mdl,
103  bool winner_takes_all_per_res =
104  false);
105 
106 /** Groups SecondaryStructureResidues into segments and then coarsens them.
107  Useful if you have a long sequence and want to make several coarse nodes.
108  \param[in] ssr_ps The SSR-decorated particles to be combined
109  \param[in] mdl The IMP Model
110  \param[in] coarse_factor Group size
111  \param[in] start_res_num Starting residue number for the provided sequence
112  \param[in] winner_takes_all_per_res Whether to set prob=1.0 for top
113  scoring secondary structure type
114  */
115 IMPATOMEXPORT SecondaryStructureResidues
117  const Particles &ssr_ps, Model *mdl, int coarse_factor,
118  int start_res_num, bool winner_takes_all_per_res = false);
119 
120 //! Compares the secondary structure probabilities of two residues.
121 /** \returns the RMSD of the three probabilities (lower is better match).
122  */
123 IMPATOMEXPORT Float
124  get_secondary_structure_match_score(SecondaryStructureResidue ssr1,
125  SecondaryStructureResidue ssr2);
126 
127 IMPATOM_END_NAMESPACE
128 
129 #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:72
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)
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:171
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:118
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.
Various important macros for implementing decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Class to handle individual model particles.
Definition: Particle.h:37
#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.
#define IMP_DECORATOR_SETUP_3(Name, FirstArgumentType, first_argument_name,SecondArgumentType, second_argument_name,ThirdArgumentType, third_argument_name)