Exemplo n.º 1
0
//! Add one weight
void Weight::add_weight() {
  int i = get_particle()->get_value(get_nstates_key());
  IMP_USAGE_CHECK(i < nstates_max, "Out of range");
  get_particle()->set_value(get_nstates_key(), i + 1);
  Float w = 1.0 / static_cast<Float>(get_number_of_states());
  for (int i = 0; i < get_number_of_states(); ++i) {
    get_particle()->set_value(get_weight_key(i), w);
  }
}
Exemplo n.º 2
0
void Atom::show(std::ostream &out) const
{
  out << "  element:"<< get_element_table().get_name(get_element());
  out << " type: "<< get_atom_type();
  if (get_input_index() != -1) {
    out << " input index: " << get_input_index();
  }
  if (core::XYZ::particle_is_instance(get_particle())) {
    out << " coords: " << core::XYZ(get_particle());
  }
}
Exemplo n.º 3
0
void Hierarchy::show(std::ostream &out) const
{
  if (*this == Hierarchy()) {
    out << "nullptr Molecular Hierarchy node";
    return;
  }
  bool found=false;
  if (get_as_atom()) {
    found=true;
    out << get_as_atom();
  }
  if (get_as_residue()){
    found=true;
    out << get_as_residue();
  }
  if (get_as_chain()) {
    found=true;
    out << get_as_chain();
  } else if (get_as_molecule()) {
    found=true;
    out << get_as_molecule();
  }
  if (get_as_fragment()) {
    found=true;
    out << get_as_fragment();
  }
  if (get_as_domain()) {
    found=true;
    out << get_as_domain();
  }
  if (core::RigidBody::particle_is_instance(get_particle())) {
    found=true;
    out << core::RigidBody(get_particle());
  }
  if (core::RigidMember::particle_is_instance(get_particle())) {
      found=true;
      out << " rigid member: " << core::RigidMember(get_particle())
        .get_rigid_body()->get_name();
    }
  if (get_as_xyzr()) {
    found=true;
    out << " sphere: " << get_as_xyzr().get_sphere();
  } else if (get_as_xyz()) {
    found=true;
    out << " coordinates: " << get_as_xyz().get_coordinates();
  }
  if (!found) {
    out << "Hierarchy \"" <<  get_particle()->get_name()
        << "\"";
  }
}
Exemplo n.º 4
0
static void direct(const struct cell *c1, const struct cell *c2) {
    for (int i = 0; i < cell_np(c1); ++i) {
        for (int j = 0; j < cell_np(c2); ++j) {
            struct particle p1 = get_particle(c1, i);
            struct particle p2 = get_particle(c2, i);
            TACO_vec d = TACO_vec_sub(p1.pos, p2.pos);
            // By convention, "force" is defined as a vector for each
            // particle. accumulate_force is a special function that
            // accumulates all contributions to the force for a particle.
            accumulate_force(c1, i, TACO_vec_mul_s(d, p1.m));
            accumulate_force(c2, i, TACO_vec_mul_s(d, -p2.m));
        }
    }
}
Exemplo n.º 5
0
void Scale::show(std::ostream &out) const {
  Particle *p = get_particle();
  bool hasupper = p->has_attribute(get_upper_key());
  out << get_lower() << " < ";
  out << " Scale = " << get_nuisance();
  if (hasupper) out << " < " << get_upper();
}
Exemplo n.º 6
0
//! Set all the weights
void Weight::set_weights(algebra::VectorKD w) {
  IMP_USAGE_CHECK(static_cast<int>(w.get_dimension()) == get_number_of_states(),
                  "Out of range");
  for (int i = 0; i < get_number_of_states(); ++i) {
    get_particle()->set_value(get_weight_key(i), w[i]);
  }
}
Exemplo n.º 7
0
void Bond::show(std::ostream &out) const {
  if (*this == Bond()) {
    out << "Null Bond";
    return;
  }
  out << "Bond between " << get_bonded(0).get_particle()->get_name() << " and "
      << get_bonded(1).get_particle()->get_name();
  if (get_type() != NONBIOLOGICAL) {
    out << " of type " << get_type();
  }
  if (get_order() != 1) out << " and order " << get_order();
  if (get_particle()->has_attribute(internal::get_bond_data().length_)) {
    out << " and length "
        << get_particle()->get_value(internal::get_bond_data().length_);
  }
}
Exemplo n.º 8
0
Float Nuisance::get_lower() const {
    Particle *p = get_particle();
    bool hasfloat = p->has_attribute(get_lower_key());
    bool hasparticle = p->has_attribute(get_lower_particle_key());
    if (hasfloat)
    {
        double floatval = p->get_value(get_lower_key());
        if (hasparticle)
        {
            Particle *d = p->get_value(get_lower_particle_key());
            double particleval = d->get_value(get_nuisance_key());
            if (floatval > particleval)
            {
                return floatval;
            } else {
                return particleval;
            }
        } else {
            return floatval;
        }
    } else if (hasparticle) {
        Particle *d = p->get_value(get_lower_particle_key());
        return d->get_value(get_nuisance_key());
    } else {
        return - std::numeric_limits<double>::infinity();
    }
  }
