IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
plot_release_highlights_0_12_0.py
1"""
2========================================
3Release Highlights for IMP.bff 0.12.0
4========================================
5
6.. currentmodule:: IMP.bff
7
8We are pleased to announce the release of IMP.bff 0.12, which comes
9with many bug fixes and new features! We detail below a few of the major
10features of this release. For an exhaustive list of all the changes, please
11refer to the :ref:`release notes <changes_0_12>`.
12
13To install the latest version with conda::
14
15 conda install -c tpeulen imp.bff
16"""
17
18import pylab as plt
19import pathlib
20
21import IMP
22import IMP.core
23import IMP.atom
24import IMP.bff
25import IMP.em
26
27
28# %%
29# Path searches
30# -------------------------------------------------------
31#
32# The :class:`bff.PathMap` now supports A* and Djikstra path
33# searches to find. This means that optimal path between points
34# (e.g., for the surface accessible distances) for between
35# two points (A*) or multiple points (Djikstra)
36# can be searched.
37
38m = IMP.Model()
39pdb_fn = pathlib.Path(IMP.bff.get_example_path('structure')) / "T4L/3GUN.pdb"
40hier = IMP.atom.read_pdb(str(pdb_fn), m)
41
42sel = IMP.atom.Selection(hier)
43sel.set_chain_id('A')
44sel.set_residue_index(132)
45sel.set_atom_type(IMP.atom.AtomType('CB'))
46sel_particles = sel.get_selected_particles()
47labeled_p = IMP.core.XYZ(sel_particles[0])
48path_origin = labeled_p.get_coordinates()
49path_map_header_parameter = {
50 "max_path_length": 20.0,
51 "grid_spacing": 1.0,
52 "neighbor_radius": 2,
53 "obstacle_threshold": 1e-5
54}
55path_map_header = IMP.bff.PathMapHeader(**path_map_header_parameter)
56path_map_header.set_path_origin(path_origin)
57path_map = IMP.bff.PathMap(path_map_header)
58
59ps = [a.get_particle() for a in IMP.atom.get_leaves(hier)]
60path_map.set_particles(ps)
61path_map.sample_obstacles(extra_radius=0.0)
62path_map.update_tiles()
63start_idx = path_map.get_voxel_by_location(path_origin)
64path_map.find_path_dijkstra(start_idx, -1) # if the end_idx
65
66t = path_map.get_tiles()
67end_idx_1 = 829
68path_1 = t[end_idx_1].backtrack_to_path()
69
70end_idx_2 = 229
71path_2 = t[end_idx_2].backtrack_to_path()
72print(path_2)
73
74# %%
75# The most important attributes of tiles are the penalty and the cost
76# of visiting a tile (from the starting point). Additionally, a tile
77# has a density, e.g., used to implement weighted accessible volumes
78# and a set of other (user-defined) features that are stored in a
79# dictionary.
80bounds = 0.0, 30
81BFF_TILE_PENALTY = path_map.get_tile_values(IMP.bff.PM_TILE_PENALTY, (0, 1))
82PM_TILE_COST = path_map.get_tile_values(IMP.bff.PM_TILE_COST, bounds)
83PM_TILE_COST_DENSITY = path_map.get_tile_values(IMP.bff.PM_TILE_COST_DENSITY, bounds)
84
85plt.imshow(PM_TILE_COST_DENSITY[16])
86plt.savefig('plot1.png')
87#plt.show()
88
89#%%
90# These features are returned as three dimensional arrays.
91fig, axs = plt.subplots(1, 3, sharex=True)
92axs[0].imshow(BFF_TILE_PENALTY[16])
93axs[1].imshow(PM_TILE_COST[16])
94axs[2].imshow(PM_TILE_COST_DENSITY[16])
95plt.savefig('plot2.png')
96#plt.show()
97
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Select hierarchy particles identified by the biological name.
Definition Selection.h:76
Class to search path on grids.
Definition PathMap.h:45
A decorator for a particle with x,y,z coordinates.
Definition XYZ.h:30
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
Hierarchies get_leaves(const Selection &h)
Bayesian Fluorescence Framework.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
Basic functionality that is expected to be used by a wide variety of IMP users.
Basic utilities for handling cryo-electron microscopy 3D density maps.