Loading...
Searching...
No Matches
tetranonplanar.h
Go to the documentation of this file.
/**********************************************************************
tetranonplanar.h - OBTetraNonPlanarStereo
Copyright (C) 2009 by Tim Vandermeersch
This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
**********************************************************************/
#ifndef OB_TETRANONPLANAR_H
#define OB_TETRANONPLANAR_H
#include <openbabel/stereo/stereo.h>
#include <openbabel/oberror.h>
namespace OpenBabel {
class OBAPI OBTetraNonPlanarStereo : public OBStereoBase
{
public:
OBTetraNonPlanarStereo(OBMol *mol);
virtual ~OBTetraNonPlanarStereo();
template <typename ConfigType>
static ConfigType ToConfig(const ConfigType &cfg, unsigned long from_or_towards,
OBStereo::Winding winding = OBStereo::Clockwise,
OBStereo::View view = OBStereo::ViewFrom)
{
if (cfg.from == OBStereo::NoRef) {
obErrorLog.ThrowError(__FUNCTION__,
"OBTetraNonPlanarStereo::ToConfig : Invalid from in ConfigType struct.", obError);
return ConfigType();
}
if (cfg.refs.size() != 3) {
obErrorLog.ThrowError(__FUNCTION__,
"OBTetraNonPlanarStereo::ToConfig : Invalid refs size.", obError);
return ConfigType();
}
// copy the internal refs
ConfigType result = cfg;
result.from = from_or_towards;
result.winding = winding;
result.view = view;
// keep track of the permuations by using the oddness
bool odd = false;
// find id
if (cfg.from != from_or_towards) {
// move id to front and remove it = 1 permutation
for (int i = 0; i < 3; ++i) {
if (cfg.refs.at(i) == from_or_towards) {
result.refs[i] = cfg.from;
break;
}
}
// 1 permutation perfromed --> odd = true
odd = true;
}
// clockwise <-> anti-clockwise : odd = true
if (winding == cfg.winding)
odd = !odd;
// ViewFrom <-> ViewTowards : odd = true
if (view == cfg.view)
odd = !odd;
// make sure we actually found id
if (result.refs.size() == 3) {
if (odd)
OBStereo::Permutate(result.refs, 1, 2);
return result;
}
obErrorLog.ThrowError(__FUNCTION__,
"OBTetraNonPlanarStereo::ToConfig : Parameter id not found in internal refs.", obError);
return result;
}
template <typename ConfigType>
static void ChangeWinding(ConfigType &cfg)
{
cfg.winding = (cfg.winding == OBStereo::Clockwise) ? OBStereo::AntiClockwise : OBStereo::Clockwise;
OBStereo::Permutate(cfg.refs, 1, 2);
}
template <typename ConfigType>
static void ChangeView(ConfigType &cfg)
{
cfg.view = (cfg.view == OBStereo::ViewFrom) ? OBStereo::ViewTowards : OBStereo::ViewFrom;
OBStereo::Permutate(cfg.refs, 1, 2);
}
template <typename ConfigType>
static void Invert(ConfigType &cfg)
{
OBStereo::Permutate(cfg.refs, 1, 2);
}
};
}
#endif
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBStereoBase::OBStereoBase
OBStereoBase(OBMol *mol)
Definition stereo.h:330
OpenBabel::OBTetraNonPlanarStereo::ChangeWinding
static void ChangeWinding(ConfigType &cfg)
Definition tetranonplanar.h:204
OpenBabel::OBTetraNonPlanarStereo::OBTetraNonPlanarStereo
OBTetraNonPlanarStereo(OBMol *mol)
OpenBabel::OBTetraNonPlanarStereo::ChangeView
static void ChangeView(ConfigType &cfg)
Definition tetranonplanar.h:213
OpenBabel::OBTetraNonPlanarStereo::~OBTetraNonPlanarStereo
virtual ~OBTetraNonPlanarStereo()
OpenBabel::OBTetraNonPlanarStereo::Invert
static void Invert(ConfigType &cfg)
Definition tetranonplanar.h:222
OpenBabel::OBTetraNonPlanarStereo::ToConfig
static ConfigType ToConfig(const ConfigType &cfg, unsigned long from_or_towards, OBStereo::Winding winding=OBStereo::Clockwise, OBStereo::View view=OBStereo::ViewFrom)
Definition tetranonplanar.h:145
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
OpenBabel::obErrorLog
OBMessageHandler obErrorLog
Global OBMessageHandler error handler.
Definition oberror.h:187
OpenBabel::obError
@ obError
for critical errors (e.g., cannot read a file)
Definition oberror.h:40
oberror.h
Handle error messages, warnings, notices, etc.
stereo.h
Process molecular stereochemistry information.
OpenBabel::OBStereo::NoRef
@ NoRef
No Ref set (invalid Ref).
Definition stereo.h:150
OpenBabel::OBStereo::Permutate
static void Permutate(Refs &refs, unsigned int i, unsigned int j)
OpenBabel::OBStereo::Winding
Winding
Definition stereo.h:130
OpenBabel::OBStereo::AntiClockwise
@ AntiClockwise
AntiClockwise winding (or CounterClockwise).
Definition stereo.h:132
OpenBabel::OBStereo::Clockwise
@ Clockwise
Clockwise winding.
Definition stereo.h:131
OpenBabel::OBStereo::View
View
Definition stereo.h:120
OpenBabel::OBStereo::ViewTowards
@ ViewTowards
view from center atom towards the atom (id parameter)
Definition stereo.h:122
OpenBabel::OBStereo::ViewFrom
@ ViewFrom
view from the atom (id parameter) towards the center atom
Definition stereo.h:121