1 """@namespace IMP.bff.tools
17 dye_radius: float = 3.5
19 """Decorate the accessible volume particles
20 with a mass and radii, so that they appear
24 p_dye = dye.get_particle()
27 p_dye.set_radius(dye_radius)
34 p_att = dye.get_source()
38 h_att.add_child(h_dye)
50 class FRETDistanceConverter(object):
52 _forster_radius_: float = 52.0
55 _dist_center_center_: float = 50.0
58 _distances_: np.ndarray =
None
59 _fret_efficiencies_: np.ndarray =
None
60 _density_: np.ndarray =
None
63 _d_mean_: np.ndarray =
None
64 _d_mean_fret_: np.ndarray =
None
65 _e_mean_: np.ndarray =
None
67 def _update_fret_efficiencies_(self, forster_radius: float):
68 RDA = self._distances_
70 self._fret_efficiencies_ = 1. / (1 + (RDA / R0)**6.0)
72 def _update_lookup(self):
73 self._d_mean_ = np.empty_like(self._distances_)
74 self._d_mean_fret_ = np.empty_like(self._distances_)
75 self._e_mean_ = np.empty_like(self._distances_)
76 for i, d
in enumerate(self._distances_):
77 self._update_density(d, self._sigma_)
78 self._d_mean_[i] = self.calc_distance_mean()
79 self._d_mean_fret_[i] = self.calc_distance_mean_fret()
80 self._e_mean_[i] = self.calc_fret_efficiency_mean()
82 def _update_density(self, dcc: float, w: float):
83 """Update the distance distribution
85 @param dcc center-to-center distance
86 @param w parameter controlling the distribution width
89 n1 = scipy.stats.norm(-dcc, w)
90 n2 = scipy.stats.norm(dcc, w)
91 p = n1.pdf(d) + n2.pdf(d)
96 def dist_center_center(self):
97 return self._dist_center_center_
99 @dist_center_center.setter
100 def dist_center_center(self, v):
101 self._dist_center_center_ = v
108 def sigma(self, v: float):
110 self._update_lookup()
113 def forster_radius(self):
114 return self._forster_radius_
116 @forster_radius.setter
117 def forster_radius(self, v: float):
118 self._forster_radius_ = v
119 self._update_fret_efficiencies_(v)
120 self._update_lookup()
122 def calc_distance_mean(self):
127 def calc_fret_efficiency_mean(self):
129 v = self._fret_efficiencies_
132 def calc_distance_mean_fret(self):
133 E = self.calc_fret_efficiency_mean()
134 R0 = self.forster_radius
135 return R0 * (1. / E - 1.)**(1. / 6.)
138 def fret_efficiency_mean(self):
139 return np.interp(self.dist_center_center, self._distances_,
143 def distance_mean(self):
144 return np.interp(self.dist_center_center, self._distances_,
148 def distance_mean_fret(self):
149 return np.interp(self.dist_center_center, self._distances_,
152 def __call__(self, value: float, distance_type: int):
153 self.dist_center_center = value
154 if distance_type == IMP.bff.DYE_PAIR_DISTANCE_MEAN:
155 return self.distance_mean
156 elif distance_type == IMP.bff.DYE_PAIR_DISTANCE_E:
157 return self.distance_mean_fret
158 elif distance_type == IMP.bff.DYE_PAIR_DISTANCE_MP:
163 forster_radius: float = 52.0,
165 distance_range: typing.Tuple[float, float] = (1.0, 100.0),
166 n_distances: int = 128
168 self._forster_radius_ = forster_radius
170 self._distances_ = np.linspace(
171 *distance_range, n_distances, dtype=np.float64)
172 self._density_ = np.zeros_like(self._distances_)
173 self._update_fret_efficiencies_(self._forster_radius_)
174 self._update_lookup()
178 """Read a xlink table
180 :param fn: filename of the xlink table
186 with open(fn,
'r') as fp:
187 lines = fp.readlines()
188 for line
in lines[1:]:
191 protein_1, residue_1, protein_2, residue_2 = line.split(
',')
192 residue_1 = int(residue_1)
193 residue_2 = int(residue_2)
195 'protein_1': protein_1,
196 'protein_2': protein_2,
197 'residue_1': residue_1,
198 'residue_2': residue_2
200 xlinks[xlink_idx] = d
A decorator for a particle with accessible volume (AV).
static XYZR setup_particle(Model *m, ParticleIndex pi)
A decorator for a particle which has bonds.
static bool get_is_setup(Model *m, ParticleIndex pi)
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Bond create_bond(Bonded a, Bonded b, Bond o)
Connect the two wrapped particles by a custom bond.
static Hierarchy setup_particle(Model *m, ParticleIndex pi, ParticleIndexesAdaptor children=ParticleIndexesAdaptor())
Create a Hierarchy of level t by adding the needed attributes.
The standard decorator for manipulating molecular structures.
static Mass setup_particle(Model *m, ParticleIndex pi, Float mass)
static Bonded setup_particle(Model *m, ParticleIndex pi)
Basic functionality that is expected to be used by a wide variety of IMP users.
static bool get_is_setup(const IMP::ParticleAdaptor &p)
Bond get_bond(Bonded a, Bonded b)
Get the bond between two particles.
Functionality for loading, creating, manipulating and scoring atomic structures.
Bayesian Fluorescence Framework.
A decorator for a particle with x,y,z coordinates and a radius.