3 __doc__ =
"Score each of a set of combinations."
7 from optparse
import OptionParser
11 colors[
"Rpt1"]=[0.78,0.78,0.73]
12 colors[
"Rpt2"]=[0.78,0.66,0.58]
13 colors[
"Rpt3"]=[0.77,0.43,0.5]
14 colors[
"Rpt4"]=[0.76,0.29,0.67]
15 colors[
"Rpt5"]=[0.51,0.14,0.75]
16 colors[
"Rpt6"]=[0.0,0.,0.75]
17 colors[
"Rpn1"]=[0.34,0.36,0.27]
18 colors[
"Rpn2"]=[0.42,0.43,0.36]
19 colors[
"Rpn3"]=[0.49,0.5,0.44]
20 colors[
"Rpn5"]=[0.56,0.57,0.51]
21 colors[
"Rpn6"]=[0.64,0.64,0.59]
22 colors[
"Rpn7"]=[0.71,0.71,0.66]
23 colors[
"Rpn8"]=[0.78,0.78,0.74]
24 colors[
"Rpn9"]=[1,0,0]
25 colors[
"Rpn10"]=[0,1,0]
26 colors[
"Rpn11"]=[0,0,1]
27 colors[
"Rpn12"]=[0.5,0.2,0.4]
28 colors[
"a1"]=[0.78,0.78,0.73]
29 colors[
"a2"]=[0.78,0.66,0.58]
30 colors[
"a3"]=[0.77,0.43,0.5]
31 colors[
"a4"]=[0.76,0.29,0.67]
32 colors[
"a5"]=[0.51,0.14,0.75]
33 colors[
"a6"]=[0.0,0.,0.75]
34 colors[
"a7"]=[0.34,0.36,0.27]
35 colors[
"a8"]=[0.42,0.43,0.36]
36 colors[
"a9"]=[0.49,0.5,0.44]
37 colors[
"a10"]=[0.56,0.57,0.51]
39 colors[
"a11"]=[0.78,0.78,0.73]
40 colors[
"a12"]=[0.78,0.66,0.58]
41 colors[
"a13"]=[0.77,0.43,0.5]
42 colors[
"a14"]=[0.76,0.29,0.67]
43 colors[
"a15"]=[0.51,0.14,0.75]
44 colors[
"a16"]=[0.0,0.,0.75]
45 colors[
"a17"]=[0.34,0.36,0.27]
46 colors[
"a18"]=[0.42,0.43,0.36]
47 colors[
"a19"]=[0.49,0.5,0.44]
48 colors[
"a20"]=[0.56,0.57,0.51]
51 colors[
"a21"]=[0.78,0.78,0.73]
52 colors[
"a22"]=[0.78,0.66,0.58]
53 colors[
"a23"]=[0.77,0.43,0.5]
54 colors[
"a24"]=[0.76,0.29,0.67]
55 colors[
"a25"]=[0.51,0.14,0.75]
56 colors[
"a26"]=[0.0,0.,0.75]
57 colors[
"a27"]=[0.34,0.36,0.27]
58 colors[
"a28"]=[0.42,0.43,0.36]
59 colors[
"a29"]=[0.49,0.5,0.44]
60 colors[
"a30"]=[0.56,0.57,0.51]
64 def decompose(dmap,mhs):
69 full_sampled_map.set_particles(all_ps)
70 full_sampled_map.resample()
71 full_sampled_map.calcRMS()
72 upper=(dmap.get_number_of_voxels()*dmap.get_header().dmean*full_sampled_map.get_header().dmean)/len(mhs)
73 lower=dmap.get_number_of_voxels()*dmap.get_header().rms*full_sampled_map.get_header().rms
74 norm_factors=[upper,lower]
75 print "===============my norm factors:",upper,lower
79 def score_each_protein(dmap,mhs,sd):
80 norm_factors=decompose(dmap,mhs)
83 mdl=mhs[0].get_model()
84 for i
in range(len(mhs)):
88 mh_dmap.set_particles(leaves)
96 mh_scores.append(cc.cross_correlation_coefficient(dmap,mh_dmap,0.,
False,norm_factors))
98 scores.append(mh_scores)
99 print "=====mol",i,mh_scores
103 usage =
"""%prog [options] <asmb> <asmb.proteomics> <asmb.mapping>
104 <alignment.params> <combinatins> <score combinations [output]>
106 Score each of a set of combinations.
109 parser.add_option(
"-m",
"--max", dest=
"max",default=999999999,
110 help=
"maximum number of fits considered")
111 (options, args) = parser.parse_args()
113 parser.error(
"incorrect number of arguments")
114 return [options,args]
116 def run(asmb_fn,proteomics_fn,mapping_fn,params_fn,combs_fn,
117 scored_comb_output_fn,max_comb):
120 dmap.get_header().set_resolution(asmb.get_assembly_header().get_resolution())
121 dmap.update_voxel_size(asmb.get_assembly_header().get_spacing())
122 dmap.set_origin(asmb.get_assembly_header().get_origin())
123 threshold=asmb.get_assembly_header().get_threshold()
126 colors=get_color_map()
129 alignment_params = IMP.multifit.AlignmentParams(params_fn)
130 alignment_params.show()
133 print "=========",combs_fn
142 em_anchors = mapping_data.get_anchors()
144 ensmb=IMP.multifit.Ensemble(asmb,mapping_data)
147 align=IMP.multifit.ProteomicsEMAlignmentAtomic(mapping_data,asmb,alignment_params)
148 align.set_fast_scoring(
False)
150 mdl=align.get_model()
151 mhs=align.get_molecules()
152 align.add_states_and_filters()
153 rbs=align.get_rigid_bodies()
155 align.set_density_map(dmap,threshold)
157 for i,mh
in enumerate(mhs):
158 ensmb.add_component_and_fits(mh,
161 rgb=colors[mh.get_name()]
166 for p in IMP.core.get_leaves(mh):
167 g= IMP.display.XYZRGeometry(p)
175 align.add_all_restraints()
177 print "Get number of restraints:",len(mdl.get_restraints())
178 rs=mdl.get_restraints()
179 for r
in mdl.get_restraints():
180 rr=IMP.RestraintSet.get_from(r)
181 for i
in range(rr.get_number_of_restraints()):
182 print rr.get_restraint(i).get_name()
183 output = open(scored_comb_output_fn,
"w")
187 for i
in range(asmb.get_number_of_component_headers()):
188 c=asmb.get_component_header(i)
189 fn=c.get_reference_fn()
194 rr=IMP.RestraintSet.get_from(r)
195 for i
in range(rr.get_number_of_restraints()):
196 output.write(rr.get_restraint(i).get_name()+
"|")
200 mdl.add_restraint(fitr)
201 print "Number of combinations:",len(combs[:max_comb])
206 rr=IMP.RestraintSet.get_from(r)
207 for j
in range(rr.get_number_of_restraints()):
208 print rr.get_restraint(j).get_name(),rr.evaluate(
False)
211 for i,comb
in enumerate(combs[:max_comb]):
212 print "Scoring combination:",comb
213 ensmb.load_combination(comb)
216 rr=IMP.RestraintSet.get_from(r)
217 for j
in range(rr.get_number_of_restraints()):
218 print rr.get_restraint(j).get_name()
219 rscore=rr.evaluate(
False)
221 num_violated=num_violated+1
223 print str(all_leaves[0])+
" :: " + str(all_leaves[-1])
224 score=mdl.evaluate(
None)
226 msg=
"COMB"+str(i)+
"|"
228 rr=IMP.RestraintSet.get_from(r)
229 for j
in range(rr.get_number_of_restraints()):
230 current_name=rr.get_restraint(j).get_name()
231 if current_name!=prev_name:
232 msg+=
' '+current_name+
' '
233 prev_name=current_name
234 rscore=rr.get_restraint(j).evaluate(
False)
237 num_violated=num_violated+1
239 msg+=
"|"+str(score)+
"|"+str(num_violated)+
"||||"+str(fitr.evaluate(
None))+
"||:"
242 IMP.core.XYZs(all_ref_leaves)))
243 output.write(msg+
"\n")
245 ensmb.unload_combination(comb)
249 (options,args) = usage()
250 run(args[0],args[1],args[2],args[3],args[4],args[5],int(options.max))
252 if __name__==
"__main__":