3 from __future__
import print_function
6 from IMP
import ArgumentParser
8 __doc__ =
"Write assembly transformation file in other formats."
10 class Formatter(object):
15 def write_header(self, settings):
19 class ChimeraFormatter(Formatter):
21 """Each line in 'chimera' format lists the transformation index, the
22 cross correlation score, and then the transformation for each component,
23 as a rotation matrix (row-major order) and a translation in angstroms."""
25 def write_line(self, ind, score, transforms):
26 self.fh.write(str(ind) +
"\t" + score +
"\t")
29 v = t.get_rotation().get_rotation_matrix_row(k)
31 str(v[0]) +
" " + str(v[1]) +
" " + str(v[2]) +
" ")
32 v = t.get_translation()
34 str(v[0]) +
" " + str(v[1]) +
" " + str(v[2]) +
" | ")
38 class DockRefFormatter(Formatter):
40 """Each line in 'dockref' format lists the transformation for each component,
41 as a set of three Euler angles (in radians about the fixed x, y and z axes)
42 and a translation in angstroms."""
44 def write_header(self, sd):
46 for i
in range(sd.get_number_of_component_headers()):
47 self.fh.write(sd.get_component_header(i).get_name() +
"|")
50 def write_line(self, ind, score, transforms):
53 tr = t.get_translation()
55 self.fh.write(
"%.6g %.6g %.6g %.6g %.6g %.6g|"
56 % (eulers.get_x(), eulers.get_y(), eulers.get_z(),
61 formatters = {
'chimera': ChimeraFormatter,
62 'dockref': DockRefFormatter}
67 Write assembly transformation file in other formats.
69 """ +
"\n\n".join(x.__doc__
for x
in formatters.values())
71 p = ArgumentParser(description=desc)
72 p.add_argument(
"-f",
"--format", default=
'chimera',
73 choices=list(formatters.keys()),
74 help=
"type of output to generate ("
75 +
", ".join(formatters.keys())
76 +
"; default: chimera)")
77 p.add_argument(
"assembly_file", help=
"assembly file name")
78 p.add_argument(
"combinations_file", help=
"combinations file name")
79 p.add_argument(
"output_file", help=
"output file name")
83 def run(asmb_fn, combs_fn, fmt):
89 for i
in range(sd.get_number_of_component_headers()):
90 fn = sd.get_component_header(i).get_transformations_fn()
92 for ind, line
in enumerate(open(combs_fn)):
96 fmt.write_line(ind, score,
97 [fits[i][int(c)].get_fit_transformation()
98 for i, c
in enumerate(comb.split())])
103 fmt = formatters[args.format](open(args.output_file,
'w'))
104 run(args.assembly_file, args.combinations_file, fmt)
106 if __name__ ==
"__main__":
SettingsData * read_settings(const char *filename)
FixedXYZ get_fixed_xyz_from_rotation(const Rotation3D &r)
The inverse of rotation_from_fixed_xyz()
Fitting atomic structures into a cryo-electron microscopy density map.
FittingSolutionRecords read_fitting_solutions(const char *fitting_fn)
Fitting solutions reader.
def __init__
Set up a new graphXL object.