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
42 """ Simply creates IMP particles from a set of 2D points
43 model - is the model to store the particles
55 def get_particles_from_vector3ds(vs, model):
67 """ Writes a set of particles with coordinates to a file """
69 f_output = open(fn_output,
"w")
70 f_output.write(io.imp_info([IMP,
IMP.em2d]))
72 f_output.write(get_common_title())
74 x, y, z = xyz.get_coordinates()
75 f_output.write(
"%8.3f %8.3f %8.3f\n" % (x, y, z))
80 """ writes a text files in the format required
81 for point alignment in multifit2
88 ap = mfit.AnchorsData(vs, edges)
89 mfit.write_txt(fn_output, ap)
92 def get_common_title():
93 return "# coordinates x | y | z\n"
99 Parseable output for a IMP Transformation3D
102 def __init__(self, T, delimiter="|"):
103 q = T.get_rotation().get_quaternion()
104 tr = T.get_translation()
105 self.rot_text = delimiter.join([str(i)
for i
in q])
106 self.tr_text = delimiter.join([str(i)
for i
in tr])
107 self.delimiter = delimiter
110 return self.delimiter.join([self.rot_text, self.tr_text])
113 class TextToTransformation3D:
115 def __init__(self, text, delimiter="|"):
116 vals = [float(x)
for x
in text.split(delimiter)]
118 raise ValueError(
"The text is not a transformation", vals)
123 def get_transformation(self):
130 Transform a IMP reference frame into parseable output
133 def __init__(self, ref, delimiter="|"):
134 T = ref.get_transformation_to()
135 Transformation3DToText.__init__(self, T, delimiter)
138 class TextToReferenceFrame(TextToTransformation3D):
140 def __init__(self, text, delimiter="|"):
141 TextToTransformation3D.__init__(self, text, delimiter)
144 def get_reference_frame(self):
150 Read a file of IMP.algebra.Transformation3D. The it is assumed that the
151 transformations are the only thing contained in a line
159 T = TextToTransformation3D(l).get_transformation()
167 Write a file with the Transformation3Ds contained in Ts
178 Read the reference frames contained in a solutions file from sampling
179 n is the maximum number of ref frames to read.
180 NOTE: Currently the function returns only the reference frames and
181 discards the score, the first element of a row
184 x = min(n, len(rows))
186 for i, row
in enumerate(rows[0:x]):
187 refs = [TextToReferenceFrame(t).get_reference_frame()
for t
in row[1:]]
188 all_refs.append(refs)
194 Read the PDB files, apply reference frames to them, and write a pdb
200 for t, rb
in zip(refs_texts, rbs):
201 r = TextToReferenceFrame(t).get_reference_frame()
202 rb.set_reference_frame(r)
207 Returns text with the time and information about the modules employed
208 imp_modules is the set of modules whose infos are requested
212 if(imp_modules
is None):
218 versions = [p.get_module_version()
for p
in imp_modules]
219 text =
"# " + tt +
"\n"
223 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).
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 ...
def get_particles_from_points
Simply creates IMP particles from a set of 2D points model - is the model to store the particles...
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 model particles.
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()