switch to C++20 (#8039)

* c++20 builds working

* get MolStandardize building with clang19

* get FMCS building with clang-19

* set cxx version to c++20

* remove a few more compiler warnings

* bump min boost version, CI cleanup

* boost 1.81 is not available from conda-forge

* remove unused constants

* bump linux version for CI

* remove another unused variable

* fix (hopefully) cartridge CI builds

* simplify cartridge environment

* try postgresql14 in CI

* start the postgresql service

* change the columns used in the pandastools nbtest

* remove missed merge conflict artifact

* get github4823 test to pass with numpy 2.2

* remove a compiler warning/error with g++13
This commit is contained in:
Greg Landrum
2025-04-09 11:57:17 +02:00
committed by GitHub
parent d3f75a115f
commit 8eb02b8bed
15 changed files with 215 additions and 143 deletions

View File

@@ -9,10 +9,10 @@ steps:
conda config --add channels conda-forge
conda config --set solver libmamba
conda info -a
conda create --name rdkit_build $(python) cmake \
conda create --name rdkit_build -c conda-forge $(python) cmake \
boost-cpp=$(boost_version) \
boost=$(boost_version) \
numpy=1.24 pillow eigen pandas=2.0 matplotlib-base=3.7 \
numpy pillow eigen pandas=2.0 matplotlib-base=3.8 \
qt=5 cairo
conda activate rdkit_build
conda install -c conda-forge pytest nbval ipykernel>=6.0

View File

@@ -1,17 +1,21 @@
steps:
- bash: |
sudo apt-get update
sudo apt-get install -y postgresql-common postgresql-14 postgresql-server-dev-14
sudo apt-get install -y postgresql-14 postgresql-client-14 postgresql-server-dev-14 postgresql-common
echo "start postgres server"
sudo systemctl start postgresql.service
echo "add postgres user"
sudo -u postgres createuser -s `whoami`
source ${CONDA}/etc/profile.d/conda.sh
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda info -a
conda create --name rdkit_build -c conda-forge cmake \
boost-cpp=$(boost_version) \
boost=$(boost_version) \
eigen cairo
eigen \
cairo
conda activate rdkit_build
displayName: Setup build environment
- bash: |
source ${CONDA}/etc/profile.d/conda.sh

View File

@@ -11,7 +11,7 @@ ENDIF(NOT CMAKE_BUILD_TYPE)
# Enable CTest
include(CTest)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_MODULE_PATH
@@ -74,7 +74,7 @@ option(RDK_BUILD_MINIMAL_LIB_MCS "build support for MCS into MinimalLib" OFF )
option(RDK_BUILD_MINIMAL_LIB_MOLZIP "build support for molzip into MinimalLib" OFF )
option(RDK_BUILD_LONG_RUNNING_TESTS "build longer running tests" OFF )
set(RDK_BOOST_VERSION "1.70.0")
set(RDK_BOOST_VERSION "1.81.0")
if(NOT MSVC)
if(RDK_OPTIMIZE_POPCNT)

View File

@@ -52,8 +52,8 @@ std::vector<RDKit::MOL_SPTR_VECT> ConvertToVect(T bbs) {
RDKit::MOL_SPTR_VECT &reacts = vect[i];
reacts.reserve(len1);
for (unsigned int j = 0; j < len1; ++j) {
RDKit::ROMOL_SPTR mol = python::extract<RDKit::ROMOL_SPTR>(bbs[i][j]);
if (mol) {
auto mol = python::extract<RDKit::ROMOL_SPTR>(bbs[i][j]);
if (mol.check()) {
reacts.push_back(mol);
} else {
throw_value_error("reaction called with non molecule reactant");

View File

@@ -1,6 +1,6 @@
rdkit_library(FMCS
FMCS.cpp Seed.cpp MaximumCommonSubgraph.cpp SubstructMatchCustom.cpp
FMCS.cpp Seed.cpp TargetMatch.cpp MaximumCommonSubgraph.cpp SubstructMatchCustom.cpp
LINK_LIBRARIES Depictor SmilesParse FileParsers ChemTransforms SubstructMatch GraphMol )
target_compile_definitions(FMCS PRIVATE RDKIT_FMCS_BUILD)

View File

@@ -17,6 +17,7 @@
#include "Graph.h"
#include "DuplicatedSeedCache.h"
#include "SubstructMatchCustom.h"
#include "TargetMatch.h"
namespace RDKit {
namespace FMCS {

View File

@@ -0,0 +1,51 @@
//
// Copyright (C) 2024 Greg Landrum and other RDKit contributors
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#include "TargetMatch.h"
#include "Target.h"
#include "Seed.h"
namespace RDKit {
namespace FMCS {
void TargetMatch::init(const Seed &seed, const match_V_t &match,
const ROMol &query, const Target &target) {
TargetAtomIdx.clear();
TargetAtomIdx.resize(query.getNumAtoms(), NotSet);
TargetBondIdx.clear();
TargetBondIdx.resize(query.getNumBonds(), NotSet);
VisitedTargetBonds.resize(target.Molecule->getNumBonds());
VisitedTargetAtoms.resize(target.Molecule->getNumAtoms());
VisitedTargetBonds.reset();
VisitedTargetAtoms.reset();
MatchedAtomSize = match.size();
for (const auto &m : match) {
TargetAtomIdx[seed.MoleculeFragment.Atoms.at(m.first)->getIdx()] = m.second;
VisitedTargetAtoms.set(m.second);
}
MatchedBondSize = 0;
for (const auto bond : seed.MoleculeFragment.Bonds) {
unsigned int i = bond->getBeginAtomIdx();
unsigned int j = bond->getEndAtomIdx();
unsigned int ti = TargetAtomIdx.at(i);
unsigned int tj = TargetAtomIdx.at(j);
const auto tb = target.Molecule->getBondBetweenAtoms(ti, tj);
if (tb) {
++MatchedBondSize;
TargetBondIdx[bond->getIdx()] = tb->getIdx(); // add
VisitedTargetBonds.set(tb->getIdx());
}
}
Empty = false;
}
} // namespace FMCS
} // namespace RDKit

View File

@@ -12,10 +12,14 @@
#include <vector>
#include <boost/dynamic_bitset.hpp>
#include "FMCS.h"
#include "SubstructMatchCustom.h"
#include "MatchTable.h"
namespace RDKit {
namespace FMCS {
class Seed;
struct Target;
struct TargetMatch {
bool Empty{true};
size_t MatchedAtomSize{0};
@@ -49,38 +53,7 @@ struct TargetMatch {
VisitedTargetAtoms.clear();
}
void init(const Seed &seed, const match_V_t &match, const ROMol &query,
const Target &target) {
TargetAtomIdx.clear();
TargetAtomIdx.resize(query.getNumAtoms(), NotSet);
TargetBondIdx.clear();
TargetBondIdx.resize(query.getNumBonds(), NotSet);
VisitedTargetBonds.resize(target.Molecule->getNumBonds());
VisitedTargetAtoms.resize(target.Molecule->getNumAtoms());
VisitedTargetBonds.reset();
VisitedTargetAtoms.reset();
MatchedAtomSize = match.size();
for (const auto &m : match) {
TargetAtomIdx[seed.MoleculeFragment.Atoms.at(m.first)->getIdx()] =
m.second;
VisitedTargetAtoms.set(m.second);
}
MatchedBondSize = 0;
for (const auto bond : seed.MoleculeFragment.Bonds) {
unsigned int i = bond->getBeginAtomIdx();
unsigned int j = bond->getEndAtomIdx();
unsigned int ti = TargetAtomIdx.at(i);
unsigned int tj = TargetAtomIdx.at(j);
const auto tb = target.Molecule->getBondBetweenAtoms(ti, tj);
if (tb) {
++MatchedBondSize;
TargetBondIdx[bond->getIdx()] = tb->getIdx(); // add
VisitedTargetBonds.set(tb->getIdx());
}
}
Empty = false;
}
const Target &target);
};
} // namespace FMCS
} // namespace RDKit

View File

@@ -29,7 +29,6 @@ namespace RDKit {
namespace {
const std::string NEEDS_FUSE("CDXML_NEEDS_FUSE");
const std::string CDXML_FRAG_ID("CDXML_FRAG_ID");
const std::string CDXML_GROUP_ID("CDXML_GROUP_ID");
const std::string FUSE_LABEL("CDXML_NODE_ID");
const std::string CDX_SCHEME_ID("CDX_SCHEME_ID");
const std::string CDX_STEP_ID("CDX_STEP_ID");
@@ -39,7 +38,6 @@ const std::string CDX_AGENT_ID("CDX_AGENT_ID");
const std::string CDX_ATOM_POS("CDX_ATOM_POS");
const std::string CDX_ATOM_ID("_CDX_ATOM_ID");
const std::string CDX_BOND_ID("_CDX_BOND_ID");
const std::string CDX_BOND_ORDERING("CDXML_BOND_ORDERING");
constexpr double RDKIT_DEPICT_BONDLENGTH = 1.5;
@@ -454,7 +452,7 @@ bool parse_fragment(RWMol &mol, ptree &frag,
ids[bond.end]->setIsAromatic(true);
ids[bond.start]->setIsAromatic(true);
}
bnd->setProp("CDX_BOND_ID", bond.bond_id);
bnd->setProp(CDX_BOND_ID, bond.bond_id);
if (bond.display == "WedgeBegin") {
bnd->setBondDir(Bond::BondDir::BEGINWEDGE);
bnd->setProp(common_properties::_MolFileBondCfg, 1);

View File

@@ -12,7 +12,6 @@
#define RD_TAUTOMER_CATALOG_PARAMS_H
#include <Catalogs/CatalogParams.h>
#include "TautomerCatalogUtils.h"
#include <GraphMol/RDKitBase.h>
#include <string>
#include <vector>
@@ -22,7 +21,6 @@ namespace RDKit {
class ROMol;
namespace MolStandardize {
class TautomerTransform;
using TautomerTransformDefs =
std::vector<std::tuple<std::string, std::string, std::string, std::string>>;
@@ -33,6 +31,37 @@ RDKIT_MOLSTANDARDIZE_EXPORT extern const TautomerTransformDefs
RDKIT_MOLSTANDARDIZE_EXPORT extern const TautomerTransformDefs
defaultTautomerTransformsv1;
} // namespace defaults
class RDKIT_MOLSTANDARDIZE_EXPORT TautomerTransform {
public:
ROMol *Mol = nullptr;
std::vector<Bond::BondType> BondTypes;
std::vector<int> Charges;
TautomerTransform(ROMol *mol, std::vector<Bond::BondType> bondtypes,
std::vector<int> charges)
: Mol(mol),
BondTypes(std::move(bondtypes)),
Charges(std::move(charges)) {}
TautomerTransform(const TautomerTransform &other)
: BondTypes(other.BondTypes), Charges(other.Charges) {
Mol = new ROMol(*other.Mol);
}
TautomerTransform &operator=(const TautomerTransform &other) {
if (this != &other) {
delete Mol;
Mol = new ROMol(*other.Mol);
BondTypes = other.BondTypes;
Charges = other.Charges;
}
return *this;
}
~TautomerTransform() { delete Mol; }
};
class RDKIT_MOLSTANDARDIZE_EXPORT TautomerCatalogParams
: public RDCatalog::CatalogParams {
public:

View File

@@ -33,35 +33,6 @@ class TautomerCatalogParams;
//} BondType;
// typedef std::vector<ROMol*, std::string, std::string> tautomerTransform;
class RDKIT_MOLSTANDARDIZE_EXPORT TautomerTransform {
public:
ROMol *Mol = nullptr;
std::vector<Bond::BondType> BondTypes;
std::vector<int> Charges;
TautomerTransform(ROMol *mol, std::vector<Bond::BondType> bondtypes,
std::vector<int> charges)
: Mol(mol),
BondTypes(std::move(bondtypes)),
Charges(std::move(charges)) {}
TautomerTransform(const TautomerTransform &other)
: BondTypes(other.BondTypes), Charges(other.Charges) {
Mol = new ROMol(*other.Mol);
}
TautomerTransform &operator=(const TautomerTransform &other) {
if (this != &other) {
delete Mol;
Mol = new ROMol(*other.Mol);
BondTypes = other.BondTypes;
Charges = other.Charges;
}
return *this;
}
~TautomerTransform() { delete Mol; }
};
RDKIT_MOLSTANDARDIZE_EXPORT std::vector<Bond::BondType> stringToBondType(
std::string bond_str);

View File

@@ -1051,14 +1051,14 @@ TEST_CASE("includeTargetMolInResults") {
REQUIRE(targetMol);
auto flattenedAtomIndices = std::accumulate(
allAtomIndices.begin(), allAtomIndices.end(), std::vector<int>{},
[](std::vector<int> &acc, const std::vector<int> &v) {
[](std::vector<int> acc, const std::vector<int> &v) {
acc.insert(acc.end(), std::make_move_iterator(v.begin()),
std::make_move_iterator(v.end()));
return acc;
});
auto uniqueAtomIndices = std::accumulate(
allAtomIndices.begin(), allAtomIndices.end(), std::set<int>{},
[](std::set<int> &acc, const std::vector<int> &v) {
[](std::set<int> acc, const std::vector<int> &v) {
acc.insert(std::make_move_iterator(v.begin()),
std::make_move_iterator(v.end()));
return acc;
@@ -1067,14 +1067,14 @@ TEST_CASE("includeTargetMolInResults") {
CHECK(flattenedAtomIndices.size() == targetMol->getNumAtoms());
auto flattenedBondIndices = std::accumulate(
allBondIndices.begin(), allBondIndices.end(), std::vector<int>{},
[](std::vector<int> &acc, const std::vector<int> &v) {
[](std::vector<int> acc, const std::vector<int> &v) {
acc.insert(acc.end(), std::make_move_iterator(v.begin()),
std::make_move_iterator(v.end()));
return acc;
});
auto uniqueBondIndices = std::accumulate(
allBondIndices.begin(), allBondIndices.end(), std::set<int>{},
[](std::set<int> &acc, const std::vector<int> &v) {
[](std::set<int> acc, const std::vector<int> &v) {
acc.insert(std::make_move_iterator(v.begin()),
std::make_move_iterator(v.end()));
return acc;

View File

@@ -18,10 +18,6 @@ extern "C" {
namespace RDKit {
namespace EHTTools {
const std::string _EHTCharge = "_EHTCharge";
const std::string _EHTMullikenOP = "_EHTMullikenOP";
const std::string _EHTChargeMatrix = "_EHTChargeMatrix";
// we should only call into the C code, which uses tons of globals, from one
// thread at a time. This mutex enforces that.
#ifdef RDK_BUILD_THREADSAFE_SSS

View File

@@ -121,7 +121,7 @@ jobs:
variables:
boost_version: 1.84.0
number_of_cores: nproc
python_name: python37
python_name: python39
compiler: gxx_linux-64
cc: gcc-10
cxx: g++-10
@@ -134,7 +134,7 @@ jobs:
variables:
boost_version: 1.84.0
number_of_cores: '%NUMBER_OF_PROCESSORS%'
python_name: python38
python_name: python39
steps:
- template: .azure-pipelines/vs_build_swig.yml

View File

@@ -17,7 +17,9 @@
"cell_type": "code",
"execution_count": 2,
"id": "complete-conversation",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
@@ -48,43 +50,51 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>200</td>\n",
" <td>200</td>\n",
" <td>200</td>\n",
" <td>200</td>\n",
" <th>0</th>\n",
" <td>122.12344</td>\n",
" <td>0.79</td>\n",
" <td>0.727;-0P;4.71</td>\n",
" <td>2.963;-40R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>unique</th>\n",
" <td>183</td>\n",
" <td>176</td>\n",
" <td>193</td>\n",
" <td>183</td>\n",
" <th>1</th>\n",
" <td>332.495</td>\n",
" <td>4.66</td>\n",
" <td>4.316;-0P;4.71</td>\n",
" <td>9.384;-0R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>top</th>\n",
" <td>198.26456</td>\n",
" <td>2.19</td>\n",
" <td>1.498;-0P;4.71</td>\n",
" <td>6.280;-0R;4.71</td>\n",
" <th>2</th>\n",
" <td>218.553</td>\n",
" <td>-2.61</td>\n",
" <td>2.239;-57P;4.71</td>\n",
" <td>4.556;-0R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>freq</th>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <th>3</th>\n",
" <td>145.14184</td>\n",
" <td>-2.01</td>\n",
" <td>0.519;-59P;4.71</td>\n",
" <td>3.267;-42R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>223.231</td>\n",
" <td>2.43</td>\n",
" <td>1.869;-0P;4.71</td>\n",
" <td>6.390;-0R;4.71</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" AMW CLOGP CP CR\n",
"count 200 200 200 200\n",
"unique 183 176 193 183\n",
"top 198.26456 2.19 1.498;-0P;4.71 6.280;-0R;4.71\n",
"freq 3 3 2 3"
" AMW CLOGP CP CR\n",
"0 122.12344 0.79 0.727;-0P;4.71 2.963;-40R;4.71\n",
"1 332.495 4.66 4.316;-0P;4.71 9.384;-0R;4.71\n",
"2 218.553 -2.61 2.239;-57P;4.71 4.556;-0R;4.71\n",
"3 145.14184 -2.01 0.519;-59P;4.71 3.267;-42R;4.71\n",
"4 223.231 2.43 1.869;-0P;4.71 6.390;-0R;4.71"
]
},
"execution_count": 2,
@@ -94,14 +104,37 @@
],
"source": [
"df = PandasTools.LoadSDF(os.path.join(RDConfig.RDDataDir,'NCI','first_200.props.sdf'))\n",
"df[['AMW','CLOGP','CP','CR']].describe()"
"df[['AMW','CLOGP','CP','CR']].head()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "permanent-liechtenstein",
"id": "63de62cc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"200"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(df)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "permanent-liechtenstein",
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
@@ -114,7 +147,7 @@
" dtype='object')"
]
},
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -148,7 +181,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"id": "identical-finder",
"metadata": {},
"outputs": [
@@ -181,53 +214,69 @@
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>count</th>\n",
" <td>200</td>\n",
" <td>200</td>\n",
" <td>200</td>\n",
" <td>200</td>\n",
" <th>0</th>\n",
" <td>122.12344</td>\n",
" <td>0.79</td>\n",
" <td>0.727;-0P;4.71</td>\n",
" <td>2.963;-40R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>unique</th>\n",
" <td>183</td>\n",
" <td>176</td>\n",
" <td>193</td>\n",
" <td>183</td>\n",
" <th>1</th>\n",
" <td>332.495</td>\n",
" <td>4.66</td>\n",
" <td>4.316;-0P;4.71</td>\n",
" <td>9.384;-0R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>top</th>\n",
" <td>198.26456</td>\n",
" <td>2.19</td>\n",
" <td>1.498;-0P;4.71</td>\n",
" <td>6.280;-0R;4.71</td>\n",
" <th>2</th>\n",
" <td>218.553</td>\n",
" <td>-2.61</td>\n",
" <td>2.239;-57P;4.71</td>\n",
" <td>4.556;-0R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>freq</th>\n",
" <td>3</td>\n",
" <td>3</td>\n",
" <td>2</td>\n",
" <td>3</td>\n",
" <th>3</th>\n",
" <td>145.14184</td>\n",
" <td>-2.01</td>\n",
" <td>0.519;-59P;4.71</td>\n",
" <td>3.267;-42R;4.71</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>223.231</td>\n",
" <td>2.43</td>\n",
" <td>1.869;-0P;4.71</td>\n",
" <td>6.390;-0R;4.71</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" AMW CLOGP CP CR\n",
"count 200 200 200 200\n",
"unique 183 176 193 183\n",
"top 198.26456 2.19 1.498;-0P;4.71 6.280;-0R;4.71\n",
"freq 3 3 2 3"
" AMW CLOGP CP CR\n",
"0 122.12344 0.79 0.727;-0P;4.71 2.963;-40R;4.71\n",
"1 332.495 4.66 4.316;-0P;4.71 9.384;-0R;4.71\n",
"2 218.553 -2.61 2.239;-57P;4.71 4.556;-0R;4.71\n",
"3 145.14184 -2.01 0.519;-59P;4.71 3.267;-42R;4.71\n",
"4 223.231 2.43 1.869;-0P;4.71 6.390;-0R;4.71"
]
},
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[['AMW','CLOGP','CP','CR']].describe()"
"df[['AMW','CLOGP','CP','CR']].head()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7cea7bba",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -246,7 +295,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.11.8"
},
"toc": {
"base_numbering": 1,