コード例 #1
0
ScoreStatesTemp
SingleParticleScoringFunction
::get_required_score_states(const DependencyGraph &dg,
                            const DependencyGraphVertexIndex &index) const {
  IMP_OBJECT_LOG;
  ScoreStatesTemp from_restraints
      =IMP::internal::RestraintsScoringFunction::get_required_score_states(dg,
                                                                        index);
  IMP_LOG(TERSE, "Score states from restraints are " << from_restraints
          << "(" << IMP::internal::RestraintsScoringFunction::get_restraints()
          << ")" << std::endl);
  ScoreStatesTemp from_dummy
      = IMP::get_required_score_states(dummy_restraints_, dg, index);
  IMP_LOG(TERSE, "Score states from dummy are " << from_dummy
          << "(" << dummy_restraints_ << ")" << std::endl);
  ScoreStatesTemp deps
      = IMP::get_dependent_score_states(get_model()->get_particle(pi_),
                                        ModelObjectsTemp(), dg, index);
  IMP_LOG(TERSE, "Dependent score states are " << deps << std::endl);
  std::sort(deps.begin(), deps.end());
  ScoreStatesTemp allin= from_restraints+from_dummy;
  std::sort(allin.begin(), allin.end());
  // intersect the lists to determine which depend on this particle and are need
  ScoreStatesTemp ret;
  std::set_intersection(allin.begin(), allin.end(),
                        deps.begin(), deps.end(),
                        std::back_inserter(ret));
  IMP_LOG(TERSE, "Particle " << Showable(get_model()->get_particle(pi_))
          << " will update " << get_ordered_score_states(ret) << std::endl);
  return get_ordered_score_states(ret);
}
コード例 #2
0
ファイル: subset_graphs.cpp プロジェクト: j-ma-bu-l-l-ock/imp
InteractionGraph get_interaction_graph(ScoringFunctionAdaptor rsi,
                                       const ParticlesTemp &ps) {
  if (ps.empty()) return InteractionGraph();
  InteractionGraph ret(ps.size());
  Restraints rs =
      create_decomposition(rsi->create_restraints());
  // Model *m= ps[0]->get_model();
  boost::unordered_map<ModelObject *, int> map;
  InteractionGraphVertexName pm = boost::get(boost::vertex_name, ret);
  DependencyGraph dg = get_dependency_graph(ps[0]->get_model());
  DependencyGraphVertexIndex index = IMP::get_vertex_index(dg);
  /*IMP_IF_LOG(VERBOSE) {
    IMP_LOG_VERBOSE( "dependency graph is \n");
    IMP::internal::show_as_graphviz(dg, std::cout);
    }*/
  for (unsigned int i = 0; i < ps.size(); ++i) {
    ParticlesTemp t = get_dependent_particles(
        ps[i], ParticlesTemp(ps.begin(), ps.end()), dg, index);
    for (unsigned int j = 0; j < t.size(); ++j) {
      IMP_USAGE_CHECK(map.find(t[j]) == map.end(),
                      "Currently particles which depend on more "
                          << "than one particle "
                          << "from the input set are not supported."
                          << "  Particle \"" << t[j]->get_name()
                          << "\" depends on \"" << ps[i]->get_name()
                          << "\" and \""
                          << ps[map.find(t[j])->second]->get_name() << "\"");
      map[t[j]] = i;
    }
    IMP_IF_LOG(VERBOSE) {
      IMP_LOG_VERBOSE("Particle \"" << ps[i]->get_name() << "\" controls ");
      for (unsigned int i = 0; i < t.size(); ++i) {
        IMP_LOG_VERBOSE("\"" << t[i]->get_name() << "\" ");
      }
      IMP_LOG_VERBOSE(std::endl);
    }
    pm[i] = ps[i];
  }
  IMP::Restraints all_rs = IMP::get_restraints(rs);
  for (Restraints::const_iterator it = all_rs.begin();
       it != all_rs.end(); ++it) {
    ModelObjectsTemp pl = (*it)->get_inputs();
    add_edges(ps, pl, map, *it, ret);
  }
  /* Make sure that composite score states (eg the normalizer for
     rigid body rotations) don't induce interactions among unconnected
     particles.*/
  ScoreStatesTemp ss = get_required_score_states(rs);
  for (ScoreStatesTemp::const_iterator it = ss.begin(); it != ss.end(); ++it) {
    ModelObjectsTemps interactions = (*it)->get_interactions();
    for (unsigned int i = 0; i < interactions.size(); ++i) {
      add_edges(ps, interactions[i], map, *it, ret);
    }
  }
  IMP_INTERNAL_CHECK(boost::num_vertices(ret) == ps.size(),
                     "Wrong number of vertices " << boost::num_vertices(ret)
                                                 << " vs " << ps.size());
  return ret;
}
コード例 #3
0
ファイル: ScoreState.cpp プロジェクト: apolitis/imp
ScoreStatesTemp get_update_order(ScoreStatesTemp in) {
  IMP_FUNCTION_LOG;
  if (in.empty()) return in;
  std::sort(in.begin(), in.end());
  in.erase(std::unique(in.begin(), in.end()), in.end());
  std::sort(in.begin(), in.end(), CompOrder());
  IMP_LOG_TERSE("Order: " << in << std::endl);
  return in;
}
コード例 #4
0
ScoreStatesTemp get_required_score_states(const ModelObjectsTemp &mos,
                                          ScoreStatesTemp exclude) {
  if (mos.empty()) return ScoreStatesTemp();
  ScoreStatesTemp ret;
  for (unsigned int i = 0; i < mos.size(); ++i) {
    mos[0]->get_model()->do_set_has_required_score_states(mos[i], true);
    ret += mos[i]->get_required_score_states();
  }
  std::sort(ret.begin(), ret.end());
  std::sort(exclude.begin(), exclude.end());
  ScoreStatesTemp diff;
  std::set_difference(ret.begin(), ret.end(), exclude.begin(), exclude.end(),
                      std::back_inserter(diff));
  return get_update_order(diff);
}