IMP  2.0.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  * Copyright 2007-2013 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 public:
29 
30  //! Set up SecondaryStructureResidue when you know all three probabilities
31  static SecondaryStructureResidue setup_particle(Particle *res_p,
32  Float prob_helix,
33  Float prob_strand,
34  Float prob_coil){
35  res_p->add_attribute(get_prob_helix_key(),prob_helix);
36  res_p->add_attribute(get_prob_strand_key(),prob_strand);
37  res_p->add_attribute(get_prob_coil_key(),prob_coil);
38  if (!Hierarchy::particle_is_instance(res_p)) {
39  Hierarchy::setup_particle(res_p);
40  }
41  SecondaryStructureResidue ssr(res_p);
42  ssr.set_prob_helix(prob_helix);
43  ssr.set_prob_strand(prob_strand);
44  ssr.set_prob_coil(prob_coil);
45  return ssr;
46  }
47 
48  //! Set up SecondaryStructureResidue with default probabilities
50  Float prob_helix=1.0/3.0,prob_strand=1.0/3.0,prob_coil=1.0/3.0;
51  SecondaryStructureResidue ssr = setup_particle(res_p,
52  prob_helix,
53  prob_strand,
54  prob_coil);
55  return ssr;
56  }
57 
58  //! Return true if the particle is a secondary structure residue
59  static bool particle_is_instance(Particle *p) {
60  if (p->has_attribute(get_prob_helix_key())
61  && (p->has_attribute(get_prob_strand_key()))
62  && (p->has_attribute(get_prob_coil_key()))) return true;
63  return false;
64  }
65 
66  Particle* get_particle() const {
67  return Decorator::get_particle();
68  }
69 
70  //! Return all probabilities in one vector
72  Floats res;
73  res.push_back(get_prob_helix());
74  res.push_back(get_prob_strand());
75  res.push_back(get_prob_coil());
76  return res;
77  }
78 
79  IMP_DECORATOR_GET_SET_OPT(prob_helix, get_prob_helix_key(),
80  Float, Float, 0.333);
81  IMP_DECORATOR_GET_SET_OPT(prob_strand, get_prob_strand_key(),
82  Float, Float, 0.333);
83  IMP_DECORATOR_GET_SET_OPT(prob_coil, get_prob_coil_key(),
84  Float, Float, 0.333);
85 
86  static FloatKey get_prob_helix_key();
87  static FloatKey get_prob_strand_key();
88  static FloatKey get_prob_coil_key();
89 };
90 IMP_DECORATORS(SecondaryStructureResidue, SecondaryStructureResidues,
91  ParticlesTemp);
92 
93 /** Coarsen some SecondaryStructureResidues. Returns a
94  SecondaryStructureResidue whose probabilities reflect those of the
95  underlying residues. Useful if you want to represent the secondary
96  structure contents at a coarser level.
97  \param[in] ssr_ps The SSR-decorated particles to be combined
98  \param[in] mdl The IMP Model
99  \param[in] winner_takes_all_per_res Whether to set prob=1.0 for top
100  scoring secondary structure type
101  */
102 IMPATOMEXPORT
103 SecondaryStructureResidue setup_coarse_secondary_structure_residue(
104  const Particles &ssr_ps,
105  Model *mdl,
106  bool winner_takes_all_per_res=false);
107 
108 /** Groups SecondaryStructureResidues into segments and then coarsens them.
109  Useful if you have a long sequence and want to make several coarse nodes.
110  \param[in] ssr_ps The SSR-decorated particles to be combined
111  \param[in] mdl The IMP Model
112  \param[in] coarse_factor Group size
113  \param[in] start_res_num Starting residue number for the provided sequence
114  \param[in] winner_takes_all_per_res Whether to set prob=1.0 for top
115  scoring secondary structure type
116  */
117 IMPATOMEXPORT
118 SecondaryStructureResidues setup_coarse_secondary_structure_residues(
119  const Particles &ssr_ps,
120  Model *mdl,
121  int coarse_factor,
122  int start_res_num,
123  bool winner_takes_all_per_res=false);
124 
125 /** Compares the secondary structure probabilities of two
126  SecondaryStructureResidues. Returns the RMSD of the three probabilities
127  (lower is better match).
128  */
129 IMPATOMEXPORT
130 Float get_secondary_structure_match_score(SecondaryStructureResidue ssr1,
131  SecondaryStructureResidue ssr2);
132 
133 IMPATOM_END_NAMESPACE
134 
135 #endif /* IMPATOM_SECONDARY_STRUCTURE_RESIDUE_H */