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


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

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


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

示例1: _test_ifile

std::string _test_ifile(TextInput a) {
  std::string read;
  while (true) {
    std::string cur;
    a.get_stream() >> cur;
    if (!a) break;
    read = read + cur;
  }
  std::cout << read;
  return read;
}
开发者ID:j-ma-bu-l-l-ock,项目名称:imp,代码行数:11,代码来源:swig_base.cpp

示例2: read_mol2

Hierarchy read_mol2(TextInput mol2_file, Model* model,
                    Mol2Selector* mol2sel) {
  if (!mol2sel) {
    mol2sel = new AllMol2Selector();
  }
  IMP::PointerMember<Mol2Selector> sel(mol2sel);
  // create a map to save atom_index and atom particle pairs
  boost::unordered_map<Int, Particle*> molecule_atoms;

  // create root particle
  Hierarchy root_d = root_particle(model, mol2_file.get_name());
  std::string line;
  Hierarchy molecule_d;
  while (std::getline(mol2_file.get_stream(), line)) {
    // check the line is the title line @<TRIPOS>MOLECULE
    if (internal::is_MOLECULE_rec(line)) {
      molecule_atoms.clear();
      molecule_d = read_molecule_mol2(model, mol2_file, root_d);
    }
        // check the starting line of atom block @<TRIPOS>ATOM
        else if (internal::is_MOL2ATOM_rec(line)) {
      if (!molecule_d) {
        IMP_THROW("Atom seen before molecule on line " << line, IOException);
      }
      read_atom_mol2(model, mol2_file, molecule_d, molecule_atoms, mol2sel);
    }
        // check the starting line of bond block @<TRIPOS>BOND
        else if (internal::is_BOND_rec(line)) {
      read_bond_mol2(model, mol2_file, molecule_d, molecule_atoms);
    } else {
      IMP_LOG_TERSE("Couldn't parse line " << line << std::endl);
    }
  }
  // Hierarchies mps = get_by_type(root_d, RESIDUE_TYPE);
  //  std::cout << "check " << mps.size() << std::endl;
  add_radii(root_d);
  IMP_INTERNAL_CHECK(root_d.get_is_valid(true), "Invalid hierarchy produced");
  return root_d;
}
开发者ID:salilab,项目名称:imp,代码行数:39,代码来源:mol2.cpp

示例3: read_parameter_file

void CHARMMParameters::read_parameter_file(TextInput input_file) {
  IMP_OBJECT_LOG;
  const String BONDS_LINE = "BOND";
  const String ANGLES_LINE = "ANGL";
  const String ANGLES_LINE2 = "THETA";
  const String DIHEDRALS_LINE = "DIHE";
  const String DIHEDRALS_LINE2 = "PHI";
  const String IMPROPER_LINE = "IMPR";
  const String IMPROPER_LINE2 = "IMPHI";
  const String NONBONDED_LINE = "NONB";
  const String NONBONDED_LINE2 = "NBON";
  enum {
    NONE,
    BONDS,
    ANGLES,
    DIHEDRALS,
    IMPROPERS,
    NONBONDED
  } section = NONE;

  while (!input_file.get_stream().eof()) {
    String line;
    getline(input_file.get_stream(), line);

    boost::trim(line);  // remove all spaces
                        // skip comments or empty lines
    if (line[0] == '!' || line[0] == '*' || line.length() == 0) continue;

    if (line.substr(0, NONBONDED_LINE.length()) == NONBONDED_LINE ||
        line.substr(0, NONBONDED_LINE2.length()) == NONBONDED_LINE2) {
      section = NONBONDED;
      getline(input_file.get_stream(), line);  // remove second line of
                                               // NONBONDED
    } else if (line.substr(0, BONDS_LINE.length()) == BONDS_LINE) {
      section = BONDS;
    } else if (line.substr(0, ANGLES_LINE.length()) == ANGLES_LINE ||
               line.substr(0, ANGLES_LINE2.length()) == ANGLES_LINE2) {
      section = ANGLES;
    } else if (line.substr(0, DIHEDRALS_LINE.length()) == DIHEDRALS_LINE ||
               line.substr(0, DIHEDRALS_LINE2.length()) == DIHEDRALS_LINE2) {
      section = DIHEDRALS;
    } else if (line.substr(0, IMPROPER_LINE.length()) == IMPROPER_LINE ||
               line.substr(0, IMPROPER_LINE2.length()) == IMPROPER_LINE2) {
      section = IMPROPERS;
    } else if (line.substr(0, 5) == "HBOND" || line.substr(0, 5) == "NBFIX") {
      section = NONE;
    } else if (line.substr(0, 3) == "END") {
      break;
    } else {
      switch (section) {
        case BONDS:
          parse_bonds_parameters_line(line);
          break;
        case ANGLES:
          parse_angles_parameters_line(line);
          break;
        case DIHEDRALS:
          parse_dihedrals_parameters_line(line, dihedral_parameters_);
          break;
        case IMPROPERS:
          parse_dihedrals_parameters_line(line, improper_parameters_);
          break;
        case NONBONDED:
          parse_nonbonded_parameters_line(line);
          break;
        default:
          break;
      }
    }
  }
  if (force_field_2_vdW_.size() == 0) {
    IMP_FAILURE("NONBONDED params not found in CHARMM parameter file");
  }
}
开发者ID:salilab,项目名称:imp,代码行数:74,代码来源:CHARMMParameters.cpp

