コード例 #1
0
ファイル: subset_scores.cpp プロジェクト: j-ma-bu-l-l-ock/imp
RestraintsTemp RestraintCache::get_restraints() const {
  IMP_OBJECT_LOG;
  RestraintsTemp ret;
  for (KnownRestraints::const_iterator it = known_restraints_.begin();
       it != known_restraints_.end(); ++it) {
    ret.push_back(it->first);
  }
  return ret;
}
コード例 #2
0
ファイル: subset_scores.cpp プロジェクト: j-ma-bu-l-l-ock/imp
void RestraintCache::load_cache(const ParticlesTemp &particle_ordering,
                                RMF::HDF5::ConstGroup group) {
  ParticleIndex particle_index = get_particle_index(particle_ordering);
  boost::unordered_map<RestraintID, Restraint *> index;
  for (KnownRestraints::const_iterator it = known_restraints_.begin();
       it != known_restraints_.end(); ++it) {
    index[get_restraint_id(particle_index, it->second,
                           restraint_index_.find(it->first)->second)] =
        it->first;
  }
  RestraintsTemp restraints;
  for (unsigned int i = 0; i < group.get_number_of_children(); ++i) {
    RMF::HDF5::ConstGroup ch = group.get_child_group(i);
    int restraint_index =
        ch.get_attribute<RMF::HDF5::IndexTraits>("restraint")[0];
    RMF::HDF5::Indexes particle_indexes =
        ch.get_attribute<RMF::HDF5::IndexTraits>("particles");
    RestraintID rid(restraint_index,
                    ConstVector<unsigned int>(Ints(
                        particle_indexes.begin(), particle_indexes.end())));
    Restraint *r = index.find(rid)->second;
    restraints.push_back(r);
    IMP_LOG_TERSE("Matching " << Showable(r) << " with " << ch.get_name()
                              << std::endl);
  }
  Orders orders = get_orders(known_restraints_, restraints, particle_ordering);
  for (unsigned int i = 0; i < group.get_number_of_children(); ++i) {
    RMF::HDF5::ConstGroup ch = group.get_child_group(i);
    RMF::HDF5::FloatConstDataSet1D scores =
        ch.get_child_float_data_set_1d("scores");
    RMF::HDF5::IntConstDataSet2D assignments =
        ch.get_child_int_data_set_2d("assignments");
    for (unsigned int j = 0; j < scores.get_size()[0]; ++j) {
      double s = scores.get_value(RMF::HDF5::DataSetIndex1D(j));
      RMF::HDF5::Ints rw = assignments.get_row(RMF::HDF5::DataSetIndex1D(j));
      Ints psit(rw.begin(), rw.end());
      Assignment ass = orders[i].get_subset_ordered(psit);
      cache_.insert(Key(restraints[i], ass), s);
    }
  }
  validate();
}
コード例 #3
0
ファイル: example_program.cpp プロジェクト: salilab/imp
int main(int argc, char **argv) {
  IMP::setup_from_argv(argc, argv, "An example program");
  Pointer<Model> m(new Model());
  ParticleIndex p0 = m->add_particle("P0");
  core::XYZ d0 = core::XYZ::setup_particle(m, p0);
  ParticleIndex p1 = m->add_particle("P1");
  core::XYZ d1 = core::XYZ::setup_particle(m, p1);
  Pointer<example::ExampleRestraint> r0 =
      new example::ExampleRestraint(m, p0, 1);
  Pointer<example::ExampleRestraint> r1 =
      new example::ExampleRestraint(m, p1, 1);
  RestraintsTemp rs;
  rs.push_back(r0);
  rs.push_back(r1);
  d0.set_coordinates(algebra::Vector3D(0, 0, 2));
  d1.set_coordinates(algebra::Vector3D(0, 0, 3));

  Pointer<core::RestraintsScoringFunction> scoring_function =
      new core::RestraintsScoringFunction(rs);
  return 0;
}
コード例 #4
0
ファイル: subset_scores.cpp プロジェクト: j-ma-bu-l-l-ock/imp
RestraintsTemp RestraintCache::get_restraints(const Subset &s,
                                              const Subsets &exclusions) const {
  IMP_OBJECT_LOG;
  RestraintsTemp ret;
  for (KnownRestraints::const_iterator it = known_restraints_.begin();
       it != known_restraints_.end(); ++it) {
    if (s.get_contains(it->second)) {
      bool excluded = false;
      for (unsigned int i = 0; i < exclusions.size(); ++i) {
        if (exclusions[i].get_contains(it->second)) {
          excluded = true;
          break;
        }
      }
      if (!excluded) {
        ret.push_back(it->first);
      }
    }
  }
  return ret;
}