/usr/include/BALL/KERNEL/bond.h is in libball1.4-dev 1.4.1+20111206-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | // -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_KERNEL_BOND_H
#define BALL_KERNEL_BOND_H
#ifndef BALL_CONCEPT_PROPERTY_H
# include <BALL/CONCEPT/property.h>
#endif
#ifndef BALL_CONCEPT_COMPOSITE_H
# include <BALL/CONCEPT/composite.h>
#endif
#ifndef BALL_CONCEPT_ATOMCONTAINER_H
# include <BALL/KERNEL/atomContainer.h>
#endif
#define BALL_BOND_DEFAULT_FIRST_ATOM 0
#define BALL_BOND_DEFAULT_SECOND_ATOM 0
#define BALL_BOND_DEFAULT_NAME ""
#define BALL_BOND_DEFAULT_ORDER ORDER__UNKNOWN
#define BALL_BOND_DEFAULT_TYPE TYPE__UNKNOWN
namespace BALL
{
class Atom;
class Fragment;
class System;
/** Bond class.
An instance of Bond represents a bond between two atoms.
There can be only one bond between two atoms (double, triple, etc. bonds are represented
using just one bond and an appropriate value for the bond order attribute, see \link setBondOrder setBondOrder \endlink ).
\par
The "first" and "second" atom are assigned in a unique way: the first atom is always
the atom with the lower \link Handle Handle \endlink than the second atom.
\par
The "state" of a bond is defined by its attributes:
- "first atom" ( \link Bond::first_ Bond::first_ \endlink )
- "second atom" ( \link Bond::second_ Bond::second_ \endlink )
- "bond name" ( \link Bond::name_ Bond::name_ \endlink ): an arbitrary name
- "bond order" ( \link Bond::bond_order_ Bond::bond_order_ \endlink ): the order, i.e. single, double, triple,...
- "bond type" ( \link Bond::bond_type_ Bond::bond_type_ \endlink ): covalent, hydrogen bond, etc. to identify non-standard bond types
Bond equality is defined as bond identity.
A linear ordering of bonds is defined as the linear order of the \link Object::Handle Object::Handle \endlink s.
\ingroup KernelMiscellaneous
*/
class BALL_EXPORT Bond
: public Composite,
public PropertyManager
{
public:
///
friend class Atom;
BALL_CREATE_DEEP(Bond)
/** @name Exceptions
*/
//@{
/** Not bound to two atoms.
* This exception may be thrown by \link getLength getLength \endlink if this instance is not bound.
*/
class BALL_EXPORT NotBound
: public Exception::GeneralException
{
public:
NotBound(const char* file, int line);
};
//@}
/** @name Type definitions
*/
//@{
/** Bond type.
*/
typedef short Order;
typedef short Type;
//@}
/** @name Enumerations
*/
//@{
/** Predefined constants for the bond order
*/
enum BondOrder
{
/// Default value.
ORDER__UNKNOWN = 0,
/// Single bond.
ORDER__SINGLE = 1,
/// Double bond.
ORDER__DOUBLE = 2,
/// Triple Bond.
ORDER__TRIPLE = 3,
/// Quadruple bond.
ORDER__QUADRUPLE = 4,
/// Aromatic bonds.
ORDER__AROMATIC = 5,
/// Any bond orders (useful for predicates).
ORDER__ANY = 6,
/// The number of bond orders.
NUMBER_OF_BOND_ORDERS
};
/** Predefined constants for the bond type.
Those are just defined for convenience but they are not
used right now.
*/
enum BondType
{
///
TYPE__UNKNOWN = 0,
///
TYPE__COVALENT = 1,
///
TYPE__HYDROGEN = 2,
///
TYPE__DISULPHIDE_BRIDGE = 3,
///
TYPE__SALT_BRIDGE = 4,
///
TYPE__PEPTIDE = 5,
///
NUMBER_OF_BOND_TYPES
};
/** Predefined properties.
Enumeration of all properties that are used by Bond.
*/
enum Property
{
/// This property can be used to store aromaticity information without overwriting bond orders.
IS_AROMATIC = 0,
///
NUMBER_OF_PROPERTIES
};
//@}
/** @name Constructors and Destructors
*/
//@{
/** Default constructor.
* The state of this bond is:
* - bond has no first atom (=0)
* - bond has no second atom (=0)
* - bond name is the empty string (="")
* - bond order is unknown (= \link Bond::ORDER__UNKNOWN Bond::ORDER__UNKNOWN \endlink )
* - bond type is unknown (= \link Bond::TYPE__UNKNOWN Bond::TYPE__UNKNOWN \endlink )
*/
Bond();
/** Copy constructor.
* Calls \link Bond::createBond Bond::createBond \endlink .
* The state of this bond is initialized to the state of bond.
* \par
* <b>Note:</b> Deep copying of bonds makes no sense, the parameter <tt>deep</tt> is therefore
* ignored. The use of this method is not recommended because it may result in inconcistencies
* of the whole the kernel data structure. This if for internal use only!
* @param bond the bond to be copied
* @param deep ignored
* @see createBond
*/
Bond(const Bond& bond, bool deep = true);
/** Detailed constructor.
* Calls \link createBond createBond \endlink to create a new bond between the two atoms
* @param name name of the constructed bond
* @param first first atom of the constructed bond
* @param second second atom of the constructed bond
* @param order order of the constructed bond
* @param type type of the constructed bond
* @exception TooManyBonds if one of the atom already possesses \link Atom::MAX_NUMBER_OF_BONDS Atom::MAX_NUMBER_OF_BONDS \endlink bonds.
*/
Bond(const String& name, Atom& first, Atom& second, Order order = BALL_BOND_DEFAULT_ORDER,
Type type = BALL_BOND_DEFAULT_TYPE);
/** Create a bond.
* Connect the two atoms <tt>first</tt> and <tt>second</tt> via a bond.
* @param bond the instantiated bond that connects the first atom <tt>first</tt>
* to the second atom <tt>second</tt>
* @param first the first atom of the bond
* @param second the second atom of the bond
* @return Bond* <tt>this</tt>
* @exception TooManyBonds if one of the atom already possesses \link Atom::MAX_NUMBER_OF_BONDS Atom::MAX_NUMBER_OF_BONDS \endlink bonds.
*/
static Bond* createBond(Bond& bond, Atom& first, Atom& second);
/** Destructor.
* If the bond is connecting two atoms, they are disconnected.
*/
virtual ~Bond();
/** Disconnect and reset to default state.
* Reset the bond attributes to their default values.
* The state of this bond is:
* - bond has no connectivity with first atom (=0)
* - bond has no connectivity with second atom (=0)
* - bond name is the empty string (="")
* - bond order is unknown (= \link Bond::ORDER__UNKNOWN Bond::ORDER__UNKNOWN \endlink )
* - bond type is unknown (= \link Bond::TYPE__UNKNOWN Bond::TYPE__UNKNOWN \endlink )
*/
virtual void clear();
/** Explicit destructor.
* Destroy this bond explicitly without releasing its heap memory thus
* this bond may exist further. Calls \link Bond::clear Bond::clear \endlink .
* Set the state of this bond to the default values.
* <b>Note:</b> Destroy is equivalent to \link Bond::clear Bond::clear \endlink .
* @see Bond::clear
*/
virtual void destroy();
//@}
/** @name Persistence
*/
//@{
/** Write a bond to a persistent stream.
* @param pm the persistence manager
*/
void persistentWrite(PersistenceManager& pm, const char* name = 0) const;
/** Read a bond from a persistent stream.
* @param pm the persistence manager
*/
void persistentRead(PersistenceManager& pm);
/** Finalize the deserialization.
* Bond might have to swap <tt>first_</tt> and <tt>second_</tt> to ensure
* the correct order (see \link Bond Bond \endlink ).
*/
void finalize();
//@}
/** @name Predicates
*/
//@{
/// Equality operator. Two bonds are equal, if they are identical instances.
bool operator == (const Bond& bond) const;
/// Inequality operator. Two bonds are not equal, if they are different instances.
bool operator != (const Bond& bond) const;
//@}
/** @name Assignment methods
*/
//@{
/** Assignment operator.
Assign a deep copy (on the level of \link Composite Composite \endlink ).
<b>Note:</b> The use of this method is not recommended because it may result in inconcistencies
of the whole system. This is for internal use only.
@param bond the bond to be copied
@return Bond - this bond
@see Bond::set
*/
Bond& operator = (const Bond& bond);
/** Swap the contents of two bonds
@param bond the bond <tt>this</tt> is being swapped with
@see Bond::Bond
*/
void swap(Bond& bond);
//@}
/** @name Accessors
*/
//@{
/** Set the first atom.
This method does not ensure the correct order of atoms
(see \link Bond Bond \endlink ), so its use is recommended for internal purposes only.
*/
void setFirstAtom(Atom* atom);
/** Set the second atom.
This method does not ensure the correct order of atoms
(see \link Bond Bond \endlink ), so its use is recommended for internal purposes only.
*/
void setSecondAtom(Atom* atom);
/// Return a pointer to the first atom
const Atom* getFirstAtom() const;
/// Return a pointer to the first atom
Atom* getFirstAtom();
/// Return a pointer to the second atom.
const Atom* getSecondAtom() const;
/// Return a pointer to the second atom.
Atom* getSecondAtom();
/** Return the partner atom of an atom.
If the given <tt>atom</tt> is part of this bond, the other atom
of the bond is returned. 0 is returned if <tt>atom</tt> is not
one of the bond's atoms.
@param atom one of the bond's atoms
@return the atom's bond partner
*/
Atom* getPartner(const Atom& atom) const;
/// Assign the atom name
void setName(const String& name);
/// Return the atom name
const String& getName() const;
/// Assign the bond order
void setOrder(Order bond_order);
/// Return the bond order
Order getOrder() const;
/** Returns true if this bond is aromatic.
*
* A bond is defined as aromatic, if it has the property Bond::IS_AROMATIC or if
* it has the order Bond::ORDER__AROMATIC
*/
bool isAromatic() const;
/// Set the bond type
void setType(Type bond_type);
/// Return the bond type
Type getType() const;
/** Return the bond length
* @return float - the distance between the two atoms
* @exception NotBound if the bond is not bound to two atoms
*/
float getLength() const;
/** Return the partner of the atom in this bond.
@param atom an atom
@return Atom a constant pointer to the atom,
0 if the atom is not part of the bond
*/
const Atom* getBoundAtom(const Atom& atom) const;
/** Return the partner of the atom in this bond.
@param atom an atom
@return Atom a pointer to the atom,
0 if the atom is not part of the bond
*/
Atom* getBoundAtom(const Atom& atom);
//@}
/** @name Predicates
*/
//@{
/** Determine whether the bond belongs to an atom.
Calls \link Atom::hasBond Atom::hasBond \endlink .
@param atom the atom that is queried to connect this bond to another atom
@return bool - <tt>true</tt> if bond connects the atom <b> atom </b> with another atom,
<tt>false</tt> otherwise
@see Atom::hasBond
*/
bool isBondOf(const Atom& atom) const;
/** Determine whether this bond contains any atom.
@return bool - <tt>true</tt> if bond connects the atom <b> atom </b> with another atom,
<tt>false</tt> otherwise
@see Atom::hasBond
*/
bool isBound() const;
/** Determine whether the bond connects two fragments.
If both atoms have no roots, the result is false.
Calls \link Composite::getRoot Composite::getRoot \endlink .
@return bool - <tt>true</tt> if this bond is intermolecular,
<tt>false</tt> otherwise
@see Composite::getRoot
*/
bool isInterBond() const;
/** Request for the intermolecular bonding of this bond within {\em atom_container}.
Query, if this bond connects a atom within {\em atom_container} instance with an atom outside.
Calls \link Composite::isDescendantOf Composite::isDescendantOf \endlink .
@param atom_container the queried parent fragment.
@return bool - <tt>true</tt> if this bond is intermolecular,
<tt>false</tt> otherwise
@see Composite::isDescendantOf
*/
bool isInterBondOf(const AtomContainer& atom_container) const;
/** Request for the intramolecular bonding of this bond.
Query, if this bond connects its two atoms within a common parent \link Composite Composite \endlink instance.
If both atoms have no roots, the result is true.
Calls \link Composite::getRoot Composite::getRoot \endlink .
@return bool - <tt>true</tt> if this bond is intramolecular,
<tt>false</tt> otherwise
@see Composite::getRoot
*/
bool isIntraBond() const;
/** Request for the intramolecular bonding of this bond within {\em atom_container}.
Query, if this bond connects its two atoms within the common parent {\em atom_container} instance.
Calls \link Composite::isDescendantOf Composite::isDescendantOf \endlink .
@param atom_container the queried parent fragment.
@return bool - <tt>true</tt> if this bond is intramolecular,
<tt>false</tt> otherwise
@see Composite::isDescendantOf
*/
bool isIntraBondOf(const AtomContainer& atom_container) const;
//@}
/** @name Debugging and diagnostics
*/
//@{
/** Internal state and consistency self-validation.
@return bool - <tt>true</tt> if the internal state of this bond is correct (self-validated)
and consistent, <tt>false</tt> otherwise
*/
virtual bool isValid() const;
/** Internal state dump.
Dump the current internal state of this bond to the output ostream <b> s </b>
with dumping depth <b> depth </b>.
@param s output stream where to output the internal state of this bond
@param depth the dumping depth
*/
virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
//@}
protected:
/** @name Atributes
*/
//@{
// First atom of the bond (bond owner)
Atom* first_;
// Second atom
Atom* second_;
// Bond name
String name_;
// Bond order
Order bond_order_;
// Bond type
Type bond_type_;
//@}
private:
void arrangeBonds_();
void clear_();
};
# ifndef BALL_NO_INLINE_FUNCTIONS
# include <BALL/KERNEL/bond.iC>
# endif
} // namespace BALL
#endif // BALL_KERNEL_BOND_H
|