25 #include <openbabel/babelconfig.h> 28 # define EXTERN extern 33 # elif (__cplusplus >= 201103L) 35 # define THREAD_LOCAL thread_local 57 class OBInternalCoord;
62 class OBMolAtomDFSIter;
72 #define OB_SSSR_MOL (1<<1) 73 #define OB_RINGFLAGS_MOL (1<<2) 75 #define OB_AROMATIC_MOL (1<<3) 77 #define OB_ATOMTYPES_MOL (1<<4) 79 #define OB_CHIRALITY_MOL (1<<5) 81 #define OB_PCHARGE_MOL (1<<6) 83 #define OB_HYBRID_MOL (1<<8) 85 #define OB_CLOSURE_MOL (1<<11) 87 #define OB_H_ADDED_MOL (1<<12) 89 #define OB_PH_CORRECTED_MOL (1<<13) 91 #define OB_CHAINS_MOL (1<<15) 93 #define OB_TCHARGE_MOL (1<<16) 95 #define OB_TSPIN_MOL (1<<17) 97 #define OB_RINGTYPES_MOL (1<<18) 99 #define OB_PATTERN_STRUCTURE (1<<19) 101 #define OB_LSSR_MOL (1<<20) 103 #define OB_ATOMSPIN_MOL (1<<21) 105 #define OB_REACTION_MOL (1<<22) 109 #define SET_OR_UNSET_FLAG(X) \ 110 if (value) SetFlag(X); \ 113 #define OB_CURRENT_CONFORMER -1 160 if (natoms > 0 && _mod) {
161 _vatom.reserve(natoms);
162 _atomIds.reserve(natoms);
168 virtual void DestroyAtom(
OBAtom*);
171 virtual void DestroyBond(
OBBond*);
180 bool AddAtom(
OBAtom& atom,
bool forceNewId =
false);
183 bool InsertAtom(
OBAtom &);
191 bool AddBond(
int beginIdx,
int endIdx,
int order,
192 int flags=0,
int insertpos=-1);
207 OBAtom *NewAtom(
unsigned long id);
215 OBBond *NewBond(
unsigned long id);
222 bool DeleteAtom(
OBAtom*,
bool destroyAtom =
true);
225 bool DeleteBond(
OBBond*,
bool destroyBond =
true);
228 bool DeleteResidue(
OBResidue*,
bool destroyResidue =
true);
233 virtual void BeginModify(
void);
240 virtual void EndModify(
bool nukePerceivedData=
true);
253 int GetFlags() {
return(_flags); }
257 const char *GetTitle(
bool replaceNewlines =
true)
const;
263 unsigned int NumHvyAtoms();
265 unsigned int NumResidues()
const {
return(static_cast<unsigned int> (_residue.size())); }
267 unsigned int NumRotors(
bool sampleRingBonds=
false);
271 OBAtom *GetAtom(
int idx)
const;
273 OBAtom *GetAtomById(
unsigned long id)
const;
276 OBAtom *GetFirstAtom()
const;
279 OBBond *GetBond(
int idx)
const;
281 OBBond *GetBondById(
unsigned long id)
const;
284 OBBond *GetBond(
int a,
int b)
const;
291 std::vector<OBInternalCoord*> GetInternalCoord();
296 double GetTorsion(
int,
int,
int,
int);
309 std::string GetFormula();
311 std::string GetSpacedFormula(
int ones=0,
const char* sp=
" ",
bool implicitH =
true);
315 double GetMolWt(
bool implicitH =
true);
319 int GetTotalCharge();
321 unsigned int GetTotalSpinMultiplicity();
327 std::vector<OBRing*> &GetSSSR();
329 std::vector<OBRing*> &GetLSSR();
339 void SetTitle(
const char *title);
342 void SetTitle(std::string &title);
344 void SetFormula(std::string molFormula);
350 void SetTotalCharge(
int charge);
353 void SetTotalSpinMultiplicity(
unsigned int spinMultiplicity);
359 void SetInternalCoord(std::vector<OBInternalCoord*> int_coord);
362 { _autoFormalCharge=val; }
365 { _autoPartialCharge=val; }
396 bool HasFlag(
int flag) {
return (_flags & flag) ? true :
false; }
405 virtual OBBase* DoTransformations(
const std::map<std::string,std::string>* pOptions,
OBConversion* pConv);
407 static const char* ClassDescription();
411 void RenumberAtoms(std::vector<OBAtom*>&);
413 void RenumberAtoms(std::vector<int>);
416 void SetCoordinates(
double *c);
418 void ToInertialFrame(
int conf,
double *rmat);
420 void ToInertialFrame();
422 void Translate(
const vector3 &v);
424 void Translate(
const vector3 &v,
int conf);
426 void Rotate(
const double u[3][3]);
428 void Rotate(
const double m[9]);
430 void Rotate(
const double m[9],
int nconf);
435 bool DeleteHydrogens();
438 bool DeleteHydrogens(
OBAtom*);
442 bool DeletePolarHydrogens();
445 bool DeleteNonPolarHydrogens();
448 bool DeleteHydrogen(
OBAtom*);
455 bool AddHydrogens(
bool polaronly=
false,
bool correctForPH=
false,
double pH=7.4);
457 bool AddHydrogens(
OBAtom*);
459 bool AddPolarHydrogens();
462 bool AddNonPolarHydrogens();
465 bool AddNewHydrogens(
HydrogenType whichHydrogen,
bool correctForPH=
false,
double pH=7.4);
470 bool StripSalts(
unsigned int threshold=0);
472 std::vector<OBMol> Separate(
int StartIndex=1);
477 unsigned int correctvalence=1,
478 std::vector<unsigned int> *atomorder=(std::vector<unsigned int>*)0,
479 std::vector<unsigned int> *bondorder=(std::vector<unsigned int>*)0);
481 bool ConvertDativeBonds();
485 bool MakeDativeBonds();
491 bool ConvertZeroBonds();
494 bool CorrectForPH(
double pH=7.4);
496 bool AssignSpinMultiplicity(
bool NoImplicitH=
false);
501 bool AssignTotalChargeToAtoms(
int charge);
521 void FindRingAtomsAndBonds();
523 void FindChildren(std::vector<int> & children,
int bgnIdx,
int endIdx);
525 void FindChildren(std::vector<OBAtom*>& children,
OBAtom* bgn,
OBAtom* end);
530 void FindLargestFragment(
OBBitVec &frag);
533 void ContigFragList(std::vector<std::vector<int> >&);
537 void ConnectTheDots();
539 void PerceiveBondOrders();
545 bool GetGTDVector(std::vector<int> &);
547 void GetGIVector(std::vector<unsigned int> &);
549 void GetGIDVector(std::vector<unsigned int> &);
554 bool Has2D(
bool Not3D=
false);
559 bool HasNonZeroCoords();
591 bool Empty() {
return(_natoms == 0); }
596 int NumConformers() {
return((_vconf.empty())?0:static_cast<int> (_vconf.size())); }
599 void SetConformers(std::vector<double*> &v);
604 void SetConformer(
unsigned int i);
607 void CopyConformer(
double* c,
int nconf);
609 void DeleteConformer(
int nconf);
613 void SetEnergies(std::vector<double> &energies);
615 std::vector<double> GetEnergies();
618 double GetEnergy(
int ci);
622 { i = _vconf.begin();
623 return((i == _vconf.end()) ? NULL:*i); }
628 return((i == _vconf.end()) ? NULL:*i); }
635 OBAtomIterator BeginAtoms() {
return _vatom.begin(); }
638 OBAtomIterator
EndAtoms() {
return _vatom.begin() + NumAtoms() ; }
642 OBBondIterator
EndBonds() {
return _vbond.begin() + NumBonds() ; }
650 OBAtom *BeginAtom(OBAtomIterator &i);
653 OBAtom *NextAtom(OBAtomIterator &i);
656 OBBond *BeginBond(OBBondIterator &i);
659 OBBond *NextBond(OBBondIterator &i);
664 i = _residue.begin();
665 return((i == _residue.end()) ? NULL:*i);
672 return((i == _residue.end()) ? NULL:*i);
679 i = _internals.begin();
680 return((i == _internals.end()) ? NULL:*i);
688 return((i == _internals.end()) ? NULL:*i);
711 template<
typename T,
int size = sizeof(T)>
721 static const T result = 0;
731 #define BUFF_SIZE 32768 735 #define EQ(a,b) (!strcmp((a), (b))) 739 #define EQn(a,b,n) (!strncmp((a), (b), (n))) 743 #define SQUARE(x) ((x)*(x)) 747 #define IsUnsatType(x) (EQ(x,"Car") || EQ(x,"C2") || EQ(x,"Sox") || EQ(x,"Sac") || EQ(x,"Pac") || EQ(x,"So2")) 753 OBAPI
void get_rmat(
double*,
double*,
double*,
int);
754 OBAPI
void ob_make_rmat(
double mat[3][3],
double rmat[9]);
755 OBAPI
void qtrfit (
double *r,
double *f,
int size,
double u[3][3]);
759 OBAPI
void get_rmat(
double*,
double*,
double*,
int);
760 OBAPI
void ob_make_rmat(
double mat[3][3],
double rmat[9]);
761 OBAPI
void qtrfit (
double *r,
double *f,
int size,
double u[3][3]);
Definition: residue.h:336
double * BeginConformer(std::vector< double *>::iterator &i)
Definition: mol.h:621
bool HasClosureBondsPerceived()
Have ring "closure" bonds been assigned? (e.g., OBBond::IsClosure())
Definition: mol.h:579
OBInternalCoord * NextInternalCoord(std::vector< OBInternalCoord *>::iterator &i)
Definition: mol.h:685
void get_rmat(double *, double *, double *, int)
Definition: obutil.cpp:1197
bool HasChiralityPerceived()
Has atom chirality been assigned?
Definition: mol.h:573
#define OB_CHAINS_MOL
Biomolecular chains and residues have been set. See OBChainsParser.
Definition: mol.h:92
#define OB_LSSR_MOL
Largest Set of Smallest Rings (LSSR) done. See OBRing and OBMol::FindLSSR.
Definition: mol.h:102
OBAtomIterator EndAtoms()
Definition: mol.h:638
double superimpose(double *, double *, int)
Definition: obutil.cpp:1103
unsigned int NumAtoms() const
Definition: mol.h:259
void SetPartialChargesPerceived(bool value=true)
Mark that partial charges have been assigned.
Definition: mol.h:384
void SetSpinMultiplicityAssigned(bool value=true)
Definition: mol.h:392
Base classes to build a graph.
#define OB_HYBRID_MOL
Atom hybridizations have been set. See OBAtomTyper.
Definition: mol.h:84
void IncrementMod()
Definition: mol.h:245
Class to convert from one format to another.
Definition: obconversion.h:59
std::vector< OBBond * > _vbond
vector of bonds
Definition: mol.h:127
int _flags
bitfield of flags
Definition: mol.h:121
#define OB_H_ADDED_MOL
Hyrdogen atoms have been added where needed. See OBMol::AddHydrogens.
Definition: mol.h:88
bool HasChainsPerceived()
Have biomolecule chains and residues been assigned by OBChainsParser?
Definition: mol.h:581
unsigned int _totalSpin
Total spin on the molecule (if not specified, assumes lowest possible spin)
Definition: mol.h:131
OBInternalCoord * BeginInternalCoord(std::vector< OBInternalCoord *>::iterator &i)
Definition: mol.h:677
#define OB_PH_CORRECTED_MOL
pH correction for hydrogen addition has been performed.
Definition: mol.h:90
void SetIsReaction(bool value=true)
Definition: mol.h:395
std::string _title
Molecule title.
Definition: mol.h:124
#define OB_RINGTYPES_MOL
Ring typing has been performed. See OBRingTyper.
Definition: mol.h:98
Bond class.
Definition: bond.h:58
void SetRingAtomsAndBondsPerceived(bool value=true)
Mark that rings have been perceived (see OBRing class for details)
Definition: mol.h:374
std::vector< OBResidue * > _residue
Residue information (if applicable)
Definition: mol.h:137
#define OB_REACTION_MOL
Treat as reaction.
Definition: mol.h:106
bool HasAtomTypesPerceived()
Have atom types been assigned by OBAtomTyper?
Definition: mol.h:569
double _energy
heat of formation
Definition: mol.h:134
Molecule Class.
Definition: mol.h:118
double * GetConformer(int i)
Definition: mol.h:611
bool Empty()
Are there any atoms in this molecule?
Definition: mol.h:591
#define SET_OR_UNSET_FLAG(X)
Definition: mol.h:109
void SetLSSRPerceived(bool value=true)
Mark that Largest Set of Smallest Rings has been run (see OBRing class)
Definition: mol.h:372
#define OB_CHIRALITY_MOL
Chirality detection has been performed.
Definition: mol.h:80
bool HasAromaticPerceived()
Has aromatic perception been performed?
Definition: mol.h:561
void SetChainsPerceived(bool value=true)
Mark that chains and residues have been perceived (see OBChainsParser)
Definition: mol.h:380
void SetDimension(unsigned short int d)
Set the dimension of this molecule (i.e., 0, 1 , 2, 3)
Definition: mol.h:348
std::vector< OBInternalCoord * > _internals
Internal Coordinates (if applicable)
Definition: mol.h:138
static const unsigned long NoId
Definition: mol.h:726
void ReserveAtoms(int natoms)
Definition: mol.h:158
OBBondIterator BeginBonds()
Definition: mol.h:640
void qtrfit(double *r, double *f, int size, double u[3][3])
Definition: obutil.cpp:686
void ThrowError(char *str)
Definition: obutil.cpp:55
A speed-optimized vector of bits.
Definition: bitvec.h:57
#define OB_PCHARGE_MOL
Partial charges have been set or percieved.
Definition: mol.h:82
void SetEnergy(double energy)
Set the heat of formation for this molecule (in kcal/mol)
Definition: mol.h:346
bool IsReaction()
Does this OBMol represent a reaction?
Definition: mol.h:589
void SetCorrectedForPH(bool value=true)
Definition: mol.h:391
#define OB_RINGFLAGS_MOL
Ring flags have been set: See OBRing::FindRingAtomsAndBonds.
Definition: mol.h:74
std::vector< double * > & GetConformers()
Definition: mol.h:630
std::vector< OBAtom * >::iterator OBAtomIterator
A standard iterator over a vector of atoms.
Definition: atom.h:48
std::vector< OBBond * > _bondIds
vector of bonds
Definition: mol.h:128
void SetAtomTypesPerceived(bool value=true)
Mark that atom types have been perceived (see OBAtomTyper for details)
Definition: mol.h:376
double GetEnergy() const
Definition: mol.h:313
void SetClosureBondsPerceived(bool value=true)
Mark that ring closure bonds have been assigned by graph traversal.
Definition: mol.h:388
std::vector< OBBond * >::iterator OBBondIterator
A standard iterator over a vector of bonds.
Definition: atom.h:46
std::vector< OBAtom * > _vatom
vector of atoms
Definition: mol.h:125
double * NextConformer(std::vector< double *>::iterator &i)
Definition: mol.h:626
void SetRingTypesPerceived(bool value=true)
Mark that ring types have been perceived (see OBRingTyper for details)
Definition: mol.h:378
void CartesianToInternal(std::vector< OBInternalCoord *> &, OBMol &)
Convert Cartesian XYZ to a set of OBInternalCoord coordinates.
Definition: obutil.cpp:547
void InternalToCartesian(std::vector< OBInternalCoord *> &, OBMol &)
Convert set of OBInternalCoord coordinates into Cartesian XYZ.
Definition: obutil.cpp:444
double * _c
coordinate array
Definition: mol.h:132
Used to transform from z-matrix to cartesian coordinates.
Definition: internalcoord.h:61
OBResidueIterator EndResidues()
Definition: mol.h:646
OBResidue * BeginResidue(OBResidueIterator &i)
Definition: mol.h:662
Represents a vector in 3-dimensional real space.
Definition: vector3.h:44
bool HasSSSRPerceived()
Has the smallest set of smallest rings (FindSSSR) been performed?
Definition: mol.h:563
a C++ template to return the maximum value of a type (e.g., int)
Definition: mol.h:712
bool AutomaticPartialCharge()
Get the current flag for whether partial charges are auto-determined.
Definition: mol.h:333
HydrogenType
Definition: mol.h:115
double GetExactMass(unsigned int atomic_number, unsigned int isotope=0)
Definition: elements.cpp:831
void SetHydrogensAdded(bool value=true)
Mark that explicit hydrogen atoms have been added.
Definition: mol.h:390
unsigned short int GetDimension() const
Definition: mol.h:323
void SetFlags(int flags)
Definition: mol.h:399
bool HasLSSRPerceived()
Has the largest set of smallest rings (FindLSSR) been performed?
Definition: mol.h:565
bool HasRingTypesPerceived()
Have ring types been assigned by OBRingTyper?
Definition: mol.h:571
unsigned short int _dimension
Dimensionality of coordinates.
Definition: mol.h:129
void SetIsPatternStructure(bool value=true)
The OBMol is a pattern, not a complete molecule. Left unchanged by Clear().
Definition: mol.h:394
bool HasPartialChargesPerceived()
Have atomic Gasteiger partial charges been assigned by OBGastChrg?
Definition: mol.h:575
#define OB_AROMATIC_MOL
Aromatic flags have been set for atoms and bonds.
Definition: mol.h:76
void AddConformer(double *f)
Add a new set of coordinates f as a new conformer.
Definition: mol.h:601
#define OB_SSSR_MOL
Smallest Set of Smallest Rings (SSSR) done. See OBRing and OBMol::FindSSSR.
Definition: mol.h:72
void SetHybridizationPerceived(bool value=true)
Mark that hybridization of all atoms has been assigned.
Definition: mol.h:386
bool _autoFormalCharge
Assign formal charges automatically.
Definition: mol.h:123
void SetFlag(int flag)
Definition: mol.h:397
void SetChiralityPerceived(bool value=true)
Mark that chirality has been perceived.
Definition: mol.h:382
unsigned int NumBonds() const
Definition: mol.h:261
std::string NewExtension(std::string &, char *)
Utility function: replace the last extension in string &src with new extension char *ext...
Definition: obutil.cpp:109
void SetAromaticPerceived(bool value=true)
Mark that aromaticity has been perceived for this molecule (see OBAromaticTyper)
Definition: mol.h:368
void SetAutomaticPartialCharge(bool val)
Set the flag for determining partial charges automatically (default=true)
Definition: mol.h:364
bool HasHybridizationPerceived()
Has atomic hybridization been assigned by OBAtomTyper?
Definition: mol.h:577
std::vector< double * > _vconf
vector of conformers
Definition: mol.h:133
std::vector< OBAtom * > _atomIds
vector of atoms indexed by id
Definition: mol.h:126
void DecrementMod()
Definition: mol.h:248
unsigned short int _mod
Number of nested calls to BeginModify()
Definition: mol.h:139
unsigned int _natoms
Number of atoms.
Definition: mol.h:135
OBBondIterator EndBonds()
Definition: mol.h:642
unsigned int NumResidues() const
Definition: mol.h:265
#define OB_ATOMSPIN_MOL
SpinMultiplicities on atoms have been set in OBMol::AssignSpinMultiplicity()
Definition: mol.h:104
bool IsCorrectedForPH()
Has the molecule been corrected for pH by CorrectForPH?
Definition: mol.h:585
double * GetCoordinates()
Definition: mol.h:325
bool HasRingAtomsAndBondsPerceived()
Have ring atoms and bonds been assigned?
Definition: mol.h:567
#define OB_PATTERN_STRUCTURE
A pattern, not a complete molecule.
Definition: mol.h:100
void SetSSSRPerceived(bool value=true)
Mark that Smallest Set of Smallest Rings has been run (see OBRing class)
Definition: mol.h:370
unsigned int _nbonds
Number of bonds.
Definition: mol.h:136
#define OB_CLOSURE_MOL
Ring "closure" bonds have been set. See OBBond::IsClosure.
Definition: mol.h:86
#define OB_ATOMTYPES_MOL
Atom typing has been performed. See OBAtomTyper.
Definition: mol.h:78
bool HasHydrogensAdded()
Have hydrogens been added to the molecule?
Definition: mol.h:583
OBResidueIterator BeginResidues()
Definition: mol.h:644
void SetAutomaticFormalCharge(bool val)
Set the flag for determining automatic formal charges with pH (default=true)
Definition: mol.h:361
int GetMod()
Definition: mol.h:242
void UnsetFlag(int flag)
Definition: mol.h:398
int _totalCharge
Total charge on the molecule.
Definition: mol.h:130
std::vector< OBResidue * >::iterator OBResidueIterator
Definition: mol.h:67
Base Class.
Definition: base.h:239
bool HasSpinMultiplicityAssigned()
Has total spin multiplicity been assigned?
Definition: mol.h:587
Residue information.
Definition: residue.h:50
bool AutomaticFormalCharge()
Get the current flag for whether formal charges are set with pH correction.
Definition: mol.h:331
bool _autoPartialCharge
Assign partial charges automatically.
Definition: mol.h:122
OBResidue * NextResidue(OBResidueIterator &i)
Definition: mol.h:669
bool HasFlag(int flag)
Definition: mol.h:396
void ob_make_rmat(double mat[3][3], double rmat[9])
Definition: obutil.cpp:896
Iterate over all atoms in an OBMol in a depth-first search (DFS)
Definition: obiter.h:67
Global namespace for all Open Babel code.
Definition: alias.h:22
Atom class.
Definition: atom.h:71