本文整理汇总了C++中OBMol::DeleteNonPolarHydrogens方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::DeleteNonPolarHydrogens方法的具体用法?C++ OBMol::DeleteNonPolarHydrogens怎么用?C++ OBMol::DeleteNonPolarHydrogens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::DeleteNonPolarHydrogens方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Do
bool OpDelNonPolarH::Do(OBBase* pOb, const char* OptionText, OpMap* pOptions, OBConversion* pConv)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(!pmol)
return false;
pmol->DeleteNonPolarHydrogens();
return true;
}
示例2: test_Issue178_DeleteHydrogens
// Delete hydrogens should not remove charged or isotopic hydrogens or [H][H] or [Cu][H][Cu]
// or hydrogens with assigned atom classes
void test_Issue178_DeleteHydrogens()
{
OBConversion conv;
conv.SetInFormat("smi");
OBMol mol;
// Test DeleteHydrogens() and DeleteNonPolarHydrogens()
static const char *smi[] = { "C[H]", "[H][H]", "C[1H]", "C[H]C", "C[H+]" };
int numHs[] = { 0, 2, 1, 1, 1 };
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 2; ++j) {
conv.ReadString(&mol, smi[i]);
if (j == 0)
mol.DeleteHydrogens();
else
mol.DeleteNonPolarHydrogens();
int myNumHs = 0;
FOR_ATOMS_OF_MOL(atom, mol)
if (atom->IsHydrogen())
myNumHs++;
OB_COMPARE(myNumHs, numHs[i]);
}
}
// Test DeletePolarHydrogens()
static const char *smiB[] = { "N[H]", "[H][H]", "N[1H]", "N[H]C", "N[H+]" };
int numHsB[] = { 0, 2, 1, 1, 1 };
for (int i = 0; i < 5; ++i) {
conv.ReadString(&mol, smiB[i]);
mol.DeletePolarHydrogens();
int myNumHs = 0;
FOR_ATOMS_OF_MOL(atom, mol)
if (atom->IsHydrogen())
myNumHs++;
OB_COMPARE(myNumHs, numHsB[i]);
}
// Test atom class
// Currently, the SMILES parser does not retain atom classes for hydrogens on reading so...
conv.ReadString(&mol, "C[H]");
OBAtomClassData *ac = new OBAtomClassData;
ac->Add(2, 99); // Assign the hydrogen (atom 2) a class of 99
mol.SetData(ac);
mol.DeleteHydrogens();
int myNumHs = 0;
FOR_ATOMS_OF_MOL(atom, mol)
if (atom->IsHydrogen())
myNumHs++;
OB_COMPARE(myNumHs, 1);
}
示例3: tmpStr
extern "C" char *
ob_delete_hydrogens (char *smiles, int nonpolaronly)
{
OBMol mol;
OBConversion conv;
string tmpStr (smiles);
string outstring;
istringstream molstream1 (tmpStr);
ostringstream molstream2;
char *tmpMolfile;
conv.SetInAndOutFormats ("SMI", "SMI");
conv.Read (&mol, &molstream1);
if(mol.NumHvyAtoms () > 0) {
if (nonpolaronly != 0)
{
mol.DeleteNonPolarHydrogens ();
}
else
{
mol.DeleteHydrogens ();
}
} else {
cout << "Warning: Cannot remove hydrogens. Resulting molecule would be empty!" << endl;
}
conv.Write (&mol, &molstream2);
outstring = molstream2.str ();
// remove the trailling $$$$\n from the SDFile
if (outstring.find ("$$$$\n", 0) != string::npos)
{
outstring = outstring.substr (0, outstring.length () - 5);
}
else if (outstring.find ("$$$$\r\n", 0) != string::npos)
{
outstring = outstring.substr (0, outstring.length () - 6);
}
tmpMolfile = strdup (outstring.c_str ());
return (tmpMolfile);
}