IMP  2.0.1
The Integrative Modeling Platform
Fragment.h
Go to the documentation of this file.
1 /**
2  * \file IMP/atom/Fragment.h
3  * \brief A decorator for associating a Hierachy piece
4  *
5  * Copyright 2007-2013 IMP Inventors. All rights reserved.
6  */
7 
8 #ifndef IMPATOM_FRAGMENT_H
9 #define IMPATOM_FRAGMENT_H
10 
11 #include <IMP/atom/atom_config.h>
12 #include "Hierarchy.h"
13 #include <IMP/Decorator.h>
14 
15 IMPATOM_BEGIN_NAMESPACE
16 
17 //! A decorator to associate a particle with a part of a protein/DNA/RNA
18 /** The decorator stores an optional list of resdiue indexes.
19  */
20 class IMPATOMEXPORT Fragment: public Hierarchy
21 {
22  static IntsKey get_begins_key();
23  static IntsKey get_ends_key();
24  static void set_residue_indexes(Particle*p, Ints ris);
25  static void set_residue_indexes(Particle*p, const IntPairs& ris);
26  static IntKey get_marker_key();
27 public:
28  static Fragment setup_particle(Particle *p, const Ints &ris=Ints()) {
29  if (!Hierarchy::particle_is_instance(p)) {
30  Hierarchy::setup_particle(p);
31  }
32  set_residue_indexes(p, ris);
33  p->add_attribute(get_marker_key(), 1);
34  return Fragment(p);
35  }
36 
37  //! Create a domain by copying from o
39  if (!Hierarchy::particle_is_instance(p)) {
40  Hierarchy::setup_particle(p);
41  }
42  IntPairs ris= o.get_residue_index_ranges();
43  set_residue_indexes(p, ris);
44  p->add_attribute(get_marker_key(), 1);
45  return Fragment(p);
46  }
47 
48  virtual ~Fragment();
49 
50  static bool particle_is_instance(Particle *p) {
52  && p->has_attribute(get_marker_key());
53  }
54 
55 
56  //! Add the residues whose indexes are listed in the passed vector
58  set_residue_indexes(get_particle(), o);
59  }
60 
61  Ints get_residue_indexes() const;
62 
63  IntPairs get_residue_index_ranges() const;
64 
65  //! Return true if this fragment contains a given residue
66  /** This could be made more efficient. */
67  bool get_contains_residue(int rindex) const;
68 
70 };
71 
72 IMP_DECORATORS(Fragment,Fragments, Hierarchies);
73 
74 IMPATOM_END_NAMESPACE
75 
76 #endif /* IMPATOM_FRAGMENT_H */