示例#1
0
int BondedPairFilter::get_value_index(
    Model *m, const ParticleIndexPair &pip) const {
  if (!Bonded::get_is_setup(m, pip[0]) || !Bonded::get_is_setup(m, pip[1])) {
    return false;
  }
  Bonded ba(m, pip[0]);
  Bonded bb(m, pip[1]);
  Bond bd = get_bond(ba, bb);
  return bd != Bond();
}
示例#2
0
void CHARMMPatch::apply(CHARMMResidueTopology *res) const {
  if (res->get_patched()) {
    IMP_THROW("Cannot patch an already-patched residue", ValueException);
  }
  check_empty_patch(this);

  // Copy or update atoms
  for (base::Vector<CHARMMAtomTopology>::const_iterator it = atoms_.begin();
       it != atoms_.end(); ++it) {
    try {
      res->get_atom(it->get_name()) = *it;
    }
    catch (base::ValueException &) {
      res->add_atom(*it);
    }
  }

  // Delete atoms
  for (base::Vector<std::string>::const_iterator it = deleted_atoms_.begin();
       it != deleted_atoms_.end(); ++it) {
    try {
      res->remove_atom(*it);
    }
    catch (base::ValueException &) {
      // ignore atoms that don't exist to start with
    }
  }

  // Add angles/bonds/dihedrals/impropers
  for (unsigned int i = 0; i < get_number_of_bonds(); ++i) {
    res->add_bond(get_bond(i));
  }
  for (unsigned int i = 0; i < get_number_of_angles(); ++i) {
    res->add_angle(get_angle(i));
  }
  for (unsigned int i = 0; i < get_number_of_dihedrals(); ++i) {
    res->add_dihedral(get_dihedral(i));
  }
  for (unsigned int i = 0; i < get_number_of_impropers(); ++i) {
    res->add_improper(get_improper(i));
  }

  // Add internal coordinates
  for (unsigned int i = 0; i < get_number_of_internal_coordinates(); ++i) {
    res->add_internal_coordinate(get_internal_coordinate(i));
  }

  res->set_patched(true);
}
示例#3
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 << " ";
  }
}
void CHARMMPatch::apply(CHARMMResidueTopology *res1,
                        CHARMMResidueTopology *res2) const
{
  if (res1->get_patched()) {
    IMP_THROW("Cannot patch an already-patched residue", ValueException);
  }
  if (res2->get_patched()) {
    IMP_THROW("Cannot patch an already-patched residue", ValueException);
  }
  check_empty_patch(this);

  // Extra checks for the commonly-used CHARMM DISU patch
  if (get_type() == "DISU"
      && (res1->get_type() != "CYS" || res2->get_type() != "CYS")) {
    IMP_WARN("Applying a DISU patch to two residues that are not both 'CYS' "
             "(they are " << *res1 << " and " << *res2 << "). This is "
             "probably not what was intended.");
  }

  // Copy or update atoms
  for (base::Vector<CHARMMAtomTopology>::const_iterator it = atoms_.begin();
       it != atoms_.end(); ++it) {
    std::pair<CHARMMResidueTopology *, CHARMMAtomTopology> resatom =
                                handle_two_patch_atom(*it, res1, res2);
    try {
      resatom.first->get_atom(resatom.second.get_name()) = resatom.second;
    } catch (ValueException &e) {
      resatom.first->add_atom(resatom.second);
    }
  }

  // Delete atoms
  for (base::Vector<std::string>::const_iterator it = deleted_atoms_.begin();
       it != deleted_atoms_.end(); ++it) {
    std::pair<CHARMMResidueTopology *, CHARMMAtomTopology> resatom =
                                handle_two_patch_atom(*it, res1, res2);
    try {
      resatom.first->remove_atom(resatom.second.get_name());
    } catch (ValueException &e) {
      // ignore atoms that don't exist to start with
    }
  }

  // Add angles/bonds/dihedrals/impropers
  for (unsigned int i = 0; i < get_number_of_bonds(); ++i) {
    CHARMMResidueTopology *res =
                get_two_patch_residue_for_bond(get_bond(i), res1, res2);
    res->add_bond(CHARMMBond(handle_two_patch_bond(get_bond(i), res1,
                                                   res2, res)));
  }
  for (unsigned int i = 0; i < get_number_of_angles(); ++i) {
    CHARMMResidueTopology *res =
               get_two_patch_residue_for_bond(get_angle(i), res1, res2);
    res->add_angle(CHARMMAngle(handle_two_patch_bond(get_angle(i), res1, res2,
                                                     res)));
  }
  for (unsigned int i = 0; i < get_number_of_dihedrals(); ++i) {
    CHARMMResidueTopology *res =
                    get_two_patch_residue_for_bond(get_dihedral(i), res1, res2);
    res->add_dihedral(CHARMMDihedral(handle_two_patch_bond(get_dihedral(i),
                                                           res1, res2, res)));
  }
  for (unsigned int i = 0; i < get_number_of_impropers(); ++i) {
    CHARMMResidueTopology *res =
                    get_two_patch_residue_for_bond(get_improper(i), res1, res2);
    res->add_improper(CHARMMDihedral(handle_two_patch_bond(get_improper(i),
                                                           res1, res2, res)));
  }

  // Add internal coordinates
  for (unsigned int i = 0; i < get_number_of_internal_coordinates(); ++i) {
    CHARMMInternalCoordinate ic = get_internal_coordinate(i);
    CHARMMResidueTopology *res =
                    get_two_patch_residue_for_bond(get_internal_coordinate(i),
                                                   res1, res2);
    res->add_internal_coordinate(
            CHARMMInternalCoordinate(handle_two_patch_bond(ic, res1,
                                                           res2, res),
                                ic.get_first_distance(), ic.get_first_angle(),
                                ic.get_dihedral(), ic.get_second_angle(),
                                ic.get_second_distance(), ic.get_improper()));
  }

  res1->set_patched(true);
  res2->set_patched(true);
}