本文整理汇总了C++中OBMol::GetAllData方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::GetAllData方法的具体用法?C++ OBMol::GetAllData怎么用?C++ OBMol::GetAllData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::GetAllData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testTetrahedralStereo1
void testTetrahedralStereo1()
{
cout << "testTetrahedralStereo1()" << endl;
// read a smiles string
OBMol mol;
OBConversion conv;
OB_REQUIRE( conv.SetInFormat("smi") );
cout << "smiles: C[[email protected]](O)N" << endl;
OB_REQUIRE( conv.ReadString(&mol, "C[[email protected]](O)N") );
// get the stereo data
OB_REQUIRE( mol.HasData(OBGenericDataType::StereoData) );
std::vector<OBGenericData *> stereoData = mol.GetAllData(OBGenericDataType::StereoData);
OB_REQUIRE( stereoData.size() == 1 );
// convert to tetrahedral data
OB_REQUIRE( ((OBStereoBase*)stereoData[0])->GetType() == OBStereo::Tetrahedral );
OBTetrahedralStereo *ts = dynamic_cast<OBTetrahedralStereo*>(stereoData[0]);
OB_REQUIRE( ts );
// print the configuration
cout << *ts << endl;
// construct a valid configuration here
//
// C[[email protected]](O)N
// 0 1 2 3 4 <- ids
//
OBTetrahedralStereo::Config cfg(1, 0, OBStereo::MakeRefs(4, 3, 2), OBStereo::Clockwise);
// compare stereochemistry
OB_REQUIRE( ts->GetConfig() == cfg );
cout << endl;
}
示例2: genericSmilesCanonicalTest
void genericSmilesCanonicalTest(const std::string &smiles)
{
cout << "Testing generic smiles <-> canonical smiles" << endl;
// read a smiles string
OBMol mol;
OBConversion conv;
OB_REQUIRE( conv.SetInFormat("smi") );
OB_REQUIRE( conv.SetOutFormat("can") );
cout << "smiles: " << smiles << endl;
// read a smiles string
OB_REQUIRE( conv.ReadString(&mol, smiles) );
// store the stereo data for the smiles string using unique symmetry ids
std::vector<OBTetrahedralStereo::Config> tetrahedral1;
std::vector<OBCisTransStereo::Config> cistrans1;
std::vector<OBSquarePlanarStereo::Config> squareplanar1;
// get the stereo data
OB_ASSERT( mol.HasData(OBGenericDataType::StereoData) );
std::vector<OBGenericData *> stereoData = mol.GetAllData(OBGenericDataType::StereoData);
std::vector<unsigned int> canlbls;
std::vector<unsigned int> symclasses;
OBGraphSym gs1(&mol);
gs1.GetSymmetry(symclasses);
CanonicalLabels(&mol, symclasses, canlbls);
cout << "mol.NumAtoms = " << mol.NumAtoms() << endl;
for (std::vector<OBGenericData*>::iterator data = stereoData.begin(); data != stereoData.end(); ++data) {
if (((OBStereoBase*)*data)->GetType() == OBStereo::Tetrahedral) {
// convert to tetrahedral data
OBTetrahedralStereo *ts = dynamic_cast<OBTetrahedralStereo*>(*data);
OB_REQUIRE( ts );
OB_ASSERT( ts->IsValid() );
if (!ts->IsValid())
continue;
OBTetrahedralStereo::Config config = ts->GetConfig();
// convert atom ids to symmetry ids
if (mol.GetAtomById(config.center))
config.center = canlbls.at( mol.GetAtomById(config.center)->GetIdx() - 1 );
if (mol.GetAtomById(config.from))
config.from = canlbls.at( mol.GetAtomById(config.from)->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[0]))
config.refs[0] = canlbls.at( mol.GetAtomById(config.refs[0])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[1]))
config.refs[1] = canlbls.at( mol.GetAtomById(config.refs[1])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[2]))
config.refs[2] = canlbls.at( mol.GetAtomById(config.refs[2])->GetIdx() - 1 );
cout << "Config with symmetry ids: " << config << endl;
tetrahedral1.push_back(config);
} else
if (((OBStereoBase*)*data)->GetType() == OBStereo::CisTrans) {
// convert to tetrahedral data
OBCisTransStereo *ct = dynamic_cast<OBCisTransStereo*>(*data);
OB_REQUIRE( ct );
OB_ASSERT( ct->IsValid() );
OBCisTransStereo::Config config = ct->GetConfig();
// convert atom ids to symmetry ids
config.begin = canlbls.at( mol.GetAtomById(config.begin)->GetIdx() - 1 );
config.end = canlbls.at( mol.GetAtomById(config.end)->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[0]))
config.refs[0] = canlbls.at( mol.GetAtomById(config.refs[0])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[1]))
config.refs[1] = canlbls.at( mol.GetAtomById(config.refs[1])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[2]))
config.refs[2] = canlbls.at( mol.GetAtomById(config.refs[2])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[3]))
config.refs[3] = canlbls.at( mol.GetAtomById(config.refs[3])->GetIdx() - 1 );
cout << "Config with symmetry ids: " << config << endl;
cistrans1.push_back(config);
} else
if (((OBStereoBase*)*data)->GetType() == OBStereo::SquarePlanar) {
// convert to tetrahedral data
OBSquarePlanarStereo *sp = dynamic_cast<OBSquarePlanarStereo*>(*data);
OB_REQUIRE( sp );
OB_ASSERT( sp->IsValid() );
if (!sp->IsValid())
continue;
OBSquarePlanarStereo::Config config = sp->GetConfig();
// convert atom ids to symmetry ids
if (mol.GetAtomById(config.center))
config.center = canlbls.at( mol.GetAtomById(config.center)->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[0]))
config.refs[0] = canlbls.at( mol.GetAtomById(config.refs[0])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[1]))
config.refs[1] = canlbls.at( mol.GetAtomById(config.refs[1])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[2]))
config.refs[2] = canlbls.at( mol.GetAtomById(config.refs[2])->GetIdx() - 1 );
if (mol.GetAtomById(config.refs[3]))
config.refs[3] = canlbls.at( mol.GetAtomById(config.refs[3])->GetIdx() - 1 );
cout << "Config with symmetry ids: " << config << endl;
squareplanar1.push_back(config);
}
}
// write to can smiles
//.........这里部分代码省略.........
示例3: printf
extern "C" int readgrid_(float *vdata, int *nx, int *ny, int *nz,
float *x0, float *y0, float *z0, float *xx, float *yy, float *zz,
char *file, int fsize) {
float dx,dy,dz;
int gsize;
float v, vmin, vmax, vavg;
int navg = 0;
OBMol mol;
OBConversion conv;
conv.SetInFormat("cube");
std::string fname = file;
int blank = fname.find(" ");
//printf("%d,'%s'\n", blank, fname.substr(0,blank).c_str());
conv.ReadFile(&mol, fname.substr(0,blank).c_str());
//cout << mol.NumAtoms() << " atoms." << endl;
if (mol.HasData(OBGenericDataType::GridData)) {
std::vector<OBGenericData*> grids = mol.GetAllData(OBGenericDataType::GridData);
OBGridData *grid = dynamic_cast<OBGridData *> (grids[0]);
gsize = grid->GetNumberOfPoints();
grid->GetNumberOfPoints(*nx, *ny, *nz);
vector3 origin = grid->GetOriginVector();
*x0 = origin[0]; *y0 = origin[1]; *z0 = origin[2];
vector3 maxv = grid->GetMaxVector();
*xx = maxv[0]; *yy = maxv[1]; *zz = maxv[2];
dx=(*xx-*x0)/(*nx-1);
dy=(*yy-*y0)/(*ny-1);
dz=(*zz-*z0)/(*nz-1);
printf("%s %d=%d*%d*%d\n", grid->GetAttribute().c_str(), gsize, *nx, *ny, *nz);
printf("%f %f\n", grid->GetMinValue(), grid->GetMaxValue());
printf("%f,%f,%f\n", *x0,*y0,*z0);
printf("%f,%f,%f\n", *xx,*yy,*zz);
printf("%f,%f,%f\n", dx,dy,dz);
//vdata = (float *)calloc(gsize, sizeof(float));
/* this is for fortran, so reverse sense of slowest/fastest moving dimensions */
//for (int i=0; i<*nx; ++i) {
vmin = grid->GetValue(0,0,0);
vmax = vmin;
for (int i=0; i<*nz; ++i) {
for (int j=0; j<*ny; ++j) {
//for (int k=0; k<*nz; ++k) {
for (int k=0; k<*nx; ++k) {
//*vdata++ = grid->GetValue(i,j,k);
v = grid->GetValue(k,j,i);
if (v < 1e30 && v > -1e30) {
if (v < vmin) vmin = v;
if (v > vmax) vmax = v;
++navg;
vavg += v;
} else {
v = vmax * 1000; // just a guess
}
*vdata++ = v;
}
}
}
}
vavg = vavg/navg;
printf("min/avg/max = %f/%f/%f\n", vmin, vavg, vmax);
return 0;
}