8#ifndef IMPATOM_BOND_DECORATORS_H
9#define IMPATOM_BOND_DECORATORS_H
11#include <IMP/atom/atom_config.h>
12#include <IMP/core/internal/graph_base.h>
13#include "internal/bond_helpers.h"
21#include <IMP/internal/IndexingIterator.h>
22IMPATOM_BEGIN_NAMESPACE
40class IMPATOMEXPORT Bond :
public Decorator {
47 return IMP::core::internal::graph_is_edge(m->get_particle(pi),
48 internal::get_bond_data().graph_);
69 Bonded get_bonded(
unsigned int i)
const;
82 static FloatKey get_length_key() {
return internal::get_bond_data().length_; }
89class IMPATOMEXPORT Bonded :
public Decorator {
91 typedef Bond result_type;
93 GetBond() : d_(
nullptr) {}
95 Bond operator()(
unsigned int i)
const;
96 bool operator==(
const GetBond &o)
const {
return d_ == o.d_; }
99 typedef Bonded result_type;
101 GetBonded() : d_(
nullptr) {}
103 Bonded operator()(
unsigned int i)
const;
104 bool operator==(
const GetBonded &o)
const {
return d_ == o.d_; }
107 graph_initialize_node(m->get_particle(pi),
108 internal::get_bond_data().graph_);
116 return IMP::core::internal::graph_is_node(m->get_particle(pi),
117 internal::get_bond_data().graph_);
121 unsigned int get_number_of_bonds()
const {
122 return graph_get_number_of_edges(get_particle(),
123 internal::get_bond_data().graph_);
127 return graph_get_edges(get_particle(), internal::get_bond_data().graph_);
136 graph_get_edge(
get_particle(), i, internal::get_bond_data().graph_);
152 graph_get_edge(
get_particle(), i, internal::get_bond_data().graph_);
154 if (bd.get_bonded(0) == *
this)
155 return bd.get_bonded(1);
157 return bd.get_bonded(0);
166 typedef IMP::internal::IndexingIterator<GetBond> BondIterator;
169 BondIterator bonds_begin()
const {
170 return BondIterator(GetBond(get_particle()), 0);
172 BondIterator bonds_end()
const {
173 return BondIterator(GetBond(get_particle()), get_number_of_bonds());
181 class BondedIterator;
183 typedef IMP::internal::IndexingIterator<GetBonded> BondedIterator;
186 BondedIterator bondeds_begin()
const {
187 return BondedIterator(GetBonded(get_particle()), 0);
189 BondedIterator bondeds_end()
const {
190 return BondedIterator(GetBonded(get_particle()), get_number_of_bonds());
201 graph_get_node(
get_particle(), i, internal::get_bond_data().graph_);
206inline Bond Bonded::GetBond::operator()(
unsigned int i)
const {
209inline Bonded Bonded::GetBonded::operator()(
unsigned int i)
const {
238 Float stiffness = -1) {
241 bd.set_length(length);
242 bd.get_particle()->set_name(std::string(
"bond ") +
243 a.get_particle()->get_name() +
" and " +
244 b.get_particle()->get_name());
245 if (stiffness >= 0) bd.set_stiffness(stiffness);
258 if (o.get_length() > 0) bd.set_length(o.get_length());
259 bd.get_particle()->set_name(std::string(
"bond ") +
260 a.get_particle()->get_name() +
" and " +
261 b.get_particle()->get_name());
262 if (o.get_stiffness() >= 0) bd.set_stiffness(o.get_stiffness());
The base class for decorators.
Storage of a model, its restraints, constraints and particles.
Classes to handle individual model particles. (Note that implementation of inline functions is in int...
#define IMP_INTERNAL_CHECK(expr, message)
An assertion to check for internal errors in IMP. An IMP::ErrorException will be thrown.
Particle * get_particle() const
Returns the particle decorated by this decorator.
Class for storing model, its restraints, constraints, and particles.
Class to handle individual particles of a Model object.
Simple implementation of segments in 3D.
A decorator for wrapping a particle representing a molecular bond.
Type
The types a bond can have right now.
Bonded get_bonded(unsigned int i) const
Get the atom i of the bond.
A decorator for a particle which has bonds.
Bonded get_bonded(unsigned int i) const
Get a Bonded of the ith bonded particle.
Bond get_bond(unsigned int i) const
Get a Bond of the ith bond.
A decorator for a particle with x,y,z coordinates.
The base class for geometry.
#define IMP_DECORATOR_GET_SET_OPT(name, AttributeKey, Type, ReturnType, default_value)
Define methods for getting and setting an optional simple field.
#define IMP_DECORATOR_SETUP_0(Name)
#define IMP_DECORATORS(Name, PluralName, Parent)
Define the types for storing sets of decorators.
#define IMP_DECORATOR_METHODS(Name, Parent)
Bond create_custom_bond(Bonded a, Bonded b, Float length, Float stiffness=-1)
Connect the two wrapped particles by a custom bond.
void destroy_bond(Bond b)
Destroy the bond connecting two particles.
Bond create_bond(Bonded a, Bonded b, Int t)
Connect the two wrapped particles by a bond.
Bond get_bond(Bonded a, Bonded b)
Get the bond between two particles.
Index< ParticleIndexTag > ParticleIndex
double Float
Basic floating-point value (could be float, double...).
int Int
Basic integer value.
Vector< ParticleIndex, std::allocator< ParticleIndex > > ParticleIndexes
A list of particles, each identified by its ParticleIndex.
Key< 0 > FloatKey
The type used to identify float attributes in the Particles.
Represent an XYZR particle with a sphere.
Implement geometry for the basic shapes from IMP.algebra.