Loading...
Searching...
No Matches
tetraplanar.h
Go to the documentation of this file.
/**********************************************************************
tetraplanar.h - OBTetraPlanarStereo
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_TETRAPLANAR_H
#define OB_TETRAPLANAR_H
#include "stereo.h"
#include <algorithm> // std::rotate
namespace OpenBabel {
class OBAPI OBTetraPlanarStereo : public OBStereoBase
{
public:
OBTetraPlanarStereo(OBMol *mol);
virtual ~OBTetraPlanarStereo();
template <typename ConfigType>
static ConfigType ToConfig(const ConfigType &cfg, unsigned long start,
OBStereo::Shape shape = OBStereo::ShapeU)
{
ConfigType result = cfg;
result.shape = shape;
// convert from U/Z/4 to U shape
switch (cfg.shape) {
case OBStereo::ShapeU:
break;
case OBStereo::ShapeZ:
OBStereo::Permutate(result.refs, 2, 3); // convert to U shape
break;
case OBStereo::Shape4:
OBStereo::Permutate(result.refs, 1, 2); // convert to U shape
break;
}
// since refs are U shaped we can rotate the refs lexicographically
for (int i = 0; i < 4; ++i) {
std::rotate(result.refs.begin(), result.refs.begin() + 1, result.refs.end());
// start at refs[0]?
if (result.refs.at(0) == start)
break;
}
// convert from U to desired U/Z/4
// (don't change refs[0]!)
switch (shape) {
case OBStereo::ShapeU:
break;
case OBStereo::ShapeZ:
OBStereo::Permutate(result.refs, 2, 3); // convert to Z shape
break;
case OBStereo::Shape4:
OBStereo::Permutate(result.refs, 1, 2); // convert to 4 shape
break;
}
return result;
}
};
}
#endif
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBStereoBase::OBStereoBase
OBStereoBase(OBMol *mol)
Definition stereo.h:330
OpenBabel::OBTetraPlanarStereo::ToConfig
static ConfigType ToConfig(const ConfigType &cfg, unsigned long start, OBStereo::Shape shape=OBStereo::ShapeU)
Definition tetraplanar.h:90
OpenBabel::OBTetraPlanarStereo::OBTetraPlanarStereo
OBTetraPlanarStereo(OBMol *mol)
OpenBabel::OBTetraPlanarStereo::~OBTetraPlanarStereo
virtual ~OBTetraPlanarStereo()
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
stereo.h
Process molecular stereochemistry information.
OpenBabel::OBStereo::Shape
Shape
Definition stereo.h:108
OpenBabel::OBStereo::ShapeU
@ ShapeU
Definition stereo.h:109
OpenBabel::OBStereo::ShapeZ
@ ShapeZ
Definition stereo.h:110
OpenBabel::OBStereo::Shape4
@ Shape4
Definition stereo.h:111
OpenBabel::OBStereo::Permutate
static void Permutate(Refs &refs, unsigned int i, unsigned int j)