コード例 #1
0
ファイル: CHARMMParameters.cpp プロジェクト: apolitis/imp
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;
}
コード例 #2
0
ファイル: CHARMMParameters.cpp プロジェクト: apolitis/imp
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;
}