1 """@namespace IMP.EMageFit.imp_general.io
2 Utility functions to handle IO.
14 log = logging.getLogger(
"io")
17 def get_vectors_from_points(points, vector_type="2d"):
18 if vector_type ==
"2d":
20 elif vector_type ==
"3d":
23 raise ValueError(
"vector type not recognized")
27 """ Simply creates IMP particles from a set of 2D points
28 model - is the model to store the particles
40 def get_particles_from_vector3ds(vs, model):
52 """ Writes a set of particles with coordinates to a file """
54 f_output = open(fn_output,
"w")
57 f_output.write(get_common_title())
59 x, y, z = xyz.get_coordinates()
60 f_output.write(
"%8.3f %8.3f %8.3f\n" % (x, y, z))
65 """ writes a text files in the format required
66 for point alignment in multifit2
73 ap = mfit.AnchorsData(vs, edges)
74 mfit.write_txt(fn_output, ap)
77 def get_common_title():
78 return "# coordinates x | y | z\n"
84 Parseable output for a IMP Transformation3D
87 def __init__(self, T, delimiter="|"):
88 q = T.get_rotation().get_quaternion()
89 tr = T.get_translation()
90 self.rot_text = delimiter.join([str(i)
for i
in q])
91 self.tr_text = delimiter.join([str(i)
for i
in tr])
92 self.delimiter = delimiter
95 return self.delimiter.join([self.rot_text, self.tr_text])
98 class TextToTransformation3D:
100 def __init__(self, text, delimiter="|"):
101 vals = [float(x)
for x
in text.split(delimiter)]
103 raise ValueError(
"The text is not a transformation", vals)
108 def get_transformation(self):
115 Transform a IMP reference frame into parseable output
118 def __init__(self, ref, delimiter="|"):
119 T = ref.get_transformation_to()
120 Transformation3DToText.__init__(self, T, delimiter)
123 class TextToReferenceFrame(TextToTransformation3D):
125 def __init__(self, text, delimiter="|"):
126 TextToTransformation3D.__init__(self, text, delimiter)
129 def get_reference_frame(self):
135 Read a file of IMP.algebra.Transformation3D. The it is assumed that the
136 transformations are the only thing contained in a line
144 T = TextToTransformation3D(line).get_transformation()
152 Write a file with the Transformation3Ds contained in Ts
163 Read the reference frames contained in a solutions file from sampling
164 n is the maximum number of ref frames to read.
165 NOTE: Currently the function returns only the reference frames and
166 discards the score, the first element of a row
169 x = min(n, len(rows))
171 for i, row
in enumerate(rows[0:x]):
172 refs = [TextToReferenceFrame(t).get_reference_frame()
for t
in row[1:]]
173 all_refs.append(refs)
179 Read the PDB files, apply reference frames to them, and write a pdb
185 for t, rb
in zip(refs_texts, rbs):
186 r = TextToReferenceFrame(t).get_reference_frame()
187 rb.set_reference_frame(r)
193 Returns text with the time and information about the modules employed
194 imp_modules is the set of modules whose infos are requested
198 if imp_modules
is None:
201 versions = [p.get_module_version()
for p
in imp_modules]
202 text =
"# " + tt +
"\n"
204 text +=
"# " + x +
"\n"
Parseable output for a IMP Transformation3D.
def write_particles_as_text
Writes a set of particles with coordinates to a file.
Restraints using electron microscopy 2D images (class averages).
def get_particles_from_points
Simply creates IMP particles from a set of 2D points model - is the model to store the particles...
static XYZR setup_particle(Model *m, ParticleIndex pi)
Utility functions to handle representation.
def write_vectors_in_multifit2_format
writes a text files in the format required for point alignment in multifit2
def create_rigid_bodies
set the children of a molecule type hierarchy as rigid bodies In this case, all the children are the ...
Transform a IMP reference frame into parseable output.
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
Class for storing model, its restraints, constraints, and particles.
def imp_info
Returns text with the time and information about the modules employed imp_modules is the set of modul...
def read_reference_frames
Read the reference frames contained in a solutions file from sampling n is the maximum number of ref ...
Fitting atomic structures into a cryo-electron microscopy density map.
def create_assembly
Read all the PDBs given in the list of names fn_pdbs and adds the hierarchies to the model...
Basic functionality that is expected to be used by a wide variety of IMP users.
General purpose algebraic and geometric methods that are expected to be used by a wide variety of IMP...
Class to handle individual particles of a Model object.
def read_transforms
Read a file of IMP.algebra.Transformation3D.
Functionality for loading, creating, manipulating and scoring atomic structures.
def write_transforms
Write a file with the Transformation3Ds contained in Ts.
def write_pdb_for_reference_frames
Read the PDB files, apply reference frames to them, and write a pdb.
std::string get_module_version()
Return the version of this module, as a string.