Exemplo n.º 9
0
void Atom::set_atom_type(AtomType t)
{
  get_particle()->set_value(get_atom_type_key(), t.get_index());
  Element e= get_element_for_atom_type(t);
  if (e != UNKNOWN_ELEMENT) {
    set_element(e);
  }
}
Exemplo n.º 10
0
IMPEM_BEGIN_NAMESPACE

void Voxel::show(std::ostream &out) const {
  algebra::VectorD<5> v;
  Particle *p = get_particle();
  core::XYZR xyzr(p);
  v[0] = xyzr.get_x();
  v[1] = xyzr.get_y();
  v[2] = xyzr.get_z();
  v[3] = xyzr.get_radius();  // p->get_value(core::XYZR::get_radius_key());
  v[4] = p->get_value(get_density_key());
  out << "(" << algebra::commas_io(v) << ")";
}
Exemplo n.º 11
0
void Nuisance::set_nuisance(Float d) {
    Float d_=d;
    Particle *p=get_particle();
    if (has_lower())
    {
        Float lo = get_lower();
        if (d < lo)  d_ = lo;
    }
    if (has_upper())
    {
        Float up = get_upper();
        if (d > up)  d_ = up;
    }
    p->set_value(get_nuisance_key(), d_);
}
Exemplo n.º 12
0
void Hierarchy::show(std::ostream &out, std::string delimiter) const {
  if (*this == Hierarchy()) {
    out << "nullptr Molecular Hierarchy node";
    return;
  }
  out << "\"" << get_particle()->get_name() << "\"" << delimiter;
  if (get_as_atom()) {
    out << get_as_atom() << delimiter;
  }
  if (get_as_residue()) {
    out << get_as_residue() << delimiter;
  }
  if (get_as_chain()) {
    out << get_as_chain() << delimiter;
  } else if (get_as_molecule()) {
    out << get_as_molecule() << delimiter;
  }
  if (get_as_fragment()) {
    out << get_as_fragment() << delimiter;
  }
  if (get_as_domain()) {
    out << get_as_domain() << delimiter;
  }
  if (core::RigidBody::get_is_setup(get_particle())) {
    out << core::RigidBody(get_particle());
  }
  if (core::RigidMember::get_is_setup(get_particle())) {
    out << " rigid member: "
        << core::RigidMember(get_particle()).get_rigid_body()->get_name();
  }
  if (get_as_xyzr()) {
    out << get_as_xyzr().get_sphere();
  } else if (get_as_xyz()) {
    out << get_as_xyz().get_coordinates();
  }
}
Exemplo n.º 13
0
void Bonded::show(std::ostream &out) const {
  if (*this == Bonded()) {
    out << "Null Bonded";
    return;
  }
  out << "Particle " << get_particle()->get_name() << " is bonded to ";
  for (unsigned int i = 0; i < get_number_of_bonds(); ++i) {
    Bond b = get_bond(i);
    if (b.get_bonded(0) == *this) {
      out << b.get_bonded(1).get_particle()->get_name();
    } else {
      out << b.get_bonded(0).get_particle()->get_name();
    }
    out << " ";
  }
}
Exemplo n.º 14
0
bool Nuisance::has_upper() const {
  Particle * p = get_particle();
  return p->has_attribute(get_upper_key())
           || p->has_attribute(get_upper_particle_key());
}
Exemplo n.º 15
0
void Nuisance::set_lower(Float d) {
    Particle * p = get_particle();
    if (! p->has_attribute(get_lower_key()))
            p->add_attribute(get_lower_key(), d);
    p->set_value(get_lower_key(), d);
}
Exemplo n.º 16
0
        Float up = get_upper();
        if (d > up)  d_ = up;
    }
    p->set_value(get_nuisance_key(), d_);
}

