Loading...
Searching...
No Matches
kekulizer.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_STRUCTURE_KEKULIZER_H
#define BALL_STRUCTURE_KEKULIZER_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#ifndef BALL_DATATYPE_HASHMAP_H
# include <BALL/DATATYPE/hashMap.h>
#endif
#include <set>
namespace BALL
{
class Atom;
class Molecule;
class Bond;
class BALL_EXPORT Kekuliser
{
struct BALL_EXPORT AtomInfo
{
// needed for sorting:
bool operator < (const AtomInfo& info) const;
AtomInfo& operator = (const AtomInfo& ai) ;
// THE atom
Atom* atom;
// bond to be set to a double bond
Bond* double_bond;
// aromatic bonds
std::vector<Bond*> abonds;
// position of the partner atoms in the vector of AtomInfos
std::vector<Position> partner_id;
// current number of double bonds for this atom
Index curr_double;
// minumum possible number of double bonds for this atom
Index min_double;
// maximum possible number of double bonds for this atom
Index max_double;
// number of double bonds for this atom to be uncharged
Index uncharged_double;
};
public:
BALL_CREATE(Kekuliser)
Kekuliser();
virtual ~Kekuliser() {}
bool setup(Molecule& ac);
void setAromaticRings(const std::vector<std::set<Atom*> >& rings) { aromatic_rings_ = rings;}
void setRings(const std::vector<std::set<Atom*> >& rings) { rings_ = rings;}
const std::vector<Bond*>& getUnassignedBonds() const { return unassigned_bonds_; }
void clear();
void dump();
void setUseFormalCharges(bool state) { use_formal_charges_ = state;}
bool useFormalCharges() const { return use_formal_charges_;}
protected:
bool fixAromaticRings_();
void fixAromaticSystem_(Position it);
virtual Size getPenalty_(Atom& atom, Index charge);
void getMaximumValence_();
// merge aromatic rings:
void calculateAromaticSystems_();
void collectSystems_(Atom& atom);
void collectAromaticAtoms_();
bool hasAromaticBonds_(Atom& atom);
void applySolution_(Position pos);
Position calculateDistanceScores_();
bool use_formal_charges_;
std::vector<std::set<Atom*> > aromatic_systems_;
std::vector<std::set<Atom*> > aromatic_rings_;
std::vector<std::set<Atom*> > rings_;
std::vector<Bond*> unassigned_bonds_;
// atoms that take part in an aromatic bond:
std::set<const Atom*> aromatic_atoms_;
std::set<const Atom*> all_aromatic_atoms_;
HashMap<Atom*, Index> max_valence_;
std::set<Atom*> current_aromatic_system_;
// current aromatic system:
std::vector<AtomInfo> atom_infos_;
Molecule* molecule_;
Size lowest_penalty_;
Size current_penalty_;
std::vector<std::vector<AtomInfo> > solutions_;
};
} // namespace BALL
#endif // BALL_STRUCTURE_KEKULIZER_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::Atom
Definition atom.h:90
BALL::Bond
Definition bond.h:57
BALL::HashMap
HashMap class based on the STL map (containing serveral convenience functions).
Definition hashMap.h:74
BALL::Kekuliser::max_valence_
HashMap< Atom *, Index > max_valence_
Definition kekulizer.h:131
BALL::Kekuliser::aromatic_systems_
std::vector< std::set< Atom * > > aromatic_systems_
Definition kekulizer.h:123
BALL::Kekuliser::dump
void dump()
BALL::Kekuliser::fixAromaticRings_
bool fixAromaticRings_()
BALL::Kekuliser::lowest_penalty_
Size lowest_penalty_
Definition kekulizer.h:138
BALL::Kekuliser::fixAromaticSystem_
void fixAromaticSystem_(Position it)
BALL::Kekuliser::molecule_
Molecule * molecule_
Definition kekulizer.h:137
BALL::Kekuliser::rings_
std::vector< std::set< Atom * > > rings_
Definition kekulizer.h:125
BALL::Kekuliser::calculateAromaticSystems_
void calculateAromaticSystems_()
BALL::Kekuliser::getPenalty_
virtual Size getPenalty_(Atom &atom, Index charge)
BALL::Kekuliser::hasAromaticBonds_
bool hasAromaticBonds_(Atom &atom)
BALL::Kekuliser::applySolution_
void applySolution_(Position pos)
BALL::Kekuliser::calculateDistanceScores_
Position calculateDistanceScores_()
BALL::Kekuliser::current_penalty_
Size current_penalty_
Definition kekulizer.h:139
BALL::Kekuliser::setRings
void setRings(const std::vector< std::set< Atom * > > &rings)
Definition kekulizer.h:88
BALL::Kekuliser::unassigned_bonds_
std::vector< Bond * > unassigned_bonds_
Definition kekulizer.h:126
BALL::Kekuliser::use_formal_charges_
bool use_formal_charges_
Definition kekulizer.h:121
BALL::Kekuliser::setUseFormalCharges
void setUseFormalCharges(bool state)
Definition kekulizer.h:100
BALL::Kekuliser::setup
bool setup(Molecule &ac)
BALL::Kekuliser::Kekuliser
Kekuliser()
BALL::Kekuliser::useFormalCharges
bool useFormalCharges() const
Definition kekulizer.h:103
BALL::Kekuliser::clear
void clear()
BALL::Kekuliser::getUnassignedBonds
const std::vector< Bond * > & getUnassignedBonds() const
Definition kekulizer.h:91
BALL::Kekuliser::getMaximumValence_
void getMaximumValence_()
BALL::Kekuliser::aromatic_rings_
std::vector< std::set< Atom * > > aromatic_rings_
Definition kekulizer.h:124
BALL::Kekuliser::collectSystems_
void collectSystems_(Atom &atom)
BALL::Kekuliser::solutions_
std::vector< std::vector< AtomInfo > > solutions_
Definition kekulizer.h:141
BALL::Kekuliser::all_aromatic_atoms_
std::set< const Atom * > all_aromatic_atoms_
Definition kekulizer.h:130
BALL::Kekuliser::setAromaticRings
void setAromaticRings(const std::vector< std::set< Atom * > > &rings)
Definition kekulizer.h:85
BALL::Kekuliser::aromatic_atoms_
std::set< const Atom * > aromatic_atoms_
Definition kekulizer.h:129
BALL::Kekuliser::collectAromaticAtoms_
void collectAromaticAtoms_()
BALL::Kekuliser::atom_infos_
std::vector< AtomInfo > atom_infos_
Definition kekulizer.h:136
BALL::Kekuliser::current_aromatic_system_
std::set< Atom * > current_aromatic_system_
Definition kekulizer.h:133
BALL::Molecule
Definition molecule.h:31
common.h
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
hashMap.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105