1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
// Created by Guillaume GODIN
// Copyright (C) 2012-2018 Greg Landrum
// @@ 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 <RDGeneral/Invariant.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/FileParsers/MolSupplier.h>
#include <GraphMol/FileParsers/FileParsers.h>
#include <RDGeneral/RDLog.h>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <sstream>
#include <iterator>
#include <GraphMol/GraphMol.h>
#include <GraphMol/MolOps.h>
#include <boost/tokenizer.hpp>
#include <GraphMol/PeriodicTable.h>
#include <GraphMol/Descriptors/CoulombMat.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/DistGeomHelpers/Embedder.h>
#include <GraphMol/ForceFieldHelpers/MMFF/MMFF.h>
#include <GraphMol/ForceFieldHelpers/UFF/UFF.h>
std::vector<std::string> tokenize(const std::string &s) {
boost::char_separator<char> sep(", \n\r\t");
boost::tokenizer<boost::char_separator<char>> tok(s, sep);
std::vector<std::string> tokens;
std::copy(tok.begin(), tok.end(),
std::back_inserter<std::vector<std::string>>(tokens));
return tokens;
}
void testCoulombMat1() {
std::cerr
<< "===================== Testing CoulombMat =======================\n";
std::string pathName = getenv("RDBASE");
// CM test 1
std::string fNameCM =
pathName + "/Code/GraphMol/Descriptors/test_data/CM1.out";
std::string mol_file =
pathName + "/Code/GraphMol/Descriptors/test_data/bobmol.sdf";
std::ifstream instrmCM(fNameCM.c_str());
std::string line;
std::vector<std::string> tokens;
RDKit::ROMOL_SPTR mol(RDKit::MolFileToMol(mol_file, true, false));
std::vector<std::vector<double>> Mres;
int confId = -1;
RDKit::Descriptors::CoulombMat(*mol, Mres, confId);
for (const auto &v : Mres) {
std::getline(instrmCM, line);
tokens = tokenize(line);
unsigned int ti = 0;
for (double x : v) {
// std::cout << x << ",";
TEST_ASSERT(std::fabs(std::stof(tokens[ti]) - x) < 0.001);
ti++;
}
// std::cout << "\n";
}
// std::cout << "\n";
std::cerr << "CM test 1 mat Done\n";
}
int main() {
RDLog::InitLogs();
testCoulombMat1();
}
|