MCPcopy Create free account
hub / github.com/BioinfoMachineLearning/FlowDock / from_prediction

Function from_prediction

flowdock/utils/visualization_utils.py:244–284  ·  view source on GitHub ↗

Assembles a protein from a prediction. Args: features: Dictionary holding model inputs. result: Dictionary holding model outputs. b_factors: (Optional) B-factors to use for the protein. remove_leading_feature_dimension: Whether to remove the leading dimension of

(
    features: FeatureDict,
    result: ModelOutput,
    b_factors: Optional[np.ndarray] = None,
    remove_leading_feature_dimension: bool = False,
)

Source from the content-addressed store, hash-verified

242
243
244def from_prediction(
245 features: FeatureDict,
246 result: ModelOutput,
247 b_factors: Optional[np.ndarray] = None,
248 remove_leading_feature_dimension: bool = False,
249) -> FDProtein:
250 """Assembles a protein from a prediction.
251
252 Args:
253 features: Dictionary holding model inputs.
254 result: Dictionary holding model outputs.
255 b_factors: (Optional) B-factors to use for the protein.
256 remove_leading_feature_dimension: Whether to remove the leading dimension
257 of the `features` values.
258
259 Returns:
260 A protein instance.
261 """
262 fold_output = result["structure_module"]
263
264 def _maybe_remove_leading_dim(arr: np.ndarray) -> np.ndarray:
265 return arr[0] if remove_leading_feature_dimension else arr
266
267 if "asym_id" in features:
268 chain_index = _maybe_remove_leading_dim(features["asym_id"])
269 else:
270 chain_index = np.zeros_like(_maybe_remove_leading_dim(features["aatype"]))
271
272 if b_factors is None:
273 b_factors = np.zeros_like(fold_output["final_atom_mask"])
274
275 return FDProtein(
276 letter_sequences=None,
277 aatype=_maybe_remove_leading_dim(features["aatype"]),
278 atom_positions=fold_output["final_atom_positions"],
279 atom_mask=fold_output["final_atom_mask"],
280 residue_index=_maybe_remove_leading_dim(features["residue_index"]),
281 chain_index=chain_index,
282 b_factors=b_factors,
283 atomtypes=None,
284 )
285
286
287def write_pdb_single(

Callers 2

write_pdb_singleFunction · 0.85
write_pdb_modelsFunction · 0.85

Calls 2

FDProteinClass · 0.90

Tested by

no test coverage detected