Skip to content
Snippets Groups Projects
Commit db4977a4 authored by Ben Webb's avatar Ben Webb
Browse files

Add metadata to RMF output

parent 3b13b009
No related branches found
No related tags found
No related merge requests found
......@@ -104,6 +104,15 @@ class IMPBAYESIANEMEXPORT GaussianEMRestraint : public Restraint
return exp(-unprotected_evaluate(NULL));
}
//! Set the filename corresponding to the density GMM particles
/** If the density GMM particles were read from a file, this method
can be used to tell the restraint so that it can track this
information back to the original EM density file, which is useful
for deposition. */
void set_density_filename(std::string density_fn) {
density_fn_ = get_absolute_path(density_fn);
}
//! Pre-calculate the density-density and model-model scores
/** This is automatically called by the constructor.
You only need to call it manually if you change Gaussian variances
......@@ -129,9 +138,17 @@ class IMPBAYESIANEMEXPORT GaussianEMRestraint : public Restraint
const IMP_OVERRIDE;
virtual IMP::ModelObjectsTemp do_get_inputs() const IMP_OVERRIDE;
void show(std::ostream &out) const { out << "GEM restraint"; }
//! \return Information for writing to RMF files
RestraintInfo *get_static_info() const IMP_OVERRIDE;
//! \return Information for writing to RMF files
RestraintInfo *get_dynamic_info() const IMP_OVERRIDE;
IMP_OBJECT_METHODS(GaussianEMRestraint);
private:
double model_cutoff_dist_, density_cutoff_dist_;
ParticleIndexes model_ps_;
ParticleIndexes density_ps_;
ParticleIndex global_sigma_;
......@@ -148,6 +165,7 @@ class IMPBAYESIANEMEXPORT GaussianEMRestraint : public Restraint
ParticleIndexes slope_ps_; //experiment
std::map<ParticleIndex,Float> map_score_dd_;
Float cached_score_term_;
std::string density_fn_;
//variables needed to tabulate the exponential
Floats exp_grid_;
......
......@@ -181,6 +181,8 @@ class GaussianEMRestraintWrapper(object):
cutoff_dist_model_data,
slope,
update_model, backbone_slope)
if target_fn != '':
self.gaussianEM_restraint.set_density_filename(target_fn)
print('done EM setup')
self.rs = IMP.RestraintSet(self.m, 'GaussianEMRestraint')
......
......@@ -26,7 +26,9 @@ GaussianEMRestraint::GaussianEMRestraint(Model *mdl, ParticleIndexes model_ps,
Float density_cutoff_dist, Float slope,
bool update_model, bool backbone_slope,
std::string name)
: Restraint(mdl, name), model_ps_(model_ps), density_ps_(density_ps),
: Restraint(mdl, name), model_cutoff_dist_(model_cutoff_dist),
density_cutoff_dist_(density_cutoff_dist),
model_ps_(model_ps), density_ps_(density_ps),
global_sigma_(global_sigma), slope_(slope), update_model_(update_model) {
msize_ = model_ps.size();
......@@ -281,4 +283,23 @@ ModelObjectsTemp GaussianEMRestraint::do_get_inputs() const {
return ret;
}
RestraintInfo *GaussianEMRestraint::get_static_info() const {
IMP_NEW(RestraintInfo, ri, ());
ri->add_string("type", "IMP.bayesianem.GaussianEMRestraint");
if (!density_fn_.empty()) {
ri->add_filename("filename", density_fn_);
}
ri->add_float("model cutoff", model_cutoff_dist_);
ri->add_float("density cutoff", density_cutoff_dist_);
return ri.release();
}
RestraintInfo *GaussianEMRestraint::get_dynamic_info() const {
IMP_NEW(RestraintInfo, ri, ());
Float scale = IMP::isd::Scale(get_model(), global_sigma_).get_scale();
ri->add_float("global sigma", scale);
ri->add_float("score", get_last_score());
return ri.release();
}
IMPBAYESIANEM_END_NAMESPACE
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment