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)
49 class FRETDistanceConverter(object):
51 _forster_radius_: float = 52.0
54 _dist_center_center_: float = 50.0
57 _distances_: np.ndarray =
None
58 _fret_efficiencies_: np.ndarray =
None
59 _density_: np.ndarray =
None
62 _d_mean_: np.ndarray =
None
63 _d_mean_fret_: np.ndarray =
None
64 _e_mean_: np.ndarray =
None
66 def _update_fret_efficiencies_(self, forster_radius: float):
67 RDA = self._distances_
69 self._fret_efficiencies_ = 1. / (1 + (RDA / R0)**6.0)
71 def _update_lookup(self):
72 self._d_mean_ = np.empty_like(self._distances_)
73 self._d_mean_fret_ = np.empty_like(self._distances_)
74 self._e_mean_ = np.empty_like(self._distances_)
75 for i, d
in enumerate(self._distances_):
76 self._update_density(d, self._sigma_)
77 self._d_mean_[i] = self.calc_distance_mean()
78 self._d_mean_fret_[i] = self.calc_distance_mean_fret()
79 self._e_mean_[i] = self.calc_fret_efficiency_mean()
81 def _update_density(self, dcc: float, w: float):
82 """Update the distance distribution
84 @param dcc center-to-center distance
85 @param w parameter controlling the distribution width
88 n1 = scipy.stats.norm(-dcc, w)
89 n2 = scipy.stats.norm(dcc, w)
90 p = n1.pdf(d) + n2.pdf(d)
95 def dist_center_center(self):
96 return self._dist_center_center_
98 @dist_center_center.setter
99 def dist_center_center(self, v):
100 self._dist_center_center_ = v
107 def sigma(self, v: float):
109 self._update_lookup()
112 def forster_radius(self):
113 return self._forster_radius_
115 @forster_radius.setter
116 def forster_radius(self, v: float):
117 self._forster_radius_ = v
118 self._update_fret_efficiencies_(v)
119 self._update_lookup()
121 def calc_distance_mean(self):
126 def calc_fret_efficiency_mean(self):
128 v = self._fret_efficiencies_
131 def calc_distance_mean_fret(self):
132 E = self.calc_fret_efficiency_mean()
133 R0 = self.forster_radius
134 return R0 * (1. / E - 1.)**(1. / 6.)
137 def fret_efficiency_mean(self):
138 return np.interp(self.dist_center_center, self._distances_, self._e_mean_)
141 def distance_mean(self):
142 return np.interp(self.dist_center_center, self._distances_, self._d_mean_)
145 def distance_mean_fret(self):
146 return np.interp(self.dist_center_center, self._distances_, self._d_mean_fret_)
148 def __call__(self, value: float, distance_type: int):
149 self.dist_center_center = value
150 if distance_type == IMP.bff.DYE_PAIR_DISTANCE_MEAN:
151 return self.distance_mean
152 elif distance_type == IMP.bff.DYE_PAIR_DISTANCE_E:
153 return self.distance_mean_fret
154 elif distance_type == IMP.bff.DYE_PAIR_DISTANCE_MP:
159 forster_radius: float = 52.0,
161 distance_range: typing.Tuple[float, float] = (1.0, 100.0),
162 n_distances: int = 128
164 self._forster_radius_ = forster_radius
166 self._distances_ = np.linspace(*distance_range, n_distances, dtype=np.float64)
167 self._density_ = np.zeros_like(self._distances_)
168 self._update_fret_efficiencies_(self._forster_radius_)
169 self._update_lookup()
173 """Read a xlink table
175 :param fn: filename of the xlink table
181 with open(fn,
'r') as fp:
182 lines = fp.readlines()
183 for line
in lines[1:]:
186 protein_1, residue_1, protein_2, residue_2 = line.split(
',')
187 residue_1 = int(residue_1)
188 residue_2 = int(residue_2)
190 'protein_1': protein_1,
191 'protein_2': protein_2,
192 'residue_1': residue_1,
193 'residue_2': residue_2
195 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.