21 The scores to all potential cross linking partners. The score is the
22 fraction of distances of all path that are shorter or equal to the
26 The sum of scores to all potential cross linking partners. The score is the
27 fraction of distances of all path that are shorter or equal to the
40 :param simulation_grid_spacing:
41 :param min_points: the minimum number of points the the computed volume. If
42 there are less points the site is not accessible and the score will be
50 xlinks: typing.Dict[int, typing.Dict]
51 linker_length: float = 20.0
52 linker_width: float = 2.0
54 simulation_grid_spacing: float = 3.5
59 def compute_scores(self, **kwargs) -> XLinkScore:
60 linker_length = kwargs.get(
'linker_length', self.linker_length)
61 linker_width = kwargs.get(
'linker_width', self.linker_width)
62 radius = kwargs.get(
'radius', self.radius)
63 simulation_grid_spacing = kwargs.get(
'simulation_grid_spacing', self.simulation_grid_spacing)
64 verbose = kwargs.get(
'verbose', self.verbose)
65 min_points = kwargs.get(
'min_points', self.min_points)
66 obstacles = self.obstacles
69 for xlink_key
in self.xlinks:
70 xlink = self.xlinks[xlink_key]
71 protein_1 = xlink[
'protein_1']
72 protein_2 = xlink[
'protein_2']
73 residue_1 = xlink[
'residue_1']
74 residue_2 = xlink[
'residue_2']
75 attachment_idx_1 = np.where((obstacles[
'res_id'] == residue_1) & (obstacles[
'protein_name'] == protein_1))[0]
76 attachment_idx_2 = np.where((obstacles[
'res_id'] == residue_2) & (obstacles[
'protein_name'] == protein_2))[0]
78 for idx_1
in attachment_idx_1:
79 origin = obstacles[
'xyz'][idx_1]
80 for idx_2
in attachment_idx_2:
81 target = obstacles[
'xyz'][idx_2]
82 if np.linalg.norm(origin - target) > linker_length:
84 print(
"Eucledian distance > linker length")
85 x_links_scores.append(0.0)
88 obstacles=self.obstacles,
90 linker_length=linker_length,
91 linker_width=linker_width,
93 simulation_grid_spacing=simulation_grid_spacing
95 if len(np.array(av.points()).T) < min_points:
97 print(protein_1, residue_1,
"is not accessible")
98 x_links_scores.append(0.0)
101 print(
"Eucledian distance < linker length.. Testing surface distance")
105 dist_eq = np.linalg.norm(xyz.T - target, axis=1) + dist
106 shorter = np.sum(dist_eq < (linker_length + radius))
107 score = shorter / len(dist_eq)
108 x_links_scores.append(score)
109 indiviudal_scores = np.array(x_links_scores)
110 scores.append(indiviudal_scores)
111 total_score = indiviudal_scores.sum()
112 total_scores.append(total_score)
114 print(xlink_key,
":", xlink,
"score:", total_score)
116 'total': np.array(total_scores, dtype=np.float),
124 verbose: bool =
False,
125 xlink_settings_file: str =
'',
128 label: str =
'XLinkSurfaceDistance'
131 base_dir = pathlib.Path(xlink_settings_file).parent
132 with open(xlink_settings_file,
'r') as fp:
133 xlink_settings = json.load(fp)
134 if root_hier
is None:
137 model = root_hier.get_model()
144 keys, formats = list(zip(*OBSTACLES_KEYS_FORMATS))
145 obstacles = np.zeros(0, dtype={
150 self.obstacles = obstacles
152 self.linker_length = xlink_settings[
'linker_length']
153 self.linker_width = xlink_settings[
'linker_width']
154 self.radius = xlink_settings[
'radius']
155 self.simulation_grid_spacing = xlink_settings[
'simulation_grid_spacing']
156 self.min_points = xlink_settings[
'min_points']
157 self.verbose = verbose
158 xlink_file = xlink_settings[
'xlink_file']
159 if pathlib.Path(xlink_file).is_file():
163 elif (base_dir / xlink_file).is_file():
165 fn=str(base_dir / xlink_file)
168 raise FileNotFoundError(
"Could not find XL file %s" % xlink_file)
169 if pathlib.Path(rmf_file).is_file():
170 self.obstacles = get_obstacles(
173 name_map=self.name_map
176 self.rs.filename = xlink_settings_file
181 xlink_file: str =
'',
182 frame_index: int = 0,
186 if pathlib.Path(xlink_file).is_file():
190 if pathlib.Path(rmf_file).is_file():
191 self.obstacles = get_obstacles(
195 frame_index=frame_index,
196 name_map=self.name_map
198 return self.compute_scores(**kwargs)
200 def get_score(self) -> float:
201 total_score = float(np.sum(self()[
'total']))
Class for storing model, its restraints, constraints, and particles.
Classes to handle different kinds of restraints.
The standard decorator for manipulating molecular structures.
:param linker_length: :param linker_width: :param radius: :param simulation_grid_spacing: :param min_...
Basic functionality that is expected to be used by a wide variety of IMP users.
Functionality for loading, creating, manipulating and scoring atomic structures.
Support for the RMF file format for storing hierarchical molecular data and markup.
Bayesian Fluorescence Framework.