本文整理汇总了C++中Molecule::countBonds方法的典型用法代码示例。如果您正苦于以下问题:C++ Molecule::countBonds方法的具体用法?C++ Molecule::countBonds怎么用?C++ Molecule::countBonds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Molecule
的用法示例。
在下文中一共展示了Molecule::countBonds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareMolecules
bool compareMolecules(Molecule& mol1, Molecule& mol2)
{
if(mol1.countAtoms()!=mol2.countAtoms())
return false;
if(mol1.countBonds()!=mol2.countBonds())
return false;
AtomIterator ai;
vector<Vector3> pos1;
vector<float> q1;
BALL_FOREACH_ATOM(mol1, ai)
{
pos1.push_back(ai->getPosition());
q1.push_back(ai->getCharge());
}
示例2: write
bool KCFFile::write(const Molecule& molecule)
throw(File::CannotWrite)
{
if (!isOpen() || getOpenMode() != std::ios::out)
{
throw File::CannotWrite(__FILE__, __LINE__, name_);
}
// An alias for simplicity's sake...
std::ostream& os(getFileStream());
// Write ENTRY block
// number of blanks???? properties are not read, written??? Which ones are there?
os << ENTRY_TAG << " " << molecule.getName() << std::endl;
static char buffer[BALL_MAX_LINE_LENGTH];
// Write NODE block
// How to create the KEGG atom types? How many blanks?
// This is not specified in the KCF format description, so we use what we can
// deduce from example files.
// First line gets the NODE tag
os << NODE_TAG << " " << molecule.countAtoms() << "\n";
Size count = 1;
AtomConstIterator ai(molecule.beginAtom());
std::map<const Atom*, Position> atom_to_index;
for (; +ai; ++ai, ++count)
{
// Write the atom line.
// Blanks????
String type = ai->getTypeName();
String comment;
// Make sure the type is in the set of KEGG types????
// Blanks?
sprintf(buffer, " %d %s %s %6.4f %6.4f %s\n",
count, type.c_str(), ai->getElement().getSymbol().c_str(),
ai->getPosition().x, ai->getPosition().y, comment.c_str());
os << buffer;
// Remember the index of the current atom to map atom
// pointers back to indices for the EDGE section.
atom_to_index[&*ai] = count;
}
// Write EDGE block. Walk over all bonds to do so.
// Blanks????
os << "EDGE " << molecule.countBonds() << "\n";
count = 1;
for (ai = molecule.beginAtom(); +ai; ++ai)
{
for (Atom::BondConstIterator bi(ai->beginBond()); +bi; ++bi)
{
Position index1 = atom_to_index[bi->getFirstAtom()];
Position index2 = atom_to_index[bi->getSecondAtom()];
String comment;
// Write every bond just once
if (bi->getFirstAtom() == &*ai)
{
sprintf(buffer, " %4d %4d %4d %1d%s\n",
count, index1, index2, bi->getOrder(), comment.c_str());
os << buffer;
++count;
}
}
}
// Write the DELIMITER block
os << DELIMITER_TAG << std::endl;
return true;
}