18#include "rxdock/Atom.h"
19#include "rxdock/Config.h"
21#include <nlohmann/json.hpp>
23using json = nlohmann::json;
38 int nFormalBondOrder = 1);
55 RBTDLL_EXPORT
friend std::ostream &operator<<(std::ostream &s,
58 friend void to_json(json &j,
const Bond &bond);
59 friend void from_json(
const json &j,
Bond &bond);
66 int GetBondId()
const {
return m_nBondId; }
67 void SetBondId(
const int nBondId) { m_nBondId = nBondId; }
70 AtomPtr GetAtom1Ptr()
const {
return m_spAtom1; }
71 AtomPtr GetAtom2Ptr()
const {
return m_spAtom2; }
72 void SetAtom1Ptr(
AtomPtr &spAtom1) { m_spAtom1 = spAtom1; }
73 void SetAtom2Ptr(
AtomPtr &spAtom2) { m_spAtom2 = spAtom2; }
76 int GetFormalBondOrder()
const {
return m_nFormalBondOrder; }
77 void SetFormalBondOrder(
const int nFormalBondOrder) {
78 m_nFormalBondOrder = nFormalBondOrder;
82 double GetPartialBondOrder()
const {
return m_dPartialBondOrder; }
83 void SetPartialBondOrder(
const double dPartialBondOrder) {
84 m_dPartialBondOrder = dPartialBondOrder;
88 bool GetCyclicFlag()
const {
return m_bCyclic; }
89 void SetCyclicFlag(
bool bCyclic =
true) { m_bCyclic = bCyclic; }
93 bool GetSelectionFlag()
const {
return m_bSelected; }
94 void SetSelectionFlag(
bool bSelected =
true) { m_bSelected = bSelected; }
100 double Length()
const;
124 int m_nFormalBondOrder;
126 double m_dPartialBondOrder;
134typedef std::vector<BondPtr> BondList;
135typedef BondList::iterator BondListIter;
136typedef BondList::const_iterator BondListConstIter;
142std::ostream &operator<<(std::ostream &s,
const Bond &bond);
144void to_json(json &j,
const Bond &bond);
145void from_json(
const json &j,
Bond &bond);
158 bool operator()(
Bond *pBond)
const {
return pBond->GetSelectionFlag(); }
165 bool operator()(
Bond *pBond)
const {
return pBond->GetCyclicFlag(); }
172 RBTDLL_EXPORT
bool operator()(
Bond *)
const;
179 RBTDLL_EXPORT
bool operator()(
Bond *)
const;
186 RBTDLL_EXPORT
bool operator()(
Bond *pBond)
const;
205 bool operator()(
Bond *pBond)
const {
return pBond == p; }
216 bool operator()(
Bond *pBond)
const {
217 return ((pBond->GetBondId() == p->GetBondId()) &&
218 (bIsAtomEqual(pBond->GetAtom1Ptr(), p->GetAtom1Ptr())) &&
219 (bIsAtomEqual(pBond->GetAtom2Ptr(), p->GetAtom2Ptr())));
228 RBTDLL_EXPORT
bool operator()(
Bond *)
const;
236template <
class Predicate>
237unsigned int GetNumBondsWithPredicate(
const BondList &bondList,
238 const Predicate &pred) {
239 return static_cast<unsigned int>(
240 std::count_if(bondList.begin(), bondList.end(), pred));
244template <
class Predicate>
245BondList GetBondListWithPredicate(
const BondList &bondList,
246 const Predicate &pred) {
247 BondList newBondList;
248 std::copy_if(bondList.begin(), bondList.end(),
249 std::back_inserter(newBondList), pred);
254template <
class Predicate>
255BondListIter FindBond(BondList &bondList,
const Predicate &pred) {
256 return std::find_if(bondList.begin(), bondList.end(), pred);
260void SetBondSelectionFlagsInList(BondList &bondList,
bool bSelected =
true);
261inline unsigned int GetNumSelectedBondsInList(
const BondList &bondList) {
262 return GetNumBondsWithPredicate(bondList, isBondSelected());
265inline BondList GetSelectedBondsFromList(
const BondList &bondList) {
266 return GetBondListWithPredicate(bondList, isBondSelected());
270void SetBondCyclicFlagsInList(BondList &bondList,
bool bCyclic =
true);
271inline unsigned int GetNumCyclicBondsInList(
const BondList &bondList) {
272 return GetNumBondsWithPredicate(bondList, isBondCyclic());
274inline BondList GetCyclicBondsFromList(
const BondList &bondList) {
275 return GetBondListWithPredicate(bondList, isBondCyclic());
279inline unsigned int GetNumRotatableBonds(
const BondList &bondList) {
280 return GetNumBondsWithPredicate(bondList, isBondRotatable());
282inline BondList GetRotatableBondList(
const BondList &bondList) {
283 return GetBondListWithPredicate(bondList, isBondRotatable());