IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
pdb2density.py
1## \example em/pdb2density.py
2# A simple example showing how to simulate density from a protein.
3# IMP uses a Gaussian smoothing kernel. see SampledDensityMap::resample
4# for documentation.
5#
6
7import IMP.em
8import IMP.core
9import IMP.atom
10import sys
11
12IMP.setup_from_argv(sys.argv, "pdb2density")
13
14m = IMP.Model()
15# read protein
17mh = IMP.atom.read_pdb(IMP.em.get_example_path("input.pdb"), m, sel)
18# add radius info to each atom, otherwise the resampling would fail.
21# decide on resolution and spacing you would like to simulate to
22resolution = 10.
23apix = 1.5
24dmap = IMP.em.particles2density(ps, resolution, apix)
25# write out the map in the favorite format (xplor, mrc, em and spider are
26# supported)
27IMP.em.write_map(dmap, "example.mrc", IMP.em.MRCReaderWriter())
Class for storing model, its restraints, constraints, and particles.
Definition Model.h:111
Select all non-water non-alternative ATOM and HETATM records.
Definition pdb.h:362
void write_map(DensityMap *m, std::string filename, MapReaderWriter *writer)
Write a density map to a file using the given writer.
Functionality for loading, creating, manipulating and scoring atomic structures.
void add_radii(Hierarchy d, const ForceFieldParameters *ffp=get_all_atom_CHARMM_parameters(), FloatKey radius_key=FloatKey("radius"))
Add vdW radius from given force field.
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.
Basic functionality that is expected to be used by a wide variety of IMP users.
GenericHierarchies get_leaves(Hierarchy mhd)
Get all the leaves of the bit of hierarchy.
Basic utilities for handling cryo-electron microscopy 3D density maps.
std::string get_example_path(std::string file_name)
Return the full path to one of this module's example files.
SampledDensityMap * particles2density(const ParticlesTemp &ps, Float resolution, Float apix, int sig_cutoff=3, const FloatKey &weight_key=IMP::atom::Mass::get_mass_key())
Resample a set of particles into a density grid.
void setup_from_argv(int argc, char **argv, std::string description)
Parse the command line flags and return the positional arguments.