3 __doc__ =
'Build initial parameters files.'
7 from optparse
import OptionParser
10 usage =
"""%prog [options] <assembly name> <subunits file>
11 <coarse level> <density map> <resolution> <spacing> <density threshold>
12 <origin X> <origin Y> <origin Z>
14 Build the parameters files for MultiFit.
16 Notice: If you have negative numbers as input, add -- as the first parameter,
17 so that the numbers are not treated as options."""
20 parser.add_option(
"-i",
"--asmb_input", dest=
"asmb_input",
22 help=
"the name of the MultiFit input file. The default "
23 "filename is asmb.input")
24 parser.add_option(
"-m",
"--model", dest=
"model",default=
"asmb.model",
25 help=
"the base filename of the solutions output by "
26 "MultiFit (.X.pdb, where X is the solution number, "
27 "is suffixed to create each output file name). "
28 "The default filename is asmb.model")
29 parser.add_option(
"-a",
"--anchor_dir", dest=
"anchor_dir",default=
"./",
30 help=
"the name of the directory to store anchor points. "
32 parser.add_option(
"-f",
"--fit_dir", dest=
"fit_dir",default=
"./",
33 help=
"the name of the directory to store fitting "
34 "solutions. The default is ./")
35 (options, args) = parser.parse_args()
37 parser.error(
"incorrect number of arguments")
40 def get_density_data(name,density_fn,resolution,spacing,threshold,
41 origin,anchor_dir_name,fit_dir_name):
44 msg=sd.get_density_header_line()
45 msg+=density_fn+
"|"+str(resolution)+
"|"+str(spacing)+
"|"+str(threshold)+
"|"+str(origin[0])+
"|"+str(origin[1])+
"|"+str(origin[2])
46 msg+=
"|"+anchor_dir_name+name+
"_em_coarse_anchors.txt|"+anchor_dir_name+name+
"_em_coarse_anchors_FINE.txt|"
47 msg+=anchor_dir_name+name+
"_em_fine_anchors.txt|"+anchor_dir_name+name+
"_em_fine_anchors_FINE.txt|\n"
50 def get_protein_data(pdb_list,coarse_level,anchor_dir_name,fit_dir_name,fit_fn_header,add_reference_fn):
53 msg=sd.get_component_header_line()
55 for i,fnn
in enumerate(open(pdb_list)):
56 name=fnn[:-1].split()[0]
57 fn=fnn[:-1].split()[1]
58 surface_fn=fnn[:-1].split()[1]+
".ms"
62 msg+=name+
"|"+fn+
"|"+surface_fn+
"|"+anchor_dir_name+name+
"_anchors.txt|"+str(num_anchors)+
"|"
63 msg+=anchor_dir_name+name+
"_fine_anchors.txt|"+str(len(
IMP.atom.get_by_type(mh,IMP.atom.RESIDUE_TYPE)))
64 msg+=
"|"+fit_dir_name+name+fit_fn_header+
"|"
71 def create_alignment_param_file(asmb_name,coarse_level):
74 asmb_name +
".alignment.param")
76 asmb_name +
".alignment.param.refined")
78 def create_assembly_input_file(pdb_list,coarse_level,anchor_dir,fit_dir,asmb_name,
79 density_map_fn,resolution,spacing,threshold,
82 fit_fn_header=
"_fitting.txt",
83 add_reference_fn=
False):
86 msg=msg+get_protein_data(pdb_list,coarse_level,anchor_dir,fit_dir,fit_fn_header,add_reference_fn)
87 msg=msg+get_density_data(asmb_name,density_map_fn,resolution,spacing,
88 threshold,origin,anchor_dir,fit_dir)
89 f=open(asmb_input_fn,
"w")
94 msg=msg+get_protein_data(pdb_list,coarse_level,anchor_dir,fit_dir,fit_fn_header+
".refined",add_reference_fn)
95 msg=msg+get_density_data(asmb_name,density_map_fn,resolution,spacing,
96 threshold,origin,anchor_dir,fit_dir)
97 f=open(asmb_input_fn+
".refined",
"w")
102 options,args = parse_args()
105 coarse_level=int(args[2])
106 anchor_dir=options.anchor_dir
107 fit_dir=options.fit_dir
108 if not anchor_dir[-1] ==
"/":
110 if not fit_dir[-1] ==
"/":
113 density_map_fn = args[3]
114 resolution=float(args[4])
117 origin=[float(args[7]),float(args[8]),float(args[9])]
118 create_assembly_input_file(pdb_list,coarse_level,anchor_dir,fit_dir,asmb_name,
119 density_map_fn,resolution,spacing,threshold,
120 origin, options.asmb_input)
122 create_alignment_param_file(asmb_name,coarse_level)
125 if __name__==
"__main__":