12#include <IMP/bff/bff_config.h>
14#include <IMP/decorator_macros.h>
15#include <IMP/Decorator.h>
16#include <IMP/algebra/Vector3D.h>
17#include <IMP/algebra/Transformation3D.h>
18#include <IMP/core/XYZ.h>
22#include <IMP/bff/PathMap.h>
30#include <IMP/bff/internal/json.h>
31#include <IMP/bff/internal/InverseSampler.h>
34#include <IMP/bff/internal/Histogram.h>
57 double error_neg = -1;
58 double error_pos = -1;
59 double forster_radius = 52.0;
60 int distance_type = IMP::bff::DYE_PAIR_DISTANCE_MEAN;
90class IMPBFFEXPORT
AV :
public IMP::core::Gaussian {
94 IMP::bff::PathMap* av_map_ =
nullptr;
99 IMP::algebra::VectorD<9> v;
100 v[0] = get_linker_length();
101 v[1] = get_radius1();
102 v[2] = get_radius2();
103 v[3] = get_radius3();
104 v[4] = get_linker_width();
105 v[5] = get_allowed_sphere_radius();
106 v[6] = get_contact_volume_thickness();
107 v[7] = get_contact_volume_trapped_fraction();
108 v[8] = get_simulation_grid_resolution();
143 IMP_USAGE_CHECK(i < 9,
"Out of range av feature");
144 static const FloatKey k[] = {
145 FloatKey(
"linker_length"),
149 FloatKey(
"linker_width"),
150 FloatKey(
"allowed_sphere_radius"),
151 FloatKey(
"contact_volume_thickness"),
152 FloatKey(
"contact_volume_trapped_fraction"),
153 FloatKey(
"simulation_grid_resolution")
178 ParticleIndex pi_source,
179 double linker_length = 20.0,
180 const algebra::Vector3D radii = algebra::Vector3D(3.5, 0, 0),
181 double linker_width = 0.5,
182 double allowed_sphere_radius = 1.5,
183 double contact_volume_thickness = 0.0,
184 double contact_volume_trapped_fraction = -1,
185 double simulation_grid_resolution = 1.5) {
186 if (!IMP::core::Gaussian::get_is_setup(m, pi)) {
187 IMP::core::Gaussian::setup_particle(m, pi);
189 m->add_attribute(get_av_key(0), pi, linker_length);
190 m->add_attribute(get_av_key(1), pi, radii[0]);
191 m->add_attribute(get_av_key(2), pi, radii[1]);
192 m->add_attribute(get_av_key(3), pi, radii[2]);
193 m->add_attribute(get_av_key(4), pi, linker_width);
194 m->add_attribute(get_av_key(5), pi, allowed_sphere_radius);
195 m->add_attribute(get_av_key(6), pi, contact_volume_thickness);
196 m->add_attribute(get_av_key(7), pi, contact_volume_trapped_fraction);
197 m->add_attribute(get_av_key(8), pi, simulation_grid_resolution);
198 m->add_attribute(get_particle_key(0), pi, pi_source);
207 static const ParticleIndexKey k[1] = {
208 ParticleIndexKey(
"Source particle")
218 return Decorator::get_particle_index();
227 return get_model()->get_attribute(get_particle_key(i), get_particle_index());
235 return Decorator::get_particle();
244 return get_model()->get_particle(get_particle_index(i));
269 return IMP::algebra::Vector3D({get_radius1(), get_radius3(), get_radius3()});
277 get_particle()->get_is_optimized(get_av_key(0)) &&
278 get_particle()->get_is_optimized(get_av_key(1)) &&
279 get_particle()->get_is_optimized(get_av_key(2)) &&
280 get_particle()->get_is_optimized(get_av_key(3)) &&
281 get_particle()->get_is_optimized(get_av_key(6)) &&
282 get_particle()->get_is_optimized(get_av_key(7));
287 get_particle()->set_is_optimized(get_av_key(0), tf);
288 get_particle()->set_is_optimized(get_av_key(1), tf);
289 get_particle()->set_is_optimized(get_av_key(2), tf);
290 get_particle()->set_is_optimized(get_av_key(3), tf);
291 get_particle()->set_is_optimized(get_av_key(6), tf);
292 get_particle()->set_is_optimized(get_av_key(7), tf);
309 return get_model()->get_coordinate_derivatives(get_particle_index());
313 return m->get_has_attribute(get_av_key(2), pi);
359 double rda_r0_6 = std::pow(distance / forster_radius, 6.0);
360 return 1. / (1. + rda_r0_6);
387 double forster_radius = 52.0,
389 int n_samples = 10000
410 std::vector<double> axis,
430 const IMP::core::Hierarchy& hier,
431 std::string json_str =
"",
432 const nlohmann::json &json_data = nlohmann::json()
IMPBFFEXPORT IMP::ParticleIndex search_labeling_site(const IMP::core::Hierarchy &hier, std::string json_str="", const nlohmann::json &json_data=nlohmann::json())
Find the particle index of a labeling site.
IMPBFFEXPORT double av_distance(const AV &a, const AV &b, double forster_radius=52.0, int distance_type=DYE_PAIR_DISTANCE_MEAN, int n_samples=10000)
Computes the distance to another accessible volume.
DyePairMeasures
Different types of distances between two accessible volumes.
Definition AV.h:40
@ DYE_PAIR_DISTANCE_E
Definition AV.h:41
@ DYE_PAIR_DISTANCE_DISTRIBUTION
Mean FRET efficiency.
Definition AV.h:45
@ DYE_PAIR_EFFICIENCY
Distance between AV mean positions.
Definition AV.h:44
@ DYE_PAIR_DISTANCE_MP
Mean distance <R_DA>
Definition AV.h:43
@ DYE_PAIR_DISTANCE_MEAN
Mean FRET averaged distance R_E.
Definition AV.h:42
@ DYE_PAIR_XYZ_DISTANCE
Distance distribution.
Definition AV.h:46
T distance_fret(double fret_efficiency, double forster_radius)
Computes the distance between two volumes given the FRET efficiency and Forster radius.
Definition AV.h:371
IMP_DECORATORS(AV, AVs, ParticlesTemp)
T fret_efficiency(T distance, double forster_radius)
Computes the FRET efficiency given the distance and Forster radius.
Definition AV.h:358
IMPBFFEXPORT std::vector< double > av_random_distances(const AV &av1, const AV &av2, int n_samples=10000)
Random sampling over AV/AV distances.
IMPBFFEXPORT std::vector< double > av_random_points(const AV &av1, int n_samples=10000)
IMPBFFEXPORT std::vector< double > av_distance_distribution(const AV &av1, const AV &av2, std::vector< double > axis, int n_samples=10000)
Compute the distance to another accessible volume.
A decorator for a particle with accessible volume (AV).
Definition AV.h:90
IMP_DECORATOR_GET_SET(radius2, get_av_key(2), Float, Float)
Particle * get_particle() const
Get the particle pointer of the AV object.
Definition AV.h:234
IMP::bff::PathMapHeader create_path_map_header()
Creates a path map header.
IMP::algebra::Vector3D get_radii()
Returns the radii of an object.
Definition AV.h:268
static ParticleIndexKey get_particle_key(unsigned int i)
Get the particle key for the specified index.
Definition AV.h:206
IMP::algebra::VectorD< 9 > get_parameter() const
Definition AV.h:98
bool get_parameters_are_optimized() const
Get whether the coordinates are optimized.
Definition AV.h:275
void set_av_parameters_are_optimized(bool tf) const
Set whether the coordinates are optimized.
Definition AV.h:286
IMP::algebra::Vector3D get_mean_position(bool include_source=true) const
Get the mean position of the AV object.
IMP_DECORATOR_GET_SET(contact_volume_trapped_fraction, get_av_key(7), Float, Float)
IMP::bff::PathMap * get_map() const
Get the PathMap associated with the AV object.
Particle * get_source() const
Get the source particle of the AV object.
void set_av_parameter(const nlohmann::json &j)
Sets the AV parameter using a JSON object.
static void do_setup_particle(Model *m, ParticleIndex pi, ParticleIndex pi_source, double linker_length=20.0, const algebra::Vector3D radii=algebra::Vector3D(3.5, 0, 0), double linker_width=0.5, double allowed_sphere_radius=1.5, double contact_volume_thickness=0.0, double contact_volume_trapped_fraction=-1, double simulation_grid_resolution=1.5)
Sets up the attributes for a particle in a model for AV (Anisotropic Volume) calculations.
Definition AV.h:177
ParticleIndex get_particle_index() const
Get the particle index of the AV object.
Definition AV.h:217
void init_path_map()
Initializes the path map.
ParticleIndex get_particle_index(unsigned int i) const
Get the particle index of the AV object at the specified index.
Definition AV.h:226
algebra::Vector3D get_derivatives() const
Get the vector of derivatives accumulated by add_to_derivatives().
Definition AV.h:308
Particle * get_particle(unsigned int i) const
Get the particle pointer of the AV object at the specified index.
Definition AV.h:243
void resample(bool shift_xyz=true)
Resample the AV object.
IMP_DECORATOR_GET_SET(radius1, get_av_key(1), Float, Float)
IMP_DECORATOR_GET_SET(simulation_grid_resolution, get_av_key(8), Float, Float)
static FloatKey get_av_key(unsigned int i)
Get the FloatKey object for a specific AV feature.
Definition AV.h:142
IMP_DECORATOR_SETUP_1(AV, IMP::ParticleIndex, pi_source)
IMP_DECORATOR_GET_SET(linker_length, get_av_key(0), Float, Float)
IMP_DECORATOR_GET_SET(allowed_sphere_radius, get_av_key(5), Float, Float)
static bool get_is_setup(Model *m, ParticleIndex pi)
Definition AV.h:312
IMP_DECORATOR_GET_SET(contact_volume_thickness, get_av_key(6), Float, Float)
IMP_DECORATOR_METHODS(AV, IMP::core::Gaussian)
IMP_DECORATOR_GET_SET(linker_width, get_av_key(4), Float, Float)
IMP::algebra::Vector3D get_source_coordinates() const
Get the source coordinates of the AV object.
IMP_DECORATOR_GET_SET(radius3, get_av_key(3), Float, Float)
Container for experimental distance measurement.
Definition AV.h:52
std::string get_json()
Get a JSON string.
double score_model(double model)
Score a model distance against the experimental distance.
std::string position_1
Definition AV.h:61
std::string position_2
Definition AV.h:62