Skip to content

Commit

Permalink
Various updates to stereochemistry
Browse files Browse the repository at this point in the history
* Use Config structs for Tetrahedral and CisTrans
* Merge Changes from Noel

Conflicts:

	scripts/CMakeLists.txt
	src/formats/smilesformat.cpp
  • Loading branch information
timvdm committed Jul 18, 2009
1 parent 6156d63 commit 06ac952
Show file tree
Hide file tree
Showing 38 changed files with 3,060 additions and 578 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ project(openbabel)
set(CMAKE_MODULE_PATH ${openbabel_SOURCE_DIR}/cmake/modules)
cmake_minimum_required(VERSION 2.4.8)

ENABLE_TESTING()

if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
Expand Down Expand Up @@ -204,6 +206,7 @@ add_subdirectory(doc)
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(tools)
add_subdirectory(scripts)
# Should Python bindings be built?
option(ENABLE_PYTHON "Enable Python bindings" OFF)
Expand Down
3 changes: 2 additions & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ WARN_LOGFILE =

INPUT = include/openbabel \
include/openbabel/math \
include/openbabel/stereo \
src/ \
src/math \
include/RDKitConv.h
Expand Down Expand Up @@ -622,7 +623,7 @@ EXAMPLE_RECURSIVE = NO
# directories that contain image that are included in the documentation (see
# the \image command).

IMAGE_PATH =
IMAGE_PATH = doc/images

# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
Expand Down
Binary file added doc/images/SPshapes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/cistrans.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/getcisref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/gettransref.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/squareplanar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/tetrahedral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/tetranonplanar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/tetraplanar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
180 changes: 129 additions & 51 deletions include/openbabel/stereo/cistrans.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,73 @@ namespace OpenBabel {
*
*
*/
class OBCisTransStereo : public OBTetraPlanarStereo
class OBAPI OBCisTransStereo : public OBTetraPlanarStereo
{
public:
/**
* The config struct represents the stereochemistry in a well defined way.
*/
struct Config
{
/**
* Default constructor.
*/
Config() : begin(OBStereo::NoId), end(OBStereo::NoId), shape(OBStereo::ShapeU)
{ }
/**
* Constructor with all parameters.
*
* @param _begin The double bond begin atom id.
* @param _end The double bond end atom id.
* @param _refs The 4 reference ids.
* @param _shape The shape for the 4 reference ids.
*/
Config(unsigned long _begin, unsigned long _end, const OBStereo::Refs &_refs,
OBStereo::Shape _shape = OBStereo::ShapeU) : begin(_begin), end(_end),
refs(_refs), shape(_shape)
{ }
/**
* Equal to operator.
*
* @code
* OBCisTransStereo::Config cfg1, cfg2;
* ...
* if (cfg1 == cfg2) {
* // cfg1 and cfg2 represent the same stereochemistry
* ...
* }
* @endcode
*
* @return True if both Config structs represent the stereochemistry.
*/
bool operator==(const Config &other) const;
/**
* Not equal to operator.
*
* @return True if the two Config structs represent a different stereochemistry.
*/
bool operator!=(const Config &other) const
{
return !(*this == other);
}

/**
* @name Data members defining stereochemistry.
* @{
*/
unsigned long begin, end; //<! The double bond begin and end ids.
OBStereo::Refs refs; //!< The 4 reference ids.
OBStereo::Shape shape; //!< The shape of the 4 reference ids.
//@}
};

/**
* Constructor.
*/
OBCisTransStereo(OBMol *mol);
/**
* Destructor.
*/
virtual ~OBCisTransStereo();

/**
Expand All @@ -64,49 +127,37 @@ class OBCisTransStereo : public OBTetraPlanarStereo
bool IsValid() const;

/**
* Set the central, double bonded atoms
* Set the configuration using a Config struct.
*/
void SetCenters(unsigned long begin, unsigned long end);
void SetConfig(const Config &config);
/**
* Set the begin atom for the double bond
* Get the configuration as Config struct.
*/
void SetBegin(unsigned long begin);
Config GetConfig(OBStereo::Shape shape = OBStereo::ShapeU) const;
/**
* Set the end atom for the double bond
* Get the configuration as Config struct and ensure refs[0] is
* equal to @p start.
*/
void SetEnd(unsigned long end);
Config GetConfig(unsigned long start,
OBStereo::Shape shape = OBStereo::ShapeU) const;
/**
* @return The double bond begin atom.
*/
unsigned long GetBegin() const;
/**
* @return The double bond begin atom.
*/
unsigned long GetEnd() const;

//! @name Methods to get and set the reference ids.
//@{
/**
* Set the 4 reference ids. The @p shape parameter specifies how the
* reference ids are layed out.
* Compare the internally stored stereochemistry with the
* stereochemistry specified by @p other.
*
* @param refs The 4 reference ids.
* @param shape The reference id order in the returned list.
* These are all examples of the same configuration:
* @image html SPshapes.png
* @return True if both OBTetrahedralStereo objects represent the same
* stereochemistry.
*/
void SetRefs(const std::vector<unsigned long> &refs,
OBStereo::Shape shape = OBStereo::ShapeU);
/**
* Get a list of the 4 reference ids. The ids occur in the sequence
* following the specified shape.
*
* @param shape The reference id order in the returned list.
* These are all examples of the same configuration:
* @image html SPshapes.png
bool operator==(const OBCisTransStereo &other) const;
bool operator!=(const OBCisTransStereo &other) const
{
return !(*this == other);
}

/*
* Implement OBGenericData::Clone().
*/
std::vector<unsigned long> GetRefs(OBStereo::Shape shape = OBStereo::ShapeU) const;
//@}
OBGenericData* Clone(OBBase *mol) const;


//! @name Query methods to compare stereochemistry.
//@{
Expand All @@ -117,7 +168,7 @@ class OBCisTransStereo : public OBTetraPlanarStereo
* atom is bonded to the begin atom and end->GetValence() == 2, the
* ids are considered to be on different atoms. The reasoning behind
* this is that hydrogens may be deleted. However, you can also use
* OBStereo::HydrogenId explicitly in code like:
* OBStereo::ImplicitId explicitly in code like:
*
* @code
* //
Expand All @@ -130,7 +181,7 @@ class OBCisTransStereo : public OBTetraPlanarStereo
* reading smiles F/C=C\F cis-difluorethene
* OBCisTransStereo ct(mol);
* ct.SetCenters(1, 2);
* ct.SetRefs(OBStereo::MakeRefs(0, OBStereo::HydrogenId, OBStereo::HydrogenId, 3));
* ct.SetRefs(OBStereo::MakeRefs(0, OBStereo::ImplicitId, OBStereo::ImplicitId, 3));
* ...
* @endcode
*
Expand All @@ -156,24 +207,51 @@ class OBCisTransStereo : public OBTetraPlanarStereo
* Get the reference id cis from reference @p id.
*/
unsigned long GetCisRef(unsigned long id) const;
/**
* This function checks to see if the internal reference ids match with @p refs.
* This is done by checking which reference ids are trans. See the OBTetraPlanarStereo
* class documentation for more information about the 3 possible configurations.
* \return True if the stored reference ids match the configuration
* of @p refs using @p shape.
*/
bool Compare(const std::vector<unsigned long> &refs, OBStereo::Shape shape) const;
//@}


private:

unsigned long m_begin; //!< the center/chiral atom
unsigned long m_end; //!< the center/chiral atom
std::vector<unsigned long> m_refs; //!< the 4 clockwise atom refs
Config m_cfg; //!< internal configuration
};

}
} // namespace OpenBabel

