File: catch_tests.cpp

package info (click to toggle)
rdkit 202209.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 203,880 kB
  • sloc: cpp: 334,239; python: 80,247; ansic: 24,579; java: 7,667; sql: 2,123; yacc: 1,884; javascript: 1,358; lex: 1,260; makefile: 576; xml: 229; fortran: 183; cs: 181; sh: 101
file content (106 lines) | stat: -rw-r--r-- 3,467 bytes parent folder | download
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
//  Copyright (C) 2022 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 "catch.hpp"
#include "AlignMolecules.h"
#include <GraphMol/FileParsers/FileParsers.h>
#include <GraphMol/ROMol.h>
#include <GraphMol/Conformer.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/MolTransforms/MolTransforms.h>

using namespace RDKit;

TEST_CASE("symmetric functional groups") {
  SECTION("basics") {
    auto m1 =
        "CCC(=O)[O-] "
        "|(-1.11,0.08,-0.29;0.08,-0.18,0.58;1.34,0.03,-0.16;1.74,1.22,-0.32;2.06,-1.04,-0.66)|"_smiles;
    REQUIRE(m1);

    // swap the bond orders to the Os
    RWMol m2(*m1);
    m2.getAtomWithIdx(3)->setFormalCharge(-1);
    m2.getAtomWithIdx(4)->setFormalCharge(0);
    m2.getBondBetweenAtoms(2, 3)->setBondType(Bond::BondType::SINGLE);
    m2.getBondBetweenAtoms(2, 4)->setBondType(Bond::BondType::DOUBLE);

    {
      auto rmsd = MolAlign::getBestRMS(m2, *m1);
      CHECK(rmsd == Approx(0.0).margin(1e-3));
    }
    {
      // previous behavior
      int probeId = -1;
      int refId = -1;
      std::vector<MatchVectType> mp;
      int maxMatches = 1e6;
      bool symmetrize = false;
      auto rmsd = MolAlign::getBestRMS(m2, *m1, probeId, refId, mp, maxMatches,
                                       symmetrize);
      CHECK(rmsd == Approx(0.747).margin(1e-3));
    }
  }
  SECTION("terminal sulfate1") {
    auto m1 =
        "CS(=O)(=O)[O-] |(-0.93,-0.06,-0.04;0.82,0.07,0.13;1.27,-0.04,1.54;1.21,1.40,-0.48;1.53,-1.11,-0.82)|"_smiles;
    REQUIRE(m1);

    // swap the bond orders to the Os
    RWMol m2(*m1);
    m2.getAtomWithIdx(2)->setFormalCharge(-1);
    m2.getAtomWithIdx(4)->setFormalCharge(0);
    m2.getBondBetweenAtoms(1, 2)->setBondType(Bond::BondType::SINGLE);
    m2.getBondBetweenAtoms(1, 4)->setBondType(Bond::BondType::DOUBLE);

    {
      auto rmsd = MolAlign::getBestRMS(m2, *m1);
      CHECK(rmsd == Approx(0.0).margin(1e-3));
    }
    {
      // previous behavior
      int probeId = -1;
      int refId = -1;
      std::vector<MatchVectType> mp;
      int maxMatches = 1e6;
      bool symmetrize = false;
      auto rmsd = MolAlign::getBestRMS(m2, *m1, probeId, refId, mp, maxMatches,
                                       symmetrize);
      CHECK(rmsd == Approx(0.097).margin(1e-3));
    }
  }
  SECTION("terminal sulfate2") {
    auto m1 =
        "CS(=O)(=O)[O-] |(-0.93,-0.06,-0.04;0.82,0.07,0.13;1.27,-0.04,1.54;1.21,1.40,-0.48;1.53,-1.11,-0.82)|"_smiles;
    REQUIRE(m1);

    // swap the bond orders to the Os
    RWMol m2(*m1);
    m2.getAtomWithIdx(3)->setFormalCharge(-1);
    m2.getAtomWithIdx(4)->setFormalCharge(0);
    m2.getBondBetweenAtoms(1, 3)->setBondType(Bond::BondType::SINGLE);
    m2.getBondBetweenAtoms(1, 4)->setBondType(Bond::BondType::DOUBLE);

    {
      auto rmsd = MolAlign::getBestRMS(m2, *m1);
      CHECK(rmsd == Approx(0.0).margin(1e-3));
    }
    {
      // previous behavior
      int probeId = -1;
      int refId = -1;
      std::vector<MatchVectType> mp;
      int maxMatches = 1e6;
      bool symmetrize = false;
      auto rmsd = MolAlign::getBestRMS(m2, *m1, probeId, refId, mp, maxMatches,
                                       symmetrize);
      CHECK(rmsd == Approx(0.097).margin(1e-3));
    }
  }
}