コード例 #1
0
ファイル: RigidBodyMover.cpp プロジェクト: AljGaber/imp
MonteCarloMoverResult RigidBodyMover::do_propose() {
  IMP_OBJECT_LOG;
  RigidBody d(get_model(), pi_);
  last_transformation_ = d.get_reference_frame().get_transformation_to();
  algebra::Vector3D translation;
  if (max_translation_ > 0) {
    translation = algebra::get_random_vector_in(
        algebra::Sphere3D(d.get_coordinates(), max_translation_));
  } else {
    translation = algebra::get_zero_vector_d<3>();
  }
  algebra::Rotation3D rc;
  if (max_angle_ > 0) {
    algebra::Vector3D axis =
        algebra::get_random_vector_on(algebra::get_unit_sphere_d<3>());
    ::boost::uniform_real<> rand(-max_angle_, max_angle_);
    Float angle = rand(random_number_generator);
    algebra::Rotation3D r = algebra::get_rotation_about_axis(axis, angle);
    rc = r * d.get_reference_frame().get_transformation_to().get_rotation();
  } else {
    rc = algebra::get_identity_rotation_3d();
  }
  algebra::Transformation3D t(rc, translation);
  IMP_LOG_VERBOSE("proposed move " << t << std::endl);
  IMP_USAGE_CHECK(
      d.get_coordinates_are_optimized(),
      "Rigid body passed to RigidBodyMover"
          << " must be set to be optimized. particle: " << d->get_name());
  d.set_reference_frame(algebra::ReferenceFrame3D(t));

  return MonteCarloMoverResult(ParticleIndexes(1, pi_), 1.0);
}
コード例 #2
0
ファイル: WeightMover.cpp プロジェクト: AljGaber/imp
core::MonteCarloMoverResult WeightMover::do_propose() {
  IMP_OBJECT_LOG;

  // store the old weights in case of reject
  oldweights_ = w_.get_weights();

  // Draw weights from a uniform distribution of variables that sum to one
  // taken from http://stats.stackexchange.com/questions/14059/
  //                     generate-uniformly-distributed-weights-that-sum-to-unity

  // get the old x
  Floats x;
  x.push_back(oldweights_[0]);
  for (unsigned i = 1; i < oldweights_.get_dimension() - 1; ++i) {
    x.push_back(oldweights_[i] + x[i - 1]);
  }

  // zero vector in D dimension
  algebra::VectorKD zero = algebra::get_zero_vector_kd(x.size());

  // generate random perturbation of old components
  algebra::VectorKD dX =
      algebra::get_random_vector_in(algebra::SphereKD(zero, radius_));

  // add perturbation to x and apply reflective boundaries
  for (unsigned i = 0; i < x.size(); ++i) {
    if (x[i] + dX[i] > 1.0)
      x[i] = 2.0 - x[i] - dX[i];
    else if (x[i] + dX[i] < 0.0)
      x[i] = -x[i] - dX[i];
    else
      x[i] += dX[i];
  }

  // sort the new x here
  std::sort(x.begin(), x.end(), std::less<double>());

  // get the new weights
  algebra::VectorKD newweights =
      algebra::get_zero_vector_kd(oldweights_.get_dimension());

  newweights[0] = x[0];
  for (unsigned i = 1; i < newweights.get_dimension() - 1; ++i) {
    newweights[i] = x[i] - x[i - 1];
  }
  newweights[newweights.get_dimension() - 1] = 1.0 - x[x.size() - 1];

  // set the new weights
  w_.set_weights(newweights);

  return core::MonteCarloMoverResult(
      ParticleIndexes(1, w_.get_particle()->get_index()), 1.0);
}
コード例 #3
0
ファイル: atom_links.cpp プロジェクト: apolitis/imp
void HierarchySaveLink::do_add(kernel::Particle *p, RMF::NodeHandle cur) {
  IMP_USAGE_CHECK(atom::Hierarchy(p).get_is_valid(true),
                  "Invalid hierarchy passed.");

  RMF::SetCurrentFrame scf(cur.get_file(), RMF::ALL_FRAMES);
  data_.insert(
      std::make_pair(p->get_index(), boost::make_shared<Data>(cur.get_file())));
  add_recursive(p->get_model(), p->get_index(), p->get_index(),
                ParticleIndexes(), cur, *data_[p->get_index()]);
  P::add_link(p, cur);
  data_[p->get_index()]
      ->save_bonds.setup_bonds(p->get_model(), p->get_index(), cur);
}
コード例 #4
0
ファイル: RelativePositionMover.cpp プロジェクト: salilab/imp
core::MonteCarloMoverResult RelativePositionMover::do_propose() {
  last_transformation_ = rbA_.get_reference_frame().get_transformation_to();
  ::boost::uniform_real<> zeroone(0., 1.);
  double p = zeroone(random_number_generator);
  if (p < probability_of_random_move_) {
    algebra::Vector3D translation = algebra::get_random_vector_in(
        algebra::Sphere3D(rbA_.get_coordinates(), max_translation_));
    algebra::Vector3D axis = algebra::get_random_vector_on(
        algebra::Sphere3D(algebra::Vector3D(0.0, 0.0, 0.0), 1.));
    ::boost::uniform_real<> rand(-max_angle_, max_angle_);
    Float angle = rand(random_number_generator);
    algebra::Rotation3D r = algebra::get_rotation_about_axis(axis, angle);
    algebra::Rotation3D rc =
        r * rbA_.get_reference_frame().get_transformation_to().get_rotation();
    algebra::Transformation3D t(rc, translation);
    IMP_LOG_TERSE("proposing a random move " << t << std::endl);
    //   std::cout << "proposing a random move for " << rbA_->get_name() << " "
    //         << rbA_ << " Transformation " <<  t << std::endl;
    rbA_.set_reference_frame(algebra::ReferenceFrame3D(t));
  } else {
    ::boost::uniform_int<> randi(0, reference_rbs_.size() - 1);
    unsigned int i = randi(random_number_generator);

    ::boost::uniform_int<> randj(0, transformations_map_[i].size() - 1);
    unsigned int j = randj(random_number_generator);

    algebra::Transformation3D Tint = transformations_map_[i][j];
    IMP_LOG_TERSE("proposing a relative move. Rigid body "
                  << i << "Internal transformation " << j << " " << Tint
                  << std::endl);
    //    std::cout << "Proposing a relative move. Rigid body " <<
    // rbA_->get_name()
    //      << " " << rbA_  << " Relative transformation " <<  Tint<< std::endl;
    // core::RigidBody rb = reference_rbs_[i];
    algebra::Transformation3D T_reference =
        reference_rbs_[i].get_reference_frame().get_transformation_to();
    // std::cout << "RF receptor  ===> " << T_reference << std::endl;
    // new absolute reference frame for the rigid body of the ligand
    algebra::Transformation3D Tdock = algebra::compose(T_reference, Tint);
    rbA_.set_reference_frame(algebra::ReferenceFrame3D(Tdock));
    //    std::cout << "Finished proposing. Reference frame for the ligand"
    //          << rbA_.get_reference_frame() << std::endl;
  }
  return core::MonteCarloMoverResult(
      ParticleIndexes(1, rbA_.get_particle_index()), 1.0);
}
コード例 #5
0
Particle* graph_connect(Particle* a, Particle* b, GraphData &d)
{
  Model *m= a->get_model();
  Particle *p= new Particle(m);
  p->add_attribute(d.node_keys_[0], a);
  p->add_attribute(d.node_keys_[1], b);
  for (int i=0; i< 2; ++i) {
    Particle *cp=((i==0)?a:b);
    if (m->get_has_attribute(d.edges_key_, cp->get_index())) {
      ParticleIndexes c=m->get_attribute(d.edges_key_, cp->get_index());
      c.push_back(p->get_index());
      m->set_attribute(d.edges_key_, cp->get_index(), c);
    } else {
      m->add_attribute(d.edges_key_, cp->get_index(),
                   ParticleIndexes(1, p->get_index()));
    }
  }

  return p;
}
コード例 #6
0
ファイル: RigidBodyMover.cpp プロジェクト: drussel/imp
MonteCarloMoverResult RigidBodyMover::do_propose() {
  IMP_OBJECT_LOG;
  RigidBody d(get_model(), pi_);
  last_transformation_= d.get_reference_frame().get_transformation_to();
  algebra::Vector3D translation
    = algebra::get_random_vector_in(algebra::Sphere3D(d.get_coordinates(),
                                                      max_translation_));
  algebra::Vector3D axis =
    algebra::get_random_vector_on(algebra::get_unit_sphere_d<3>());
  ::boost::uniform_real<> rand(-max_angle_,max_angle_);
  Float angle =rand(random_number_generator);
  algebra::Rotation3D r
    = algebra::get_rotation_about_axis(axis, angle);
  algebra::Rotation3D rc
    = r*d.get_reference_frame().get_transformation_to().get_rotation();
  algebra::Transformation3D t(rc, translation);
  IMP_LOG_VERBOSE("proposed move " << t << std::endl);
  d.set_reference_frame(algebra::ReferenceFrame3D(t));

  return MonteCarloMoverResult(ParticleIndexes(1, pi_), 1.0);
}
コード例 #7
0
ファイル: NormalMover.cpp プロジェクト: AljGaber/imp
NormalMover::NormalMover(Model *m, ParticleIndex pi,
                         double radius)
    : MonteCarloMover(m, get_normal_mover_name(m, pi)) {
  initialize(ParticleIndexes(1, pi), XYZ::get_xyz_keys(), radius);
}
コード例 #8
0
ファイル: NormalMover.cpp プロジェクト: AljGaber/imp
NormalMover::NormalMover(Model *m, ParticleIndex pi,
                         const FloatKeys &keys, double radius)
    : MonteCarloMover(m, get_normal_mover_name(m, pi)) {
  initialize(ParticleIndexes(1, pi), keys, radius);
}
コード例 #9
0
ParticlesTemp ParticleOutputs::get_output_particles(Particle *p) const {
  IMPKERNEL_DEPRECATED_METHOD_DEF(2.1, "Call get_outputs instead.");
  return IMP::kernel::get_output_particles(
      get_outputs(p->get_model(), ParticleIndexes(1, p->get_index())));
}