3 __doc__ =
"Align proteomics graph with the EM map."
8 from IMP
import OptionParser
11 def __init__(self, minValue = 0, maxValue = 10, totalWidth=12):
15 self.span = maxValue - minValue
16 self.width = totalWidth
20 def updateAmount(self, newAmount = 0):
21 if newAmount < self.min: newAmount = self.min
22 if newAmount > self.max: newAmount = self.max
23 self.amount = newAmount
26 diffFromMin = float(self.amount - self.min)
27 percentDone = (diffFromMin / float(self.span)) * 100.0
28 percentDone = round(percentDone)
29 percentDone = int(percentDone)
32 allFull = self.width - 2
33 numHashes = (percentDone / 100.0) * allFull
34 numHashes = int(round(numHashes))
37 self.progBar =
"[" +
'#'*numHashes +
' '*(allFull-numHashes) +
"]"
40 percentPlace = (len(self.progBar) / 2) - len(str(percentDone))
41 percentString = str(percentDone) +
"%"
44 self.progBar = self.progBar[0:percentPlace] + percentString + self.progBar[percentPlace+len(percentString):]
47 return str(self.progBar)
51 usage =
"""%prog [options] <asmb> <asmb.proteomics> <asmb.mapping>
52 <alignment.params> <combinations[output]>
53 <Fitting scores[output]>
55 Align proteomics graph with the EM map.
58 parser.add_option(
"-m",
"--max", type=
"int", dest=
"max", default=999999999,
59 help=
"maximum number of fits considered")
61 options, args = parser.parse_args()
63 parser.error(
"incorrect number of arguments")
66 def report_solutions(asmb, mdl, mhs, dmap, mapping_data, combs,
67 combs_fn_output_fn, scored_comb_output_fn, max_comb):
70 for i,mh
in enumerate(mhs):
71 fn = asmb.get_component_header(i).get_transformations_fn()
72 ensmb.add_component_and_fits(mh,
79 all_leaves=all_leaves+s1.get_selected_particles();
80 print "number of leaves:",len(all_leaves)
81 print "Get number of restraints:",len(mdl.get_restraints())
82 pb=progressBar(0,len(combs))
84 mdl.add_restraint(fitr)
87 print "going to calculate fits for:",len(combs)
88 for i,comb
in enumerate(combs):
91 ensmb.load_combination(comb)
92 ranked_combs.append([comb,fitr.evaluate(
False)])
93 ensmb.unload_combination(comb)
98 ranked_combs.sort(
lambda a,b: cmp(a[1], b[1]))
100 print "ranked combs:",len(ranked_combs)
101 ranked_combs[max_comb:] = []
102 print "ranked combs:",len(ranked_combs)
103 for comb
in ranked_combs:
104 sorted_combs.append(comb[0])
106 output = open(scored_comb_output_fn,
"w")
107 for comb,score
in ranked_combs:
110 output.write(str(ind)+
" ")
111 output.write(
"|"+str(1.-score)+
"|\n")
114 def run(asmb_fn, proteomics_fn, mapping_fn, params_fn,
115 combs_fn_output_fn, scored_comb_output_fn, max_comb):
117 asmb.set_was_used(
True)
119 dmap.get_header().set_resolution(
120 asmb.get_assembly_header().get_resolution())
121 threshold=asmb.get_assembly_header().get_threshold()
122 dmap.update_voxel_size(asmb.get_assembly_header().get_spacing())
123 dmap.set_origin(asmb.get_assembly_header().get_origin())
126 alignment_params = IMP.multifit.AlignmentParams(params_fn)
127 alignment_params.show()
134 em_anchors = mapping_data.get_anchors()
140 align.set_fast_scoring(
False)
141 align.set_density_map(dmap,threshold)
142 align.add_states_and_filters()
143 align.add_all_restraints()
148 combs=align.get_combinations()
151 f=open(combs_fn_output_fn,
"w")
152 f.write(
"NO SOLUTIONS FOUND\n")
156 report_solutions(asmb, align.get_model(), align.get_molecules(), dmap,
157 mapping_data, combs, combs_fn_output_fn,
158 scored_comb_output_fn, max_comb)
161 options,args = parse_args()
162 run(args[0], args[1], args[2], args[3], args[4], args[5],
164 if __name__ ==
"__main__":
An ensemble of fitting solutions.
void set_log_level(LogLevel l)
Set the current global log level.
void write_paths(const IntsList &paths, const std::string &txt_filename)
SettingsData * read_settings(const char *filename)
ProteinsAnchorsSamplingSpace read_protein_anchors_mapping(multifit::ProteomicsData *prots, const std::string &anchors_prot_map_fn, int max_paths=INT_MAX)
Align proteomics graph to EM density map.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
See IMP.multifit for more information.
DensityMap * read_map(std::string filename)
ProteomicsData * read_proteomics_data(const char *proteomics_fn)
Proteomics reader.
IMP::kernel::OptionParser OptionParser
Calculate score based on fit to EM map.
FittingSolutionRecords read_fitting_solutions(const char *fitting_fn)
Fitting solutions reader.