Files
rdkit/Code/GraphMol/Wrap/Table.cpp
Greg Landrum eb3d720010 Fixes for sf.net bugs 1942657 : square brackets in smiles allow invalid valences
http://sourceforge.net/tracker/index.php?func=detail&aid=1942657&group_id=160139&atid=814650

This was handled by adding error/consistency checking to Atom.calcExplicitValence()

This includes another pretty big scale modification:
the allowed valence list for atoms (in atomic_data.cpp) can now contain a -1 at the end. If this is the case, the atom will tolerate valences above the ones listed.
This is done to allow "flexible" atoms (i.e. transition metals and the like) to accept arbitrary coordination numbers without generating errors.
2008-04-17 05:09:02 +00:00

83 lines
3.1 KiB
C++
Executable File

// $Id$
//
// Copyright (C) 2003-2006 Rational Discovery LLC
//
// @@ All Rights Reserved @@
//
#define NO_IMPORT_ARRAY
#include <boost/python.hpp>
#include <string>
#include <GraphMol/RDKitBase.h>
#include <RDGeneral/types.h>
namespace python = boost::python;
namespace RDKit{
PeriodicTable *GetTable(){
return PeriodicTable::getTable();
}
std::string periodicTableClassDoc="A class which stores information from the Periodic Table.\n\
\n\
It is not possible to create a PeriodicTable object directly from Python,\n\
use GetPeriodicTable() to get the global table.\n\
\n\
The PeriodicTable object can be queried for a variety of properties:\n\
\n\
- GetAtomicWeight\n\
\n\
- GetAtomicNumber\n\
\n\
- GetElementSymbol\n\
\n\
- GetRvdw (van der Waals radius)\n\
\n\
- GetRCovalent (covalent radius)\n\
\n\
- GetDefaultValence\n\
\n\
- GetValenceList\n\
\n\
- GetNOuterElecs (number of valence electrons)\n\
\n\
When it makes sense, these can be queried using either an atomic number (integer)\n\
or an atomic symbol (string)\n\
\n";
struct table_wrapper {
static void wrap(){
python::class_<PeriodicTable>("PeriodicTable",periodicTableClassDoc.c_str(),
python::no_init)
.def("GetAtomicWeight",(double (PeriodicTable::*)(UINT) const)&PeriodicTable::getAtomicWeight)
.def("GetAtomicWeight",(double (PeriodicTable::*)(const std::string &) const)&PeriodicTable::getAtomicWeight)
.def("GetAtomicNumber",(int (PeriodicTable::*)(const std::string &) const)&PeriodicTable::getAtomicNumber)
.def("GetElementSymbol",(std::string (PeriodicTable::*)(UINT) const)&PeriodicTable::getElementSymbol)
.def("GetRvdw",(double (PeriodicTable::*)(UINT) const)&PeriodicTable::getRvdw)
.def("GetRvdw",(double (PeriodicTable::*)(const std::string &) const)&PeriodicTable::getRvdw)
.def("GetRcovalent",(double (PeriodicTable::*)(UINT) const)&PeriodicTable::getRcovalent)
.def("GetRcovalent",(double (PeriodicTable::*)(const std::string &) const)&PeriodicTable::getRcovalent)
.def("GetDefaultValence",(int (PeriodicTable::*)(UINT) const)&PeriodicTable::getDefaultValence)
.def("GetDefaultValence",(int (PeriodicTable::*)(const std::string &) const)&PeriodicTable::getDefaultValence)
.def("GetValenceList",(const INT_VECT &(PeriodicTable::*)(UINT) const)&PeriodicTable::getValenceList,
python::return_value_policy<python::copy_const_reference>())
.def("GetValenceList",(const INT_VECT &(PeriodicTable::*)(const std::string &) const)&PeriodicTable::getValenceList,
python::return_value_policy<python::copy_const_reference>())
.def("GetNOuterElecs",(int (PeriodicTable::*)(UINT) const)&PeriodicTable::getNouterElecs)
.def("GetNOuterElecs",(int (PeriodicTable::*)(const std::string &) const)&PeriodicTable::getNouterElecs)
;
python::def("GetPeriodicTable",GetTable,
"Returns the application's PeriodicTable instance.\n\n",
python::return_value_policy<python::reference_existing_object>());
};
};
} // end of namespace
void wrap_table() {
RDKit::table_wrapper::wrap();
}