本文整理汇总了C++中OBMol::NewBond方法的典型用法代码示例。如果您正苦于以下问题:C++ OBMol::NewBond方法的具体用法?C++ OBMol::NewBond怎么用?C++ OBMol::NewBond使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OBMol
的用法示例。
在下文中一共展示了OBMol::NewBond方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: basicExportTest
/* FUNCTION: basicExportTest */
void OpenBabelImportExportTest::basicExportTest() {
// Create a water molecule for frame 0
//
int frameSetId = entityManager->addFrameSet();
int frameIndex = entityManager->addFrame(frameSetId);
NXMoleculeSet* rootMoleculeSet =
entityManager->getRootMoleculeSet(frameSetId, frameIndex);
OBMol* molecule = rootMoleculeSet->newMolecule();
OBAtom* atomO = molecule->NewAtom();
atomO->SetAtomicNum(etab.GetAtomicNum("O")); // Oxygen
atomO->SetVector(0.00000000, 0.00000000, 0.37000000); // Angstroms
OBAtom* atomH1 = molecule->NewAtom();
atomH1->SetAtomicNum(etab.GetAtomicNum("H")); // Hydrogen
atomH1->SetVector(0.78000000, 0.00000000, -0.18000000);
OBAtom* atomH2 = molecule->NewAtom();
atomH2->SetAtomicNum(etab.GetAtomicNum("H")); // Hydrogen
atomH2->SetVector(-0.78000000, 0.00000000, -0.18000000);
OBBond* bond = molecule->NewBond();
bond->SetBegin(atomO);
bond->SetEnd(atomH1);
bond = molecule->NewBond();
bond->SetBegin(atomO);
bond->SetEnd(atomH2);
// Write it with the OpenBabelImportExport plugin
NXCommandResult* commandResult =
entityManager->exportToFile("testOpenBabel.pdb", frameSetId, -1);
if (commandResult->getResult() != NX_CMD_SUCCESS)
printf("\n%s\n", qPrintable(GetNV1ResultCodeString(commandResult)));
CPPUNIT_ASSERT(commandResult->getResult() == NX_CMD_SUCCESS);
}
示例2: testIdsNewBond1
// OBMol::NewBond()
void testIdsNewBond1()
{
OBMol mol;
for (int i = 0; i < 10; ++i) {
OBBond *bond = mol.NewBond();
OB_REQUIRE(bond->GetId() == i);
}
OB_REQUIRE( mol.GetBondById(0) );
OB_REQUIRE( mol.GetBondById(4) );
OB_REQUIRE( mol.GetBondById(9) );
OB_REQUIRE( !mol.GetBondById(10) );
OB_REQUIRE( mol.GetBondById(0)->GetId() == 0 );
OB_REQUIRE( mol.GetBondById(4)->GetId() == 4 );
OB_REQUIRE( mol.GetBondById(9)->GetId() == 9 );
}
示例3: testIdsAddBond
void testIdsAddBond()
{
OBMol mol;
// add 5 bonds
for (int i = 0; i < 5; ++i)
mol.NewBond();
OBBond bond;
OBAtom *a = mol.NewAtom();
OBAtom *b = mol.NewAtom();
bond.SetBegin(a);
bond.SetEnd(b);
// add a sixth bond
mol.AddBond(bond);
OB_REQUIRE( mol.NumBonds() == 6 );
OB_REQUIRE( mol.GetBondById(5) );
OB_REQUIRE( mol.GetBondById(5)->GetId() == 5 );
}
示例4: testIdsNewBond2
// OBMol::NewBond(unsigned long id)
void testIdsNewBond2()
{
OBMol mol;
for (int i = 0; i < 10; ++i) {
OBBond *bond = mol.NewBond(i*2);
OB_REQUIRE(bond->GetId() == i*2);
}
OB_REQUIRE( mol.GetBondById(0) );
OB_REQUIRE( !mol.GetBondById(7) );
OB_REQUIRE( mol.GetBondById(8) );
OB_REQUIRE( !mol.GetBondById(9) );
OB_REQUIRE( mol.GetBondById(18) );
OB_REQUIRE( !mol.GetBondById(19) );
OB_REQUIRE( mol.GetBondById(0)->GetId() == 0 );
OB_REQUIRE( mol.GetBondById(8)->GetId() == 8 );
OB_REQUIRE( mol.GetBondById(18)->GetId() == 18 );
}
示例5: testIdsDeleteBond
void testIdsDeleteBond()
{
OBMol mol;
for (int i = 0; i < 10; ++i)
mol.NewBond();
OB_REQUIRE( mol.GetBondById(3) );
OB_REQUIRE( mol.GetBondById(4) );
OB_REQUIRE( mol.GetBondById(5) );
OBBond *bond4 = mol.GetBondById(4);
OBAtom *a = mol.NewAtom();
OBAtom *b = mol.NewAtom();
bond4->SetBegin(a);
bond4->SetEnd(b);
mol.DeleteBond(mol.GetBondById(4));
OB_REQUIRE( mol.GetBondById(3) );
OB_REQUIRE( mol.GetBondById(3)->GetId() == 3 );
OB_REQUIRE( !mol.GetBondById(4) );
OB_REQUIRE( mol.GetBondById(5) );
OB_REQUIRE( mol.GetBondById(5)->GetId() == 5 );
}
示例6: mol
//.........这里部分代码省略.........
OBConversion conv(&ifs1, &cout);
OBFormat* pFormat;
pFormat = conv.FindFormat("XYZ");
if ( pFormat == NULL )
{
cout << "Bail out! Cannot read file format!" << endl;
return(-1);
}
if (! conv.SetInAndOutFormats(pFormat, pFormat))
{
cout << "Bail out! File format isn't loaded" << endl;
return (-1);
}
OBMol testMol2D, testMol3D;
if (conv.Read(&testMol3D))
cout << "ok 8\n";
else
cout << "not ok 8\n";
testMol3D.Center();
// test bond insertion (PR#1665649)
OBMol doubleBondMol;
OBAtom *a1, *a2;
OBBond *b;
doubleBondMol.BeginModify();
a1 = doubleBondMol.NewAtom();
a1->SetVector(0.0, 0.0, 0.0);
a1->SetAtomicNum(6);
a2 = doubleBondMol.NewAtom();
a2->SetVector(1.6, 0.0, 0.0);
a2->SetAtomicNum(6);
b = doubleBondMol.NewBond();
b->SetBegin(a1);
b->SetEnd(a2);
a1->AddBond(b);
a2->AddBond(b);
doubleBondMol.EndModify();
cout << "ok 9" << endl;
// test AddHydrogens
OBMol testMolH;
testMolH.BeginModify();
OBAtom *testAtom = testMolH.NewAtom();
testAtom->SetVector(0.5f, 0.5f, 0.5f);
testAtom->SetAtomicNum(6);
testAtom->SetImplicitHCount(4);
testMolH.EndModify();
testMolH.AddHydrogens();
if (testMolH.NumAtoms() == 5) {
cout << "ok 10" << endl;
} else {
cout << "not ok 10" << endl;
}
// test AddHydrogens (pr #1665519)
OBMol testMolH2;
OBAtom *testAtom2 = testMolH2.NewAtom();
testAtom2->SetVector(0.5f, 0.5f, 0.5f);
testAtom2->SetAtomicNum(6);
testAtom2->SetImplicitHCount(4);
testMolH2.AddHydrogens();
if (testMolH2.NumAtoms() == 5) {
cout << "ok 11" << endl;
} else {