IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
plot_AVScreening.py
1"""
2Scoring of structures
3=====================
4This examples illustrates how to use ``IMP.bff.AVNetworkRestraint`` for
5scoring structures in a trajectory.
6"""
7import json
8import pylab as plt
9
10import RMF
11import IMP
12import IMP.rmf
13import IMP.atom
14import IMP.bff
15
16try:
17 from tqdm import tqdm
18except ImportError:
19 def tqdm(x): return x
20
21# %%
22# Load an RMF file and create a hierarchy
23print("Creating IMP Model")
24m = IMP.Model()
25rmf_fn = IMP.bff.get_example_path("structure/T4L/t4l_docking.rmf3")
26
27print("Loading RMF")
28frame_index = 0
29f = RMF.open_rmf_file_read_only(rmf_fn)
30hier = IMP.rmf.create_hierarchies(f, m)[frame_index]
31IMP.rmf.load_frame(f, RMF.FrameID(frame_index))
32
33# %%
34# Load fps.json file and create restraint for scoring
35print("Creating FRET restraint")
36fps_json_path = IMP.bff.get_example_path("structure/T4L/fret.fps.json")
37with open(fps_json_path) as fp:
38 fps_json = json.load(fp)
39score_set_c1 = "chi2_C1_33p"
40fret_restraint = IMP.bff.AVNetworkRestraint(
41 hier, fps_json_path,
42 score_set=score_set_c1
43)
44v = fret_restraint.unprotected_evaluate(None)
45
46# %%
47# Score each frame in the RMF file and plot score
48print("Scoring frames")
49scores = list()
50for frame in tqdm(f.get_root_frames()):
51 IMP.rmf.load_frame(f, frame)
52 v = fret_restraint.unprotected_evaluate(None)
53 scores.append(v)
54
55# %%
56# Plot score for each frame
57plt.plot(scores, "o-")
58plt.xlabel("Frame")
59plt.ylabel("Score")
60print("See plot.png for score for each frame")
61plt.savefig('plot.png')
62#plt.show()
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
A restraint that uses an annotated volumetric network to score particle distances.
Functionality for loading, creating, manipulating and scoring atomic structures.
Bayesian Fluorescence Framework.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Support for the RMF file format for storing hierarchical molecular data and markup.
atom::Hierarchies create_hierarchies(RMF::FileConstHandle fh, Model *m)
void load_frame(RMF::FileConstHandle file, RMF::FrameID frame)
Load the given RMF frame into the state of the linked objects.