7 import IMP.em2d.imp_general.representation
as representation
14 log = logging.getLogger(
"restraints")
16 def get_connectivity_restraint(particles, distance=10.,
17 n_pairs=1, spring_constant=1):
19 Set a connectivity restraint for the leaves of a set of particles
21 The intended use is that the each particle is a hierarchy. Each
22 hierarchy contains leaves that are atoms, or particles
23 that are a coarse representation of a molecule
25 score = core.HarmonicUpperBoundSphereDistancePairScore(distance,
31 cr.set_particles(particles)
35 def get_em2d_restraint( assembly,
36 images_selection_file,
40 """ Sets a restraint for comparing the model to a set of EM images
42 model = assembly.get_model()
45 r = em2d.Em2DRestraint()
46 r.setup(sc, restraint_params)
47 names = em2d.read_selection_file(images_selection_file)
48 names = [base.get_relative_path(images_selection_file, x)
for x
in names]
49 log.debug(
"names of the images %s", names)
50 srw = em2d.SpiderImageReaderWriter()
51 imgs = em2d.read_images(names, srw)
54 ps = atom.get_leaves(assembly)
55 lsc = container.ListSingletonContainer(ps)
58 if (mode ==
"coarse"):
59 r.set_coarse_registration_mode(
True)
60 elif (mode ==
"fast"):
61 r.set_fast_mode(n_optimized)
62 elif(mode ==
"complete"):
65 raise ValueError(
"Em2DRestraint mode not recognized")