mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-05 22:04:27 +08:00
* Address minor compilation warning messages
Addresses trivial compilation warning messages:
[ 11%] Building CXX object Code/GraphMol/CMakeFiles/GraphMol.dir/AddHs.cpp.o
rdkit/Code/GraphMol/AddHs.cpp:497:9: warning: unused variable 'dblBond' [-Wunused-variable]
Bond *dblBond = nullptr;
^
1 warning generated.
[ 11%] Building CXX object Code/GraphMol/CMakeFiles/GraphMol.dir/Chirality.cpp.o
rdkit/Code/GraphMol/Chirality.cpp:1738:62: warning: unused parameter 'mol' [-Wunused-parameter]
bool isBondCandidateForStereo(const Bond *bond, const ROMol &mol) {
^
1 warning generated.
[ 44%] Building CXX object Code/GraphMol/CMakeFiles/graphmolMolOpsTest.dir/molopstest.cpp.o
rdkit/Code/GraphMol/molopstest.cpp:4694:12: warning: unused variable 'nm' [-Wunused-variable]
ROMol *nm = MolOps::renumberAtoms(*m, nVect);
^
rdkit/Code/GraphMol/molopstest.cpp:6941:16: warning: unused variable 'm' [-Wunused-variable]
RWMol *m = SmilesToMol(smiles);
^
2 warnings generated.
[ 42%] Building CXX object Code/GraphMol/CMakeFiles/graphmoltestPicklerGlobalSetting.dir/testPicklerGlobalSettings.cpp.o
rdkit/Code/GraphMol/testPicklerGlobalSettings.cpp:257:14: warning: unused parameter 'argc' [-Wunused-parameter]
int main(int argc, char *argv[]) {
^
rdkit/Code/GraphMol/testPicklerGlobalSettings.cpp:257:26: warning: unused parameter 'argv' [-Wunused-parameter]
int main(int argc, char *argv[]) {
^
2 warnings generated.
[ 55%] Building CXX object Code/GraphMol/FilterCatalog/CMakeFiles/FilterCatalog.dir/FunctionalGroupHierarchy.cpp.o
rdkit/Code/GraphMol/FilterCatalog/FunctionalGroupHierarchy.cpp:176:20: warning: unused variable 'NUM_FUNCS' [-Wunused-const-variable]
const unsigned int NUM_FUNCS =
^
1 warning generated.
[ 84%] Building CXX object Code/GraphMol/StructChecker/CMakeFiles/StructChecker.dir/ReCharge.cpp.o
rdkit/Code/GraphMol/StructChecker/ReCharge.cpp:405:17: warning: unused variable 'atom' [-Wunused-variable]
const Atom &atom = *Mol.getAtomWithIdx(i);
^
1 warning generated.
[ 84%] Building CXX object Code/GraphMol/StructChecker/CMakeFiles/StructChecker.dir/Tautomer.cpp.o
rdkit/Code/GraphMol/StructChecker/Tautomer.cpp:61:12: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
if (-1 == ti || -1 == tj) continue;
~~ ^ ~~
rdkit/Code/GraphMol/StructChecker/Tautomer.cpp:61:24: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
if (-1 == ti || -1 == tj) continue;
~~ ^ ~~
2 warnings generated.
[ 88%] Building CXX object Code/GraphMol/RGroupDecomposition/CMakeFiles/testRGroupDecomp.dir/testRGroupDecomp.cpp.o
rdkit/Code/GraphMol/RGroupDecomposition/testRGroupDecomp.cpp:428:9: warning: unused variable 'res' [-Wunused-variable]
int res = decomp.add(*mol);
^
1 warning generated.
[ 96%] Building CXX object Code/SimDivPickers/CMakeFiles/testSimDivPickers.dir/testPickers.cpp.o
rdkit/Code/SimDivPickers/testPickers.cpp:19:10: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
return abs((double)i - (double)j);
^
rdkit/Code/SimDivPickers/testPickers.cpp:19:10: note: use function 'std::abs' instead
return abs((double)i - (double)j);
^~~
std::abs
1 warning generated.
* Close open file handles during build set-up
Under Python3, the update_pains.py file generated warning
messages like:
== Done updating pains files
/Code/GraphMol/FilterCatalog/update_pains.py:140: ResourceWarning:
unclosed file <_io.TextIOWrapper
name='/Code/GraphMol/FilterCatalog/../../../Data/Pains/wehi_pains.csv'
mode='r' encoding='UTF-8'>
for smiles, name in csv.reader(open(PAINS_CSV)):
/Code/GraphMol/FilterCatalog/update_pains.py:169: ResourceWarning:
unclosed file <_io.TextIOWrapper
name='/Code/GraphMol/FilterCatalog/pains_a.in' mode='r'
encoding='UTF-8'>
t = open(filename).read()
/Code/GraphMol/FilterCatalog/update_pains.py:169: ResourceWarning:
unclosed file <_io.TextIOWrapper
name='/Code/GraphMol/FilterCatalog/pains_b.in' mode='r'
encoding='UTF-8'>
t = open(filename).read()
/Code/GraphMol/FilterCatalog/update_pains.py:169: ResourceWarning:
unclosed file <_io.TextIOWrapper
name='/Code/GraphMol/FilterCatalog/pains_c.in' mode='r'
encoding='UTF-8'>
t = open(filename).read()
79 lines
2.8 KiB
C++
79 lines
2.8 KiB
C++
//
|
|
// Copyright (C) 2016 Novartis Institutes for BioMedical Research
|
|
//
|
|
// @@ 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 "../Substruct/SubstructMatch.h"
|
|
#include "StructChecker.h"
|
|
#include "Pattern.h"
|
|
#include "Tautomer.h"
|
|
|
|
namespace RDKit {
|
|
namespace StructureCheck {
|
|
|
|
bool StructCheckTautomer::applyTautomer(unsigned it) {
|
|
if (Options.FromTautomer.size() <= it || Options.ToTautomer.size() <= it) {
|
|
if (Options.Verbose)
|
|
BOOST_LOG(rdInfoLog) << "ERROR: incorrect Tautomer index it=" << it
|
|
<< "\n";
|
|
return false;
|
|
}
|
|
const ROMol &fromTautomer = *Options.FromTautomer[it];
|
|
const ROMol &toTautomer = *Options.ToTautomer[it];
|
|
if (toTautomer.getNumAtoms() != fromTautomer.getNumAtoms()) {
|
|
if (Options.Verbose)
|
|
BOOST_LOG(rdInfoLog) << "ERROR: incorrect data toTautomer.getNumAtoms() "
|
|
"!= fromTautomer.getNumAtoms()\n";
|
|
// incorrect data
|
|
// throw(.....);
|
|
return false;
|
|
}
|
|
const unsigned nta = toTautomer.getNumAtoms();
|
|
MatchVectType match; // The format is (queryAtomIdx, molAtomIdx)
|
|
std::vector<unsigned> atomIdxMap(
|
|
Mol.getNumAtoms()); // matched tau atom indeces
|
|
|
|
if (!SubstructMatch(Mol, *Options.FromTautomer[it],
|
|
match)) // SSMatch(mp, from_tautomer, SINGLE_MATCH);
|
|
return false;
|
|
if (Options.Verbose)
|
|
BOOST_LOG(rdInfoLog) << "found match for from_tautomer with " << nta
|
|
<< " atoms\n";
|
|
// init
|
|
for (unsigned i = 0; i < Mol.getNumAtoms(); i++) atomIdxMap[i] = -1;
|
|
for (MatchVectType::const_iterator mit = match.begin(); mit != match.end();
|
|
mit++) {
|
|
unsigned tai = mit->first; // From and To Tautomer Atom index
|
|
unsigned mai = mit->second; // Mol Atom index
|
|
atomIdxMap[mai] = tai;
|
|
}
|
|
// scan for completely mapped bonds and replace bond order with mapped bond
|
|
// from to_tautomer
|
|
for (RDKit::BondIterator_ bond = Mol.beginBonds(); bond != Mol.endBonds();
|
|
bond++) {
|
|
unsigned ti = atomIdxMap[(*bond)->getBeginAtomIdx()];
|
|
unsigned tj = atomIdxMap[(*bond)->getEndAtomIdx()];
|
|
if (-1 == ti || -1 == tj) continue;
|
|
const Bond *tb = toTautomer.getBondBetweenAtoms(ti, tj);
|
|
if (tb && (*bond)->getBondType() != tb->getBondType()) {
|
|
(*bond)->setBondType(tb->getBondType());
|
|
}
|
|
}
|
|
// apply charge/radical fixes if any
|
|
for (auto &i : match) {
|
|
Atom &atom = *Mol.getAtomWithIdx(i.second);
|
|
const Atom &ta = *toTautomer.getAtomWithIdx(i.first);
|
|
atom.setFormalCharge(ta.getFormalCharge());
|
|
atom.setNumRadicalElectrons(ta.getNumRadicalElectrons());
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace StructureCheck
|
|
} // namespace RDKit
|