namespace std {

/**
* @code
* OBTetrahedralStereo::Config cfg;
* cfg.begin = 0;
* cfg.end = 1;
* cfg.refs = OBStereo::MakeRefs(2, 3, 4, 5);
* cfg.shape = OBStereo::ShapeU;
*
* OBCisTransStereo ct(mol);
* ct.SetConfig(cfg)
*
* cout << "ct = " << ct << endl;
*
* // output
* OBCisTransStereo(begin = 0, end = 1, refs = 2 3 4 5, shape = U)
* @endcode
*/
OBAPI ostream& operator<<(ostream &out, const OpenBabel::OBCisTransStereo &ct);
/**
* @code
* OBCisTransStereo::Config cfg;
* cfg.begin = 0;
* cfg.end = 1;
* cfg.refs = OBStereo::MakeRefs(2, 3, 4, 5);
* cfg.shape = OBStereo::ShapeU;
*
* cout << "cfg = " << cfg << endl;
*
* // output
* OBCisTransStereo::Config(begin = 0, end = 1, refs = 2 3 4 5, shape = U)
* @endcode
*/
OBAPI ostream& operator<<(ostream &out, const OpenBabel::OBCisTransStereo::Config &cfg);

} // namespace std


#endif
2 changes: 1 addition & 1 deletion include/openbabel/stereo/squareplanar.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace OpenBabel {
* to get more information. Like all stereo classes, errors,
* warnings or info is reported using OBMessageHandler.
*/
class OBSquarePlanarStereo : public OBTetraPlanarStereo
class OBAPI OBSquarePlanarStereo : public OBTetraPlanarStereo
{
public:
OBSquarePlanarStereo(OBMol *mol);
Expand Down
Loading

0 comments on commit 06ac952

Please sign in to comment.