示例4: read_topology_file

void CHARMMParameters::read_topology_file(TextInput input_file,
                                          bool translate_names_to_pdb) {
  IMP_OBJECT_LOG;
  const String MASS_LINE = "MASS";
  const String DEFA_LINE = "DEFA";
  const String PATC_LINE = "PATC";
  const String RESI_LINE = "RESI";
  const String PRES_LINE = "PRES";
  const String ATOM_LINE = "ATOM";
  const String DELE_LINE = "DELE";
  const String BOND_LINE = "BOND";
  const String BOND_LINE2 = "DOUBLE";
  const String ANGLE_LINE = "ANGL";
  const String ANGLE_LINE2 = "THET";
  const String DIHEDRAL_LINE = "DIHE";
  const String DIHEDRAL_LINE2 = "PHI";
  const String IMPROPER_LINE = "IMPR";
  const String IMPROPER_LINE2 = "IMPH";
  const String IC_LINE = "IC";
  std::string first_patch = "", last_patch = "";
  Pointer<CHARMMIdealResidueTopology> residue;
  Pointer<CHARMMPatch> patch;

  ResidueType curr_res_type;
  while (!input_file.get_stream().eof()) {
    String line;
    getline(input_file.get_stream(), line);
    boost::trim(line);  // remove all spaces
                        // skip comments or empty lines
    if (line[0] == '!' || line[0] == '*' || line.length() == 0) continue;

    // read residue line
    if (line.substr(0, RESI_LINE.length()) == RESI_LINE) {
      if (residue) {
        add_residue_topology(residue.release());
      } else if (patch) {
        add_patch(patch.release());
      }
      curr_res_type = parse_residue_line(line, translate_names_to_pdb);
      ResidueType rt(curr_res_type.get_string());
      residue = new CHARMMIdealResidueTopology(rt);
      residue->set_default_first_patch(first_patch);
      residue->set_default_last_patch(last_patch);

      // handle patch residues
    } else if (line.substr(0, PRES_LINE.length()) == PRES_LINE) {
      if (residue) {
        add_residue_topology(residue.release());
      } else if (patch) {
        add_patch(patch.release());
      }
      Strings split_results;
      boost::split(split_results, line, boost::is_any_of(" \t"),
                   boost::token_compress_on);
      if (split_results.size() < 3) {
        IMP_THROW("Invalid PRES line: " << line, ValueException);
      }
      patch = new CHARMMPatch(
          get_residue_name(split_results[1], translate_names_to_pdb));

      // handle MASS line
    } else if (line.substr(0, MASS_LINE.length()) == MASS_LINE) {
      parse_mass_line(line, atom_type_to_element_);

      // handle DEFA line
    } else if (line.substr(0, DEFA_LINE.length()) == DEFA_LINE) {
      parse_patch_line(line, first_patch, last_patch, translate_names_to_pdb);

      // handle PATC line
    } else if (line.substr(0, PATC_LINE.length()) == PATC_LINE && residue) {
      std::string first = residue->get_default_first_patch();
      std::string last = residue->get_default_last_patch();
      parse_patch_line(line, first, last, translate_names_to_pdb);
      residue->set_default_first_patch(first);
      residue->set_default_last_patch(last);

      // read DELE line
    } else if (line.substr(0, DELE_LINE.length()) == DELE_LINE && patch) {
      parse_dele_line(line, patch, translate_names_to_pdb);

      // read atom line
    } else if (line.substr(0, ATOM_LINE.length()) == ATOM_LINE &&
               (residue || patch)) {
      parse_atom_line(line, curr_res_type, get_residue(residue, patch),
                      translate_names_to_pdb);

      // read bond line
    } else if ((line.substr(0, BOND_LINE.length()) == BOND_LINE ||
                line.substr(0, BOND_LINE2.length()) == BOND_LINE2) &&
               (residue || patch)) {
      parse_bond_line(line, curr_res_type, get_residue(residue, patch),
                      translate_names_to_pdb);

      // read angle line
    } else if ((line.substr(0, ANGLE_LINE.length()) == ANGLE_LINE ||
                line.substr(0, ANGLE_LINE2.length()) == ANGLE_LINE2) &&
               (residue || patch)) {
      parse_angle_line(line, get_residue(residue, patch),
                       translate_names_to_pdb);
      // read dihedral line
//.........这里部分代码省略.........
开发者ID:salilab,项目名称:imp,代码行数:101,代码来源:CHARMMParameters.cpp


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