Particles CHARMMParameters::create_angles(kernel::Particles bonds) const { IMP_OBJECT_LOG; kernel::Particles ps; BondMap particle_bonds; make_bond_map(bonds, particle_bonds); // Iterate over all bonds for (kernel::Particles::const_iterator bit1 = bonds.begin(); bit1 != bonds.end(); ++bit1) { IMP::atom::Bond bd = IMP::atom::Bond(*bit1); kernel::Particle *p2 = bd.get_bonded(0).get_particle(); kernel::Particle *p3 = bd.get_bonded(1).get_particle(); // Extend along each adjoining p2 bond to get candidate p1-p2-p3 angles for (base::Vector<IMP::atom::Bond>::const_iterator bit2 = particle_bonds[p2].begin(); bit2 != particle_bonds[p2].end(); ++bit2) { kernel::Particle *p1 = get_other_end_of_bond(p2, *bit2); // Avoid making angles where p1 == p3, and avoid double-counting if (p3 > p1) { add_angle(p1, p2, p3, ps); } } // Do the same for p2-p3-p4 angles for (base::Vector<IMP::atom::Bond>::const_iterator bit2 = particle_bonds[p3].begin(); bit2 != particle_bonds[p3].end(); ++bit2) { kernel::Particle *p4 = get_other_end_of_bond(p3, *bit2); if (p4 < p2) { add_angle(p2, p3, p4, ps); } } } return ps; }
IMPATOM_BEGIN_INTERNAL_NAMESPACE void add_dihedral_to_list(const CHARMMParameters *param, kernel::Particle *p1, kernel::Particle *p2, kernel::Particle *p3, kernel::Particle *p4, kernel::Particles &ps) { try { base::Vector<CHARMMDihedralParameters> p = param->get_dihedral_parameters( CHARMMAtom(p1).get_charmm_type(), CHARMMAtom(p2).get_charmm_type(), CHARMMAtom(p3).get_charmm_type(), CHARMMAtom(p4).get_charmm_type()); for (base::Vector<CHARMMDihedralParameters>::const_iterator it = p.begin(); it != p.end(); ++it) { Dihedral dd = Dihedral::setup_particle( new kernel::Particle(p1->get_model()), core::XYZ(p1), core::XYZ(p2), core::XYZ(p3), core::XYZ(p4)); dd.set_ideal(it->ideal / 180.0 * PI); dd.set_multiplicity(it->multiplicity); if (it->force_constant < 0.0) { dd.set_stiffness(-std::sqrt(-it->force_constant * 2.0)); } else { dd.set_stiffness(std::sqrt(it->force_constant * 2.0)); } ps.push_back(dd); } } catch (const base::IndexException &e) { // If no parameters, warn, and create an empty dihedral IMP_WARN(e.what() << std::endl); Dihedral dd = Dihedral::setup_particle( new kernel::Particle(p1->get_model()), core::XYZ(p1), core::XYZ(p2), core::XYZ(p3), core::XYZ(p4)); ps.push_back(dd); } }
RadiusOfGyrationRestraint::RadiusOfGyrationRestraint(kernel::Particles ps, int num_residues, Float scale): kernel::Restraint(IMP::internal::get_model(ps), "RadiusOfGyrationRestraint"){ if (ps.size()==0) return; add_particles(ps); mdl_=ps[0]->get_model(); predicted_rog_ = get_approximated_radius_of_gyration(num_residues); scale_=scale; hub_=new core::HarmonicUpperBound(predicted_rog_*scale_,1); }
Particles CHARMMParameters::create_dihedrals(kernel::Particles bonds) const { IMP_OBJECT_LOG; kernel::Particles ps; BondMap particle_bonds; make_bond_map(bonds, particle_bonds); // Iterate over all bonds for (kernel::Particles::const_iterator bit1 = bonds.begin(); bit1 != bonds.end(); ++bit1) { IMP::atom::Bond bd = IMP::atom::Bond(*bit1); kernel::Particle *p2 = bd.get_bonded(0).get_particle(); kernel::Particle *p3 = bd.get_bonded(1).get_particle(); // Extend along each bond from p2 and p3 to get candidate // p1-p2-p3-p4 dihedrals for (base::Vector<IMP::atom::Bond>::const_iterator bit2 = particle_bonds[p2].begin(); bit2 != particle_bonds[p2].end(); ++bit2) { kernel::Particle *p1 = get_other_end_of_bond(p2, *bit2); if (p1 != p3) { for (base::Vector<IMP::atom::Bond>::const_iterator bit3 = particle_bonds[p3].begin(); bit3 != particle_bonds[p3].end(); ++bit3) { kernel::Particle *p4 = get_other_end_of_bond(p3, *bit3); // Avoid generating dihedrals for three-membered rings if (p1 != p4 && p2 != p4) { internal::add_dihedral_to_list(this, p1, p2, p3, p4, ps); } } } } } return ps; }
SimpleDistance create_simple_distance(const kernel::Particles &ps) { IMP_USAGE_CHECK(ps.size() == 2, "Two particles should be given"); /****** Set the restraint ******/ IMP_NEW(core::HarmonicUpperBound, h, (0, 1)); IMP_NEW(core::DistanceRestraint, dr, (h, ps[0], ps[1])); /****** Add restraint to the model ******/ //Model *mdl = (*ps)[0]->get_model(); //mdl->add_restraint(dr); /****** Return a SimpleDistance object ******/ return SimpleDistance(dr, h); }
void CHARMMParameters::add_angle(kernel::Particle *p1, kernel::Particle *p2, kernel::Particle *p3, kernel::Particles &ps) const { IMP_OBJECT_LOG; Angle ad = Angle::setup_particle(new kernel::Particle(p1->get_model()), core::XYZ(p1), core::XYZ(p2), core::XYZ(p3)); try { const CHARMMBondParameters &p = get_angle_parameters( CHARMMAtom(p1).get_charmm_type(), CHARMMAtom(p2).get_charmm_type(), CHARMMAtom(p3).get_charmm_type()); ad.set_ideal(p.ideal / 180.0 * PI); ad.set_stiffness(std::sqrt(p.force_constant * 2.0)); } catch (const base::IndexException &e) { // If no parameters, warn only IMP_WARN(e.what()); } ps.push_back(ad); }
SimpleDiameter create_simple_diameter(const kernel::Particles &ps, Float diameter) { IMP_USAGE_CHECK(ps.size() >= 2, "At least two particles should be given"); /****** Set the restraint ******/ IMP_NEW(core::HarmonicUpperBound, h, (0, 1)); IMP_NEW(container::ListSingletonContainer, lsc, (get_as<kernel::ParticlesTemp>(ps))); IMP_NEW(core::DiameterRestraint, dr, (h, lsc, diameter)); /****** Add restraint to the model ******/ //Model *mdl = (*ps)[0]->get_model(); //mdl->add_restraint(dr); /****** Return a SimpleDiameter object ******/ return SimpleDiameter(dr, h); }