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


C++ OBMol::GetCoordinates方法代码示例

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


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

示例1: generateCovarMatrixFromMolecule

void generateCovarMatrixFromMolecule(vector<double> &matrix, OBMol &molecule) {
    double uX = 0, uY = 0, uZ = 0, *moleculeCoords = molecule.GetCoordinates();
    for (unsigned int i=0; i < 3 * molecule.NumAtoms(); i+=3) {
        uX += moleculeCoords[i];
        uY += moleculeCoords[i+1];
        uZ += moleculeCoords[i+2];
    }
    uX /= molecule.NumAtoms();
    uY /= molecule.NumAtoms();
    uZ /= molecule.NumAtoms();

    double cXX = 0, cYY = 0, cZZ = 0, cXY = 0, cXZ = 0, cYZ = 0;
    for (unsigned int i=0; i < 3 * molecule.NumAtoms(); i+=3) {
        double atomWeight = molecule.GetAtom(i/3 + 1)->GetAtomicMass(); // getAtoms is 1-based instead of 0-based
        cXX += pow(moleculeCoords[i] - uX, 2) * atomWeight;
        cYY += pow(moleculeCoords[i+1] - uY, 2) * atomWeight;
        cZZ += pow(moleculeCoords[i+2] - uZ, 2) * atomWeight;
        cXY += (moleculeCoords[i] - uX) * (moleculeCoords[i+1] - uY) * atomWeight;
        cXZ += (moleculeCoords[i] - uX) * (moleculeCoords[i+2] - uZ) * atomWeight;
        cYZ += (moleculeCoords[i+1] - uY) * (moleculeCoords[i+2] - uZ) * atomWeight;
    }

    matrix.clear();
    matrix.resize(9);
    matrix[0] = cXX;
    matrix[1] = matrix[3] = cXY;
    matrix[2] = matrix[6] = cXZ;
    matrix[4] = cYY;
    matrix[5] = matrix[7] = cYZ;
    matrix[8] = cZZ;

    for (unsigned int i=0; i < matrix.size(); i++) matrix[i] /= molecule.GetMolWt();
}
开发者ID:q10,项目名称:bmsip,代码行数:33,代码来源:example.cpp

示例2: ProcessVec

bool OpReadConformers::ProcessVec(std::vector<OBBase*>& vec)
{
  // DeferredFormat collects all the molecules, they are processed here, and Deferred Format outputs them
  OBConversion smconv;
  smconv.AddOption("n");
  if(!smconv.SetOutFormat("smi"))
  {
    obErrorLog.ThrowError(__FUNCTION__, "SmilesFormat is not loaded" , obError, onceOnly);
    return false;
  }

  std::string smiles, stored_smiles;
  OBMol* stored_pmol=NULL;
  std::vector<OBBase*>::iterator iter;
  for(iter= vec.begin();iter!=vec.end();++iter)
  {
    OBMol* pmol = dynamic_cast<OBMol*>(*iter);
    if(!pmol)
      continue;
    smiles = smconv.WriteString(pmol);
    Trim(smiles);

    if(stored_smiles==smiles)
    {
      //add the coordinates of the current mol to the stored one as a conformer, and delete current mol
      double *confCoord = new double [pmol->NumAtoms() * 3];
      memcpy((char*)confCoord,(char*)pmol->GetCoordinates(),sizeof(double)*3*pmol->NumAtoms());
      stored_pmol->AddConformer(confCoord);
      delete pmol;
      *iter = NULL;
    }
    else
    {
      stored_pmol = pmol;
      stored_smiles = smiles;
    }
  }

  //erase the NULLS
  vec.erase(std::remove(vec.begin(),vec.end(), (void*)NULL), vec.end());
  return true;
}
开发者ID:baoilleach,项目名称:openbabel-svn-mirror,代码行数:42,代码来源:readconformers.cpp

示例3: Score

double OBEnergyConformerScore::Score(OBMol &mol, unsigned int index,
                                     const RotorKeys &keys, const std::vector<double*> &conformers)
{
    double *origCoords = mol.GetCoordinates();
    // copy the original coordinates to coords
    // copy the conformer coordinates to OBMol object
    std::vector<double> coords(mol.NumAtoms() * 3);
    for (unsigned int i = 0; i < mol.NumAtoms() * 3; ++i) {
        coords[i] = origCoords[i];
        origCoords[i] = conformers[index][i];
    }

    OBForceField *ff = OBForceField::FindType("MMFF94");
    if (!ff->Setup(mol))
        return 10e10;
//    ff->SteepestDescent(500);
    double score = ff->Energy();

    // copy original coordinates back
    for (unsigned int i = 0; i < mol.NumAtoms() * 3; ++i)
        origCoords[i] = coords[i];

    return score;
}
开发者ID:baoilleach,项目名称:openbabel-svn-mirror,代码行数:24,代码来源:conformersearch.cpp