void Nuisance::set_lower(Float d) {
    Particle * p = get_particle();
    if (! p->has_attribute(get_lower_key()))
            p->add_attribute(get_lower_key(), d);
    p->set_value(get_lower_key(), d);
}

void Nuisance::set_lower(Particle * d) {
    IMP_IF_CHECK(USAGE_AND_INTERNAL) { Nuisance::decorate_particle(d); }
    Particle * p = get_particle();
    if (! p->has_attribute(get_lower_particle_key()))
            p->add_attribute(get_lower_particle_key(), d);
    p->set_value(get_lower_particle_key(), d);
}

void Nuisance::set_upper(Float d) {
    Particle * p = get_particle();
    if (! p->has_attribute(get_upper_key()))
            p->add_attribute(get_upper_key(), d);
    p->set_value(get_upper_key(), d);
}

void Nuisance::set_upper(Particle * d) {
    IMP_IF_CHECK(USAGE_AND_INTERNAL) { Nuisance::decorate_particle(d); }
    Particle * p = get_particle();
Exemplo n.º 17
0
//! Set weights are optimized
void Weight::set_weights_are_optimized(bool tf) {
  for (int i = 0; i < nstates_max; ++i) {
    get_particle()->set_is_optimized(get_weight_key(i), tf);
  }
}
Exemplo n.º 18
0
void Residue::set_residue_type(ResidueType t) {
  get_particle()->set_value(get_residue_type_key(), t.get_index());
}
Exemplo n.º 19
0
void _TrivialTraitsDecorator::show(std::ostream &out) const {
  out << "trivial traits decorator " << get_particle()->get_name() << " with "
      << get_decorator_traits();
}
Exemplo n.º 20
0
void _TrivialDerivedDecorator::show(std::ostream &out) const {
  out << "trivial derived decorator " << get_particle()->get_name();
}
Exemplo n.º 21
0
void Atom::set_element(Element e) {
  get_particle()->set_value(get_element_key(), e);
  Mass(get_particle()).set_mass(get_element_table().get_mass(e));
}
Exemplo n.º 22
0
void Reference::show(std::ostream &out) const {
  out << get_particle()->get_name() << " references "
      << get_reference_particle()->get_name();
}
Exemplo n.º 23
0
void Angle::show(std::ostream &out) const {
  out << "Angle on " << get_particle(0)->get_name() << " "
      << get_particle(1)->get_name() << " " << get_particle(2)->get_name();
}
Exemplo n.º 24
0
void Molecule::show(std::ostream &out) const {
  out << "name: " << get_particle()->get_name();
}
Exemplo n.º 25
0
void Dihedral::show(std::ostream &out) const {
  out << "Dihedral on " << get_particle(0)->get_name() << " "
      << get_particle(1)->get_name() << " " << get_particle(2)->get_name()
      << " " << get_particle(3)->get_name();
}
Exemplo n.º 26
0
void destroy_particle( uint32 checksum )
{
	CParticle * p = get_particle( checksum );	 	// get item
	CEngine::sGetParticleTable()->FlushItem( checksum );		// remove reference from hash table
	delete p;										// deleted particle, will remove itself from the table
}
Exemplo n.º 27
0
//! Get the i-th weight
Float Weight::get_weight(int i) {
  IMP_USAGE_CHECK(i < get_number_of_states(), "Out of range");
  return get_particle()->get_value(get_weight_key(i));
}
Exemplo n.º 28
0
void destroy_particle_when_empty( uint32 checksum )
{
	CParticle * p = get_particle( checksum );	 	// get item
	p->delete_when_empty();
}
Exemplo n.º 29
0
//! Get number of states
Int Weight::get_number_of_states() {
  return get_particle()->get_value(get_nstates_key());
}
Exemplo n.º 30
0
void CenterOfMass::show(std::ostream &out) const {
  core::XYZ xyz(get_particle());
  atom::Mass m(get_particle());
  out << "CenterOfMass at " << xyz
      << " with mass " << m.get_mass();
}