2 from __future__
import division
4 __doc__ =
'Build initial parameters files.'
8 from IMP
import OptionParser
12 usage =
"""%prog [options] <assembly name> <subunits file>
13 <coarse level> <density map> <resolution> <spacing> <density threshold>
14 <origin X> <origin Y> <origin Z>
16 Build the parameters files for MultiFit.
18 Notice: If you have negative numbers as input, add -- as the first parameter,
19 so that the numbers are not treated as options."""
21 parser = OptionParser(usage)
22 parser.add_option(
"-i",
"--asmb_input", dest=
"asmb_input",
24 help=
"the name of the MultiFit input file. The default "
25 "filename is asmb.input")
26 parser.add_option(
"-m",
"--model", dest=
"model", default=
"asmb.model",
27 help=
"the base filename of the solutions output by "
28 "MultiFit (.X.pdb, where X is the solution number, "
29 "is suffixed to create each output file name). "
30 "The default filename is asmb.model")
31 parser.add_option(
"-a",
"--anchor_dir", dest=
"anchor_dir", default=
"./",
32 help=
"the name of the directory to store anchor points. "
34 parser.add_option(
"-f",
"--fit_dir", dest=
"fit_dir", default=
"./",
35 help=
"the name of the directory to store fitting "
36 "solutions. The default is ./")
37 (options, args) = parser.parse_args()
39 parser.error(
"incorrect number of arguments")
43 def get_density_data(name, density_fn, resolution, spacing, threshold,
44 origin, anchor_dir_name, fit_dir_name):
47 msg = sd.get_density_header_line()
48 msg += density_fn +
"|" + str(resolution) +
"|" + str(spacing) +
"|" + str(
49 threshold) +
"|" + str(origin[0]) +
"|" + str(origin[1]) +
"|" + str(origin[2])
50 msg +=
"|" + anchor_dir_name + name +
"_em_coarse_anchors.txt|" + \
51 anchor_dir_name + name +
"_em_coarse_anchors_FINE.txt|"
52 msg += anchor_dir_name + name +
"_em_fine_anchors.txt|" + \
53 anchor_dir_name + name +
"_em_fine_anchors_FINE.txt|\n"
66 msg = sd.get_component_header_line()
68 with open(pdb_list)
as fh:
69 for i, fnn
in enumerate(fh):
70 name = fnn[:-1].split()[0]
71 fn = fnn[:-1].split()[1]
72 surface_fn = fnn[:-1].split()[1] +
".ms"
75 num_anchors = len(IMP.atom.get_by_type(mh,
76 IMP.atom.RESIDUE_TYPE)) // coarse_level
77 msg += name +
"|" + fn +
"|" + surface_fn +
"|" + \
78 anchor_dir_name + name +
"_anchors.txt|" + \
79 str(num_anchors) +
"|"
80 msg += anchor_dir_name + name +
"_fine_anchors.txt|" + \
81 str(len(IMP.atom.get_by_type(mh, IMP.atom.RESIDUE_TYPE)))
82 msg +=
"|" + fit_dir_name + name + fit_fn_header +
"|"
84 msg = msg + fn +
"|\n"
90 def create_alignment_param_file(asmb_name, coarse_level):
93 asmb_name +
".alignment.param")
95 asmb_name +
".alignment.param.refined")
98 def create_assembly_input_file(
99 pdb_list, coarse_level, anchor_dir, fit_dir, asmb_name,
100 density_map_fn, resolution, spacing, threshold,
103 fit_fn_header=
"_fitting.txt",
104 add_reference_fn=
False):
107 msg = msg + get_protein_data(
114 msg = msg + get_density_data(
115 asmb_name, density_map_fn, resolution, spacing,
116 threshold, origin, anchor_dir, fit_dir)
117 f = open(asmb_input_fn,
"w")
122 msg = msg + get_protein_data(
127 fit_fn_header +
".refined",
129 msg = msg + get_density_data(
130 asmb_name, density_map_fn, resolution, spacing,
131 threshold, origin, anchor_dir, fit_dir)
132 f = open(asmb_input_fn +
".refined",
"w")
138 options, args = parse_args()
141 coarse_level = int(args[2])
142 anchor_dir = options.anchor_dir
143 fit_dir = options.fit_dir
144 if not anchor_dir[-1] ==
"/":
146 if not fit_dir[-1] ==
"/":
149 density_map_fn = args[3]
150 resolution = float(args[4])
153 origin = [float(args[7]), float(args[8]), float(args[9])]
154 create_assembly_input_file(
155 pdb_list, coarse_level, anchor_dir, fit_dir, asmb_name,
156 density_map_fn, resolution, spacing, threshold,
157 origin, options.asmb_input)
159 create_alignment_param_file(asmb_name, coarse_level)
162 if __name__ ==
"__main__":
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
Fitting atomic structures into a cryo-electron microscopy density map.
Holds header data for optimization.
std::string get_data_path(std::string file_name)
Return the full path to one of this module's data files.