当前位置: 首页>>代码示例>>C++>>正文


C++ TextOutput::get_stream方法代码示例

本文整理汇总了C++中TextOutput::get_stream方法的典型用法代码示例。如果您正苦于以下问题:C++ TextOutput::get_stream方法的具体用法?C++ TextOutput::get_stream怎么用?C++ TextOutput::get_stream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextOutput的用法示例。


在下文中一共展示了TextOutput::get_stream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: write_connolly_surface

IMPMULTIFIT_BEGIN_NAMESPACE

void write_connolly_surface(atom::Atoms atoms, TextOutput fn,
                            float density, float probe_radius) {

  algebra::Sphere3Ds spheres;
  for (unsigned int i = 0; i < atoms.size(); ++i) {
    spheres.push_back(core::XYZR(atoms[i]).get_sphere());
  }

  algebra::ConnollySurfacePoints sps =
      algebra::get_connolly_surface(spheres, density, probe_radius);

  for (unsigned int i = 0; i < sps.size(); ++i) {
    fn.get_stream() << std::setw(5) << sps[i].get_atom(0) + 1 << std::setw(5)
                    << sps[i].get_atom(1) + 1 << std::setw(5)
                    << sps[i].get_atom(2) + 1 << std::fixed << std::setw(8)
                    << std::setprecision(3) << sps[i].get_surface_point()[0]
                    << std::setw(8) << std::setprecision(3)
                    << sps[i].get_surface_point()[1] << std::setw(8)
                    << std::setprecision(3) << sps[i].get_surface_point()[2]
                    << std::setw(8) << std::setprecision(3) << sps[i].get_area()
                    << std::setw(7) << std::setprecision(3)
                    << sps[i].get_normal()[0] << std::setw(7)
                    << std::setprecision(3) << sps[i].get_normal()[1]
                    << std::setw(7) << std::setprecision(3)
                    << sps[i].get_normal()[2] << "  0.500" << std::endl;
  }
}
开发者ID:AljGaber,项目名称:imp,代码行数:29,代码来源:connolly_surface.cpp

示例2: write_pdb

void write_pdb(const ParticlesTemp& ps, TextOutput out) {
  IMP_FUNCTION_LOG;
  int last_index = 0;
  bool use_input_index = true;
  for (unsigned int i = 0; i < ps.size(); ++i) {
    if (Atom(ps[i]).get_input_index() != last_index + 1) {
      use_input_index = false;
      break;
    } else {
      ++last_index;
    }
  }
  for (unsigned int i = 0; i < ps.size(); ++i) {
    if (Atom::get_is_setup(ps[i])) {
      Atom ad(ps[i]);
      Residue rd = get_residue(ad);
      // really dumb and slow, fix later
      char chain;
      Chain c = get_chain(rd);
      if (c) {
        chain = c.get_id()[0];
      } else {
        chain = ' ';
      }
      int inum = i+1;
      if (i>=99999) inum=99999;
      out.get_stream() << get_pdb_string(
                              core::XYZ(ps[i]).get_coordinates(),
                              use_input_index ? ad.get_input_index()
                                              : static_cast<int>(inum),
                              ad.get_atom_type(), rd.get_residue_type(), chain,
                              rd.get_index(), rd.get_insertion_code(),
                              ad.get_occupancy(), ad.get_temperature_factor(),
                              ad.get_element());

      if (!out) {
        IMP_THROW("Error writing to file in write_pdb", IOException);
      }
    }
    else if (Residue::get_is_setup(ps[i])) {    // if C-alpha residue is available
      Residue rd = IMP::atom::Residue(ps[i]);
      // comment 1 by SJ - TODO: How to retrieve the correct chain information without an hierarchy?
      char chain;
      Chain c = get_chain(rd);
      if (c) {
        chain = c.get_id()[0];
      } else {
        chain = ' ';
      }

      // comment 2 by SJ - TODO: The C-alpha residues are not sorted yet. We need to sort the residues similarly to what PMI does.
      out.get_stream() << get_pdb_string(
                              core::XYZ(ps[i]).get_coordinates(),
                              static_cast<int>(i + 1),
                              IMP::atom::AT_CA, rd.get_residue_type(), chain,
                              rd.get_index(), ' ',
                              1.0, IMP::core::XYZR(ps[i]).get_radius());
    }
    else {  // if a coarse-grained BEAD is available
      Ints resindexes = IMP::atom::Fragment(ps[i]).get_residue_indexes();
      int resindex = (int)resindexes.front() + (int)(resindexes.size()/2);
      // comment 1 by SJ - TODO: How to retrieve the correct chain information without an hierarchy?
      char chain = ' ';

      // comment 3 by SJ - TODO: The BEADs are not sorted yet. We need to sort the residues similarly to what PMI does.
      // comment 4 by SJ - TODO: currently IMP does not allow "BEA" as a residue name, while PMI allows it. Thus "UNK" was used instead.
      out.get_stream() << get_pdb_string(
                              core::XYZ(ps[i]).get_coordinates(),
                              static_cast<int>(i + 1),
                              IMP::atom::AT_CA, IMP::atom::UNK, chain,
                              (int)resindex, ' ',
                              1.0, IMP::core::XYZR(ps[i]).get_radius());
    }
  }
}
开发者ID:salilab,项目名称:imp,代码行数:75,代码来源:pdb.cpp


注:本文中的TextOutput::get_stream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。