示例4: OutputHeader

  void PovrayFormat::OutputHeader(ostream &ofs, OBMol &mol, string prefix)
  {
    time_t akttime;                              /* Systemtime                        */
    char timestr[TIME_STR_SIZE + 1] = "";        /* Timestring                        */
    size_t time_res;                             /* Result of strftime                */

    /* ---- Get the system-time ---- */
    akttime = time((time_t *) NULL);
    time_res = strftime(timestr,
                        TIME_STR_SIZE,
                        "%a %b %d %H:%M:%S %Z %Y",
                        localtime((time_t *) &akttime)
                        );

    /* ---- Write some header information ---- */
    ofs << "//Povray v3 code generated by Open Babel" << endl;
    ofs << "//Author: Steffen Reith <[email protected]>" << endl;
    ofs << "//Update (2010): Noel O'Boyle and Steven Wathen" << endl;

    /* ---- Include timestamp in header ---- */
    ofs << "//Date: " << timestr << endl << endl;

    /* ---- Set configurable global settings ---- */
    ofs << "//Set some global parameters for display options" << endl;
    ofs << "#declare " << model_type << " = true;" << endl;
    string trans_tex_setting = trans_texture ? "true" : "false";
    ofs << "#declare TRANS = " << trans_tex_setting << ";" << endl << endl;

    /* ---- Background, camera and light source ---- */
    OpenBabel::vector3 centroid = my_center_coords(mol.GetCoordinates(), mol.NumAtoms());

    ofs << "#include \"colors.inc\"\n" << endl;

    ofs <<  "// create a regular point light source\n"
            "light_source {\n"
            "  <" << centroid.x()  + 2.0 << "," << centroid.y() + 3.0 << "," << centroid.z() - 8.0 << ">\n"
            "  color rgb <1,1,1>    // light's color\n"
            "}\n" << endl;

    if (sky) {
      ofs << "// Add some nice sky with clouds\n"
"sky_sphere {\n"
"    pigment {\n"
"      gradient y\n"
"      color_map {\n"
"        [0.0 1.0 color SkyBlue  color NavyBlue]\n"
"      }\n"
"      scale 2\n"
"      translate -1\n"
"    }\n"
"    pigment {\n"
"      bozo\n"
"      turbulence 0.65\n"
"      octaves 6\n"
"      omega 0.7\n"
"      lambda 2\n"
"      color_map {\n"
"          [0.0 0.1 color rgb <0.85, 0.85, 0.85>\n"
"                   color rgb <0.75, 0.75, 0.75>]\n"
"          [0.1 0.5 color rgb <0.75, 0.75, 0.75>\n"
"                   color rgbt <1, 1, 1, 1>]\n"
"          [0.5 1.0 color rgbt <1, 1, 1, 1>\n"
"                   color rgbt <1, 1, 1, 1>]\n"
"      }\n"
"      scale <0.2, 0.5, 0.2>\n"
"    }\n"
"    rotate -135*x\n"
"  }\n" << endl;
    }
    else { // Simple background
      ofs << "// set a color of the background (sky)" << endl;
      ofs << "background { color rgb <0.95 0.95 0.95> }\n" << endl;
    }

    ofs <<  "// perspective (default) camera\n"
            "camera {\n"
            "  location  <" << centroid.x() << "," << centroid.y() << "," << centroid.z() - 10.0 << ">\n"
            "  look_at   <" << centroid.x() << "," << centroid.y() << "," << centroid.z() << ">\n"
            "  right     x*image_width/image_height\n"
            "}\n" << endl;

    /* ---- Checkerboard and mirror sphere ---- */
    if (sphere) {
      ofs <<
"// a mirror sphere\n"
"sphere\n"
"{ <" << centroid.x()  + 8.0 << "," << centroid.y() - 4 << "," << centroid.z() + 8.0 << ">,4\n"
"  pigment { rgb <0,0,0> } // A perfect mirror with no color\n"
"  finish { reflection 1 } // It reflects all\n"
"}\n" << endl;
    }
    if (checkerboard) {
      ofs <<
"// simple Black on White checkerboard... it's a classic\n"
"plane {\n"
" -y, " << -(centroid.y()-8) << "\n"
" pigment {\n"
"  checker color Black color White\n"
"  scale 2\n"
" }\n"
//.........这里部分代码省略.........
开发者ID:Clyde-fare,项目名称:openbabel,代码行数:101,代码来源:povrayformat.cpp


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