1 """@namespace IMP.EMageFit.imp_general.io
2 Utility functions to handle IO.
5 from __future__
import print_function
15 log = logging.getLogger(
"io")
18 def get_vectors_from_points(points, vector_type="2d"):
19 if vector_type ==
"2d":
21 elif vector_type ==
"3d":
24 raise ValueError(
"vector type not recognized")
28 """ Simply creates IMP particles from a set of 2D points
29 model - is the model to store the particles
41 def get_particles_from_vector3ds(vs, model):
53 """ Writes a set of particles with coordinates to a file """
55 f_output = open(fn_output,
"w")
58 f_output.write(get_common_title())
60 x, y, z = xyz.get_coordinates()
61 f_output.write(
"%8.3f %8.3f %8.3f\n" % (x, y, z))
66 """ writes a text files in the format required
67 for point alignment in multifit2
74 ap = mfit.AnchorsData(vs, edges)
75 mfit.write_txt(fn_output, ap)
78 def get_common_title():
79 return "# coordinates x | y | z\n"
85 Parseable output for a IMP Transformation3D
88 def __init__(self, T, delimiter="|"):
89 q = T.get_rotation().get_quaternion()
90 tr = T.get_translation()
91 self.rot_text = delimiter.join([str(i)
for i
in q])
92 self.tr_text = delimiter.join([str(i)
for i
in tr])
93 self.delimiter = delimiter
96 return self.delimiter.join([self.rot_text, self.tr_text])
99 class TextToTransformation3D:
101 def __init__(self, text, delimiter="|"):
102 vals = [float(x)
for x
in text.split(delimiter)]
104 raise ValueError(
"The text is not a transformation", vals)
109 def get_transformation(self):
116 Transform a IMP reference frame into parseable output
119 def __init__(self, ref, delimiter="|"):
120 T = ref.get_transformation_to()
121 Transformation3DToText.__init__(self, T, delimiter)
124 class TextToReferenceFrame(TextToTransformation3D):
126 def __init__(self, text, delimiter="|"):
127 TextToTransformation3D.__init__(self, text, delimiter)
130 def get_reference_frame(self):
136 Read a file of IMP.algebra.Transformation3D. The it is assumed that the
137 transformations are the only thing contained in a line
145 T = TextToTransformation3D(line).get_transformation()
153 Write a file with the Transformation3Ds contained in Ts
164 Read the reference frames contained in a solutions file from sampling
165 n is the maximum number of ref frames to read.
166 NOTE: Currently the function returns only the reference frames and
167 discards the score, the first element of a row
170 x = min(n, len(rows))
172 for i, row
in enumerate(rows[0:x]):
173 refs = [TextToReferenceFrame(t).get_reference_frame()
for t
in row[1:]]
174 all_refs.append(refs)
180 Read the PDB files, apply reference frames to them, and write a pdb
186 for t, rb
in zip(refs_texts, rbs):
187 r = TextToReferenceFrame(t).get_reference_frame()
188 rb.set_reference_frame(r)
194 Returns text with the time and information about the modules employed
195 imp_modules is the set of modules whose infos are requested
199 if imp_modules
is None:
202 versions = [p.get_module_version()
for p
in imp_modules]
203 text =
"# " + tt +
"\n"
205 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.