예제 #1
0
파일: Fragment.cpp 프로젝트: newtonjoo/imp
void Fragment::set_residue_indexes(kernel::Model *m, kernel::ParticleIndex pi,
                                   const IntPairs &ris) {
  Ints begins(ris.size());
  Ints ends(ris.size());
  for (unsigned int i = 0; i < ris.size(); ++i) {
    begins[i] = ris[i].first;
    ends[i] = ris[i].second;
    IMP_USAGE_CHECK(ris[i].first < ris[i].second,
                    "Bad range for residue indexes");
  }
  if (begins.size() > 0) {
    if (m->get_has_attribute(get_begins_key(), pi)) {
      m->set_attribute(get_begins_key(), pi, begins);
      m->set_attribute(get_ends_key(), pi, ends);
    } else {
      m->add_attribute(get_begins_key(), pi, begins);
      m->add_attribute(get_ends_key(), pi, ends);
    }
  } else {
    if (m->get_has_attribute(get_begins_key(), pi)) {
      m->remove_attribute(get_begins_key(), pi);
      m->remove_attribute(get_ends_key(), pi);
    }
  }
}
예제 #2
0
파일: Fragment.cpp 프로젝트: newtonjoo/imp
void Fragment::set_residue_indexes(kernel::Model *m, kernel::ParticleIndex pi,
                                   Ints o) {
  if (o.empty()) {
    set_residue_indexes(m, pi, IntPairs());
    return;
  }
  std::sort(o.begin(), o.end());
  o.erase(std::unique(o.begin(), o.end()), o.end());
  IntPairs pairs;
  int begin = 0;
  for (unsigned int i = 1; i < o.size(); ++i) {
    if (o[i] != o[i - 1] + 1) {
      pairs.push_back(IntPair(o[begin], o[i - 1] + 1));
      begin = i;
    }
  }
  pairs.push_back(IntPair(o[begin], o.back() + 1));
  set_residue_indexes(m, pi, pairs);
  using IMP::operator<<;
  IMP_IF_CHECK(USAGE) {
    for (unsigned int i = 0; i < o.size(); ++i) {
      IMP_INTERNAL_CHECK(Fragment(m, pi).get_contains_residue(o[i]),
                         "Residue index not found after addition: "
                             << o << " became " << pairs);
    }
  }
}
예제 #3
0
파일: Fragment.cpp 프로젝트: newtonjoo/imp
bool Fragment::get_contains_residue(int ri) const {
  IntPairs all = get_residue_index_ranges();
  for (unsigned int i = 0; i < all.size(); ++i) {
    if (ri >= all[i].first && ri < all[i].second) return true;
  }
  return false;
}
예제 #4
0
파일: Fragment.cpp 프로젝트: newtonjoo/imp
Ints Fragment::get_residue_indexes() const {
  IntPairs ranges = get_residue_index_ranges();
  Ints ret;
  for (unsigned int i = 0; i < ranges.size(); ++i) {
    for (int j = ranges[i].first; j < ranges[i].second; ++j) {
      ret.push_back(j);
    }
  }
  return ret;
}
예제 #5
0
파일: Fragment.cpp 프로젝트: newtonjoo/imp
IMPATOM_BEGIN_NAMESPACE

void Fragment::show(std::ostream &out) const {
  out << "Fragment: ";
  IntPairs ps = get_residue_index_ranges();
  for (unsigned int i = 0; i < ps.size(); ++i) {
    if (ps[i].first != ps[i].second - 1) {
      out << "[" << ps[i].first << ", " << ps[i].second << ") ";
    } else {
      out << ps[i].first << " ";
    }
  }
}
예제 #6
0
void write_txt(const std::string &txt_filename, const AnchorsData &ad) {
  std::ofstream out;
  out.open(txt_filename.c_str(), std::ios::out);
  out << "|points|" << std::endl;
  for (int i = 0; i < ad.get_number_of_points(); i++) {
    algebra::Vector3D xyz = ad.points_[i];
    out << "|" << i << "|" << xyz[0] << "|" << xyz[1] << "|" << xyz[2] << "|"
        << std::endl;
  }
  out << "|edges|" << std::endl;
  IntPairs edges = ad.edges_;
  for (IntPairs::const_iterator it = edges.begin(); it != edges.end(); it++) {
    out << "|" << it->first << "|" << it->second << "|" << std::endl;
  }
  out.close();
}
예제 #7
0
IntPairs QuadraticClosePairsFinder::get_close_pairs(
    const algebra::BoundingBox3Ds &bbs) const {
  set_was_used(true);
  IMP_OBJECT_LOG;
  IMP_LOG_TERSE("Adding close pairs from "
                << bbs.size() << " boxes with threshold " << get_distance()
                << std::endl);
  IntPairs ret;
  const double d2 = get_distance() / 2.0;
  for (unsigned int i = 0; i < bbs.size(); ++i) {
    algebra::BoundingBox3D bi = bbs[i] + d2;
    for (unsigned int j = 0; j < i; ++j) {
      algebra::BoundingBox3D bj = bbs[j] + d2;
      if (get_interiors_intersect(bi, bj)) {
        ret.push_back(IntPair(i, j));
      }
    }
  }
  return ret;
}
IntPairs NearestNeighborsClosePairsFinder::get_close_pairs(
    const algebra::BoundingBox3Ds &bas,
    const algebra::BoundingBox3Ds &bbs) const {
  set_was_used(true);
  IMP_OBJECT_LOG;
  IMP_LOG_TERSE("Quadratic add_close_pairs called with "
                << bas.size() << " and " << bbs.size() << std::endl);
  IntPairs ret;
  const double d2 = get_distance() / 2.0;
  for (unsigned int i = 0; i < bas.size(); ++i) {
    algebra::BoundingBox3D bi = bas[i] + d2;
    for (unsigned int j = 0; j < bbs.size(); ++j) {
      algebra::BoundingBox3D bj = bbs[j] + d2;
      if (get_interiors_intersect(bi, bj)) {
        ret.push_back(IntPair(i, j));
      }
    }
  }
  return ret;
}