Codebase list schroedinger-coordgenlibs / f62b4b9
Update upstream source from tag 'upstream/3.0.1' Update to upstream version '3.0.1' with Debian dir 158a841d12b8bdbcd6ad36b166cd7e0d21f9544c Andrius Merkys 1 year, 7 months ago
17 changed file(s) with 217 addition(s) and 166 deletion(s). Raw diff Collapse all Expand all
1313 mkdir build && cd build
1414 call activate coordgen_build
1515 cmake .. ^
16 -G "Visual Studio 15 2017 Win64" ^
16 -G "Visual Studio 16 2019" ^
1717 -DCMAKE_BUILD_TYPE=Release ^
1818 -DCOORDGEN_RIGOROUS_BUILD=ON ^
1919 -DBoost_NO_SYSTEM_PATHS=ON ^
8585
8686 set_target_properties(coordgen
8787 PROPERTIES
88 VERSION 3.0.0
88 VERSION 3.0.1
8989 SOVERSION 3
9090 )
9191
128128
129129 install(EXPORT coordgen-targets
130130 FILE ${PROJECT_NAME}-config.cmake
131 DESTINATION lib/cmake)
131 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
132132
133133 # Example
134134 if(COORDGEN_BUILD_EXAMPLE)
2929 void CoordgenFragmentBuilder::initializeCoordinates(
3030 sketcherMinimizerFragment* fragment) const
3131 {
32 assert(fragment->getAtoms().size());
32 assert(!fragment->getAtoms().empty());
3333 buildFragment(fragment);
3434 fragment->storeCoordinateInformation();
3535 }
6565 constrainOldCenter += a->templateCoordinates;
6666 constrainNewCenter += a->coordinates;
6767 }
68 if (constrainedAtoms.size() > 0) {
68 if (!constrainedAtoms.empty()) {
6969 constrainOldCenter /= constrainedAtoms.size();
7070 constrainNewCenter /= constrainedAtoms.size();
7171 }
143143 for (auto& temp : sketcherMinimizer::m_templates.getTemplates()) {
144144 foundTemplate = sketcherMinimizer::compare(atoms, bonds, temp, mapping);
145145 if (foundTemplate) {
146 if (atoms.size() > 0) {
146 if (!atoms.empty()) {
147147 atoms[0]->fragment->isTemplated = true;
148148 }
149149 for (unsigned int i = 0; i < atoms.size(); i++) {
214214 if (needsTemplate) {
215215 findTemplate(rings);
216216 }
217 while (rings.size() != 0) {
217 while (!rings.empty()) {
218218 auto centralRing = findCentralRingOfSystem(rings);
219219 buildRing(centralRing);
220220 rings.erase(
278278 void CoordgenFragmentBuilder::generateCoordinatesSideRings(
279279 stack<sketcherMinimizerRing*> sideRings) const
280280 {
281 while (sideRings.size()) {
281 while (!sideRings.empty()) {
282282 sketcherMinimizerRing* ring = sideRings.top();
283283 sideRings.pop();
284284 buildRing(ring);
384384 pivotAtom = fusionAtoms.at(0);
385385 pivotAtomOnParent = fusionAtoms.at(0);
386386 } else {
387 assert(fusionBond != NULL);
387 assert(fusionBond != nullptr);
388388 if (find(atoms.begin(), atoms.end(),
389389 fusionBond->getStartAtom()) != atoms.end()) {
390390 pivotAtom = fusionBond->getStartAtom();
544544 const vector<sketcherMinimizerAtom*>& atoms)
545545 {
546546 vector<sketcherMinimizerPointF> out;
547 assert(atoms.size());
547 assert(!atoms.empty());
548548 auto a = static_cast<float>(2 * M_PI / atoms.size());
549549 sketcherMinimizerPointF coords(0.f, 0.f);
550550 float angle = 0;
581581 isAtomVisited.insert(atomToStartFrom);
582582 }
583583
584 while (q.size()) {
584 while (!q.empty()) {
585585 generateCoordinatesNeighborsOfFirstAtomInQueue(q, isAtomVisited,
586586 fragment);
587587 }
613613 angles.push_back(static_cast<float>(M_PI * 0.5));
614614 }
615615 }
616 if (!angles.size()) {
616 if (angles.empty()) {
617617 for (unsigned int i = 0; i < atom->neighbors.size(); i++) {
618618 angles.push_back(static_cast<float>(2 * M_PI / angleDivision));
619619 }
627627 vector<sketcherMinimizerAtom*>& orderedNeighbors,
628628 vector<float>& angles) const
629629 {
630 if (atom->rings.size()) {
630 if (!atom->rings.empty()) {
631631 return initializeVariablesForNeighboursCoordinatesRingAtom(
632632 atom, isAtomVisited, startCoordinates, orderedNeighbors, angles);
633633 }
828828 if (doubleBond == nullptr) {
829829 return;
830830 }
831 if (atomsToMirror.size() && doubleBond) {
831 if (!atomsToMirror.empty() && doubleBond) {
832832 sketcherMinimizerAtom* firstCIPNeighborStart =
833833 doubleBond->startAtomCIPFirstNeighbor();
834834 if (firstCIPNeighborStart == nullptr) {
962962 break;
963963 }
964964 }
965 assert(startAtom != NULL);
965 assert(startAtom != nullptr);
966966 r->fusionAtoms[i] = orderChainOfAtoms(fusionAtoms, startAtom);
967967 }
968968 }
166166 sketcherMinimizerAtom* atom,
167167 std::set<sketcherMinimizerAtom*>& isAtomVisited,
168168 sketcherMinimizerPointF& startCoordinates,
169 std::vector<sketcherMinimizerAtom*>& orderedNeighbours,
169 std::vector<sketcherMinimizerAtom*>& orderedNeighbors,
170170 std::vector<float>& angles) const;
171171
172172 /* initialize data to generate coordinates of atoms bound to a ring atom */
174174 const sketcherMinimizerAtom* atom,
175175 std::set<sketcherMinimizerAtom*>& isAtomVisited,
176176 sketcherMinimizerPointF& startCoordinates,
177 std::vector<sketcherMinimizerAtom*>& orderedNeighbours,
177 std::vector<sketcherMinimizerAtom*>& orderedNeighbors,
178178 std::vector<float>& angles) const;
179179
180180 /* check if the atom is part of a macrocycle and has some degrees of freedom
4343 }
4444 #ifndef NDEBUG
4545 for (auto atom : molecule->getAtoms()) {
46 assert(atom->getFragment() != NULL);
46 assert(atom->getFragment() != nullptr);
4747 }
4848 #endif
49 if (fragments.size()) {
49 if (!fragments.empty()) {
5050 initializeInformation(fragments, molecule);
5151 }
5252 }
151151 if (atom->getBonds().size() > 3) {
152152 return false;
153153 }
154 if (atom->getRings().size()) {
154 if (!atom->getRings().empty()) {
155155 return false;
156156 }
157157 }
344344 // itself so it results visited
345345 q.push(fragment);
346346 sketcherMinimizerFragment* lastFragment = nullptr;
347 while (q.size()) {
347 while (!q.empty()) {
348348 lastFragment = q.front();
349349 q.pop();
350350 for (sketcherMinimizerBond* b : lastFragment->_interFragmentBonds) {
384384 {
385385 queue<sketcherMinimizerFragment*> fragmentsQueue;
386386 fragmentsQueue.push(mainFragment);
387 while (fragmentsQueue.size() > 0) {
387 while (!fragmentsQueue.empty()) {
388388 sketcherMinimizerFragment* fragment = fragmentsQueue.front();
389389 fragmentsQueue.pop();
390390 for (sketcherMinimizerBond* bond : fragment->_interFragmentBonds) {
429429 queue<sketcherMinimizerFragment*> q;
430430 vector<sketcherMinimizerFragment*> new_fragments;
431431 q.push(mainFragment);
432 while (q.size()) {
432 while (!q.empty()) {
433433 sketcherMinimizerFragment* fragment = q.front();
434434 q.pop();
435435 new_fragments.push_back(fragment);
109109 for (Hex* hex : p.m_list) {
110110 targetCoords.push_back(hex->coords());
111111 }
112 if (!targetCoords.size()) {
112 if (targetCoords.empty()) {
113113 return true; // both polyominoes are empty
114114 }
115115 int lowestx = m_list[0]->coords().x;
463463 void Polyomino::addHex(hexCoords coords)
464464 {
465465 int index = getIndexInList(coords);
466 assert(m_grid[index] == NULL);
466 assert(m_grid[index] == nullptr);
467467 Hex* h = new Hex(coords);
468468 m_list.push_back(h);
469469 m_grid[index] = h;
473473 {
474474 int index = getIndexInList(coords);
475475 Hex* hex = m_grid[getIndexInList(coords)];
476 assert(hex != NULL);
476 assert(hex != nullptr);
477477 for (unsigned int i = 0; i < m_list.size(); i++) {
478478 if (m_list[i] == hex) {
479479 m_list.erase(m_list.begin() + i);
506506 vertexCoords Polyomino::coordinatesOfSubstituent(const vertexCoords pos) const
507507 {
508508 vector<Hex*> neighbors = vertexNeighbors(pos);
509 assert(neighbors.size() != 0);
509 assert(!neighbors.empty());
510510 assert(neighbors.size() < 3);
511511 vertexCoords out = pos;
512512
557557 vertexCoords nextVertex = currentHex->followingVertex(currentVertex);
558558 do {
559559 bool skip = false;
560 if (pentagonVertices.size()) {
560 if (!pentagonVertices.empty()) {
561561 for (auto pentagonVertice : pentagonVertices) {
562562 if (pentagonVertice == currentVertex) {
563563 skip = true;
685685 pols = listOfEquivalents(pols);
686686 pols = removeDuplicates(pols);
687687
688 } while (pols.size());
688 } while (!pols.empty());
689689 }
690690 if (found) {
691691 vector<vertexCoords> path = chosenP.getPath();
692692
693693 writePolyominoCoordinates(path, atoms, startOfChosen);
694 if (chosenP.pentagonVertices.size()) {
694 if (!chosenP.pentagonVertices.empty()) {
695695 atoms.at(0)->molecule->requireMinimization();
696696 }
697697 } else { // could not find a shape. fallback methods
981981 queue<sketcherMinimizerAtom*> q;
982982 q.push(a);
983983 visited[parent] = true;
984 while (q.size()) {
984 while (!q.empty()) {
985985 sketcherMinimizerAtom* thisA = q.front();
986986 q.pop();
987987 visited[thisA] = true;
11401140 vector<hexCoords> newPos = p.freeVertexNeighborPositions(path[counter]);
11411141 vector<hexCoords> oldPos = allowedHexs[r];
11421142 vector<hexCoords> nextPos;
1143 if (!oldPos.size()) {
1143 if (oldPos.empty()) {
11441144 nextPos = newPos;
11451145 } else {
11461146 for (auto toCheck : newPos) {
11521152 }
11531153 }
11541154 }
1155 if (!nextPos.size()) {
1155 if (nextPos.empty()) {
11561156 return false;
11571157 }
11581158 allowedHexs[r] = nextPos;
152152 {
153153 public:
154154 Polyomino();
155 Polyomino(const Polyomino& p);
155 Polyomino(const Polyomino& rhs);
156156 ~Polyomino();
157 Polyomino& operator=(const Polyomino& rhv);
157 Polyomino& operator=(const Polyomino& rhs);
158158
159159 /*
160160 explore the topology of the polyominoes and returns true if they have the
7373 if (skipMinimization) {
7474 return;
7575 }
76 if (!_interactions.size()) {
76 if (_interactions.empty()) {
7777 setupInteractions();
7878 }
7979
550550 if (ringInteractions.size() != 1 || nonRingInteractions.size() != 2) {
551551 invertedMacrocycleBond = false;
552552 }
553 if (ringInteractions.size()) { // subtract all the ring angles from 360
553 if (!ringInteractions.empty()) { // subtract all the ring angles from 360
554554 // and divide the remaining equally
555555 // between the other interactions
556556 float totalAngleInRings = 0;
862862 }
863863 }
864864 }
865 if (m_residueInteractions.size() && residueInteractions) {
865 if (!m_residueInteractions.empty() && residueInteractions) {
866866 for (auto r : m_residues) {
867867 if (r->residueInteractions.size() > 1) {
868868 for (unsigned int ri1 = 0;
15121512 bool CoordgenMinimizer::hasNaNCoordinates(
15131513 const std::vector<sketcherMinimizerAtom*>& atoms)
15141514 {
1515 for (sketcherMinimizerAtom* a : atoms)
1516 if (a->coordinates.x() != a->coordinates.x() ||
1517 a->coordinates.y() != a->coordinates.y()) {
1515 for (sketcherMinimizerAtom* a : atoms) {
1516 if (std::isnan(a->coordinates.x()) || std::isnan(a->coordinates.y())) {
15181517 return true;
15191518 }
1519 }
15201520 return false;
15211521 }
15221522
11
22 [![Azure_Build_Status](https://dev.azure.com/patlorton/coordgenlibs/_apis/build/status/schrodinger.coordgenlibs?branchName=master)](https://dev.azure.com/patlorton/coordgenlibs/_build/latest?definitionId=2&branchName=master)
33
4 This is **Schrödinger, Inc's** 2D coordinate generation. It was formerly proprietary code, but is now released under the [BSD license](https://github.com/schrodinger/coordgenlibs/blob/master/LICENSE). The emphasis of these algorithms are on quality of 2D coordinates rather than speed of generation. The algorithm distinguishes itself from many others by doing well with both macrocycles and metal complexes. It also does extremely well on typical drug-like small molecules, and has been validated on millions of compounds.
4 This is **Schrödinger, Inc's** 2D coordinate generation. It was formerly
5 proprietary code, but is now released under the [BSD
6 license](https://github.com/schrodinger/coordgenlibs/blob/master/LICENSE). The
7 emphasis of these algorithms are on quality of 2D coordinates rather than speed
8 of generation. The algorithm distinguishes itself from many others by doing
9 well with both macrocycles and metal complexes. It also does extremely well on
10 typical drug-like small molecules, and has been validated on millions of
11 compounds.
512
6 Schrodinger intends to continue to contribute to this code as it still uses it inside its products, but will also be happy if others contribute pull-requests when there are improvements they would like to make. We'll also be happy to hear bug reports or feature requests from use of this code, though make no guarantee on our ability to process these.
13 Schrodinger intends to continue to contribute to this code as it still uses it
14 inside its products, but will also be happy if others contribute pull-requests
15 when there are improvements they would like to make. We'll also be happy to
16 hear bug reports or feature requests from use of this code, though make no
17 guarantee on our ability to process these.
718
819 ## Documentation
920
1122
1223 ## Templates
1324
14 Coordgen uses templates for some macrocycle systems. The source for the templates is `templates.mae`. If
15 you're an end user of coordgen, you can add local templates in a file called
16 `user_templates.mae` in a directory specified by `CoordgenTemplates::setTemplateDir()`. If you want to
17 update the templates, add new templates to `templates.mae` and run `mol_generator.py` to generate the
25 Coordgen uses templates for some macrocycle systems. The source for the
26 templates is `templates.mae`. If you're an end user of coordgen, you can add
27 local templates in a file called `user_templates.mae` in a directory specified
28 by `CoordgenTemplates::setTemplateDir()`. If you want to update the templates,
29 add new templates to `templates.mae` and run `mol_generator.py` to generate the
1830 source files.
1931
2032 ## Usage example
2133
22 Code for a sample executable is provided in the `example_dir` directory. Building the example executable is enabled by default, but can be disabled by means of the `COORDGEN_BUILD_EXAMPLE` option.
34 Code for a sample executable is provided in the `example_dir` directory.
35 Building the example executable is enabled by default, but can be disabled by
36 means of the `COORDGEN_BUILD_EXAMPLE` option.
2337
2438 ## Automated Testing
2539
26 Automated testing is still primarily taking place inside Schrodinger's internal build system, although tests are incrementally being added to the `testing` directory. Building the tests is enabled by default, but can be disabled by means of the `COORDGEN_BUILD_TESTS` option.
40 Automated testing is still primarily taking place inside Schrodinger's internal
41 build system, although tests are incrementally being added to the `testing`
42 directory. Building the tests is enabled by default, but can be disabled by
43 means of the `COORDGEN_BUILD_TESTS` option.
2744
28 Memory debugging is, by default, configured to use `valgrind`. It can be run on the tests by passing `-DCMAKE_BUILD_TYPE=Debug` to cmake, to enable building the debugging symbols, and then using `ctest -T memcheck` inside the build directory.
45 Memory debugging is, by default, configured to use `valgrind`. It can be run on
46 the tests by passing `-DCMAKE_BUILD_TYPE=Debug` to cmake, to enable building
47 the debugging symbols, and then using `ctest -T memcheck` inside the build
48 directory.
2949
3050 ## Building from source
3151
3252 ### Requirements
3353
34 To build coordgen, you will need to have the following installed in your system:
54 To build coordgen, you will need to have the following installed in your
55 system:
3556
3657 - **CMake** version 3.2 or later.
37 - The development files for the **Boost libraries**. At least the **iostreams** and **regex** components are required. In case of also building the unit tests, the **filesystems** and **unit_test_framework** components will also be required.
58 - The development files for the **Boost libraries**. At least the **iostreams**
59 and **regex** components are required. In case of also building the unit
60 tests, the **filesystems** and **unit_test_framework** components will also
61 be required.
3862 - A **C++ compiler** supporting the C++11 standard.
3963 - A compiled instance of the **maeparser library** or its source code.
4064
41 In case **maeparser** is not available on your system, neither as a compiled library or as source code, if a working `git` executable and an internet connection are available, the builder can automatically download the source and build **maeparser** for you.
65 In case **maeparser** is not available on your system, neither as a compiled
66 library or as source code, if a working `git` executable and an internet
67 connection are available, the builder can automatically download the source and
68 build **maeparser** for you.
4269
4370 ### Building
4471
45 1. Create a build directory inside the the one that contains Coordgen, and move into it:
72 1. Create a build directory inside the the one that contains Coordgen, and move
73 into it:
4674
47 ```bash
48 mkdir build
49 cd build
50 ```
75 ```bash
76 mkdir build
77 cd build
78 ```
5179
52 1. Run `cmake` to configure the build, passing the path to the directory where the sources are located (just `..` if you created `build` inside the sources directory). At this point, you should add any required flags to the `cmake` command. Check the 'Options' section in CMakeLists.txt to see which options are available.
80 1. Run `cmake` to configure the build, passing the path to the directory where
81 the sources are located (just `..` if you created `build` inside the sources
82 directory). At this point, you should add any required flags to the `cmake`
83 command. Check the 'Options' section in CMakeLists.txt to see which options
84 are available.
5385
54 ```bash
55 cmake .. -Dmaeparser_DIR=/home/schrodinger/maeparser_install -DCMAKE_INSTALL_PREFIX=/home/schrodinger/coordgen_install`
56 ```
86 ```bash
87 cmake .. -Dmaeparser_DIR=/home/schrodinger/maeparser_install -DCMAKE_INSTALL_PREFIX=/home/schrodinger/coordgen_install`
88 ```
5789
58 A few notes on the maeparser dependency:
90 A few notes on the maeparser dependency:
5991
60 - CMake will, by default, search your system's default library paths for the maeparser library. If a `CMAKE_INSTALL_PREFIX` was specified to Coordgen, CMake will also search for maeparser there.
92 - CMake will, by default, search your system's default library paths for
93 the maeparser library. If a `CMAKE_INSTALL_PREFIX` was specified to
94 Coordgen, CMake will also search for maeparser there.
6195
62 - If you already built and installed maeparser using the `CMAKE_INSTALL_PREFIX` to set the installation path, you should pass the exact same path to Coordgen with `maeparser_DIR`.
96 - If you already built and installed maeparser using the
97 `CMAKE_INSTALL_PREFIX` to set the installation path, you should pass the
98 exact same path to Coordgen with `maeparser_DIR`.
6399
64 - If CMake cannot find a compiled library for maeparser, it will attempt to download the source code from GitHub and build it. The release to be downloaded if the library is not found can be set using the `-DMAEPARSER_VERSION` flag. The sources will be stored in a directory named like `maeparser-{MAEPARSER_VERSION}` under the coordgen sources.
100 - If CMake cannot find a compiled library for maeparser, it will attempt to
101 download the source code from GitHub and build it. The release to be
102 downloaded if the library is not found can be set using the
103 `-DMAEPARSER_VERSION` flag. The sources will be stored in a directory
104 named like `maeparser-{MAEPARSER_VERSION}` under the coordgen sources.
65105
66 - If `maeparser_DIR` was passed to CMake, and the library was not found, CMake will **NOT** download the sources from GitHub (since we expected to find a compiled library).
106 - If `maeparser_DIR` was passed to CMake, and the library was not found,
107 CMake will **NOT** download the sources from GitHub (since we expected to
108 find a compiled library).
67109
68 - If a copy of maeparser's source is found under the proper path, it be used, instead of being downloaded again.
110 - If a copy of maeparser's source is found under the proper path, it be
111 used, instead of being downloaded again.
69112
70 - If you want to use Coordgen in a CMake project that also depends on maeparser, set up the maeparser first, as Coordgen will be able to find and use it, without searching for further libraries or compiling it again from the source code.
113 - If you want to use Coordgen in a CMake project that also depends on
114 maeparser, set up the maeparser first, as Coordgen will be able to find
115 and use it, without searching for further libraries or compiling it again
116 from the source code.
71117
72118 1. Build and install:
73119
74 ```bash
75 make -j install
76 ```
120 ```bash
121 make -j install
122 ```
22 - dev/*
33
44 jobs:
5 - job: Ubuntu_18_04_x64
5 - job: Ubuntu_20_04_x64
66 timeoutInMinutes: 90
77 pool:
8 vmImage: ubuntu-18.04
8 vmImage: ubuntu-20.04
99 variables:
10 compiler: gxx_linux-64=7.2.0
10 compiler: gxx_linux-64
1111 boost_version: 1.67.0
1212 number_of_cores: nproc
1313 python_name: python37
1414 shared_lib: ON
1515 steps:
1616 - template: .azure-pipelines/linux_build.yml
17 - job: Ubuntu_18_04_x64_static
17 - job: Ubuntu_20_04_x64_static
1818 timeoutInMinutes: 90
1919 pool:
20 vmImage: ubuntu-18.04
20 vmImage: ubuntu-20.04
2121 variables:
22 compiler: gxx_linux-64=7.2.0
22 compiler: gxx_linux-64
2323 boost_version: 1.67.0
2424 number_of_cores: nproc
2525 python_name: python37
2626 shared_lib: OFF
2727 steps:
2828 - template: .azure-pipelines/linux_build.yml
29 - job: macOS_10_14_x64
29 - job: macOS_10_15_x64
3030 timeoutInMinutes: 90
3131 pool:
32 vmImage: macos-10.14
32 vmImage: macos-10.15
3333 variables:
3434 compiler: clangxx_osx-64
3535 boost_version: 1.67.0
3939 shared_lib: ON
4040 steps:
4141 - template: .azure-pipelines/mac_build.yml
42 - job: macOS_10_14_x64_static
42 - job: macOS_10_15_x64_static
4343 timeoutInMinutes: 90
4444 pool:
45 vmImage: macos-10.14
45 vmImage: macos-10.15
4646 variables:
4747 compiler: clangxx_osx-64
4848 boost_version: 1.67.0
5252 shared_lib: OFF
5353 steps:
5454 - template: .azure-pipelines/mac_build.yml
55 - job: Windows_VS2017_x64
55 - job: Windows_VS2019_x64
5656 timeoutInMinutes: 90
5757 pool:
58 vmImage: vs2017-win2016
58 vmImage: windows-2019
5959 variables:
60 compiler: vs2017_win-64
60 compiler: vs2019_win-64
6161 boost_version: 1.67.0
6262 number_of_cores: "%NUMBER_OF_PROCESSORS%"
6363 python_name: python37
6565 boost_lib_prefix: ""
6666 steps:
6767 - template: .azure-pipelines/vs_build.yml
68 - job: Windows_VS2017_x64_static
68 - job: Windows_VS2019_x64_static
6969 timeoutInMinutes: 90
7070 pool:
71 vmImage: vs2017-win2016
71 vmImage: windows-2019
7272 variables:
73 compiler: vs2017_win-64
73 compiler: vs2019_win-64
7474 boost_version: 1.67.0
7575 number_of_cores: "%NUMBER_OF_PROCESSORS%"
7676 python_name: python37
115115 q.push(minMol->_atoms[scoreMaxI]);
116116 minMol->_atoms[scoreMaxI]->_generalUseVisited = true;
117117
118 while (q.size()) {
118 while (!q.empty()) {
119119 sketcherMinimizerAtom* at = q.front();
120120 newAtoms.push_back(at);
121121 q.pop();
280280
281281 bool sketcherMinimizer::structurePassSanityCheck() const
282282 {
283 if (!m_atoms.size()) {
283 if (m_atoms.empty()) {
284284 return false;
285285 }
286286 for (auto molecule : m_molecules) {
372372 sketcherMinimizerMolecule* mol, vector<sketcherMinimizerMolecule*>& mols)
373373 {
374374
375 if (!mol->_atoms.size()) {
375 if (mol->_atoms.empty()) {
376376 mols.push_back(mol);
377377 return;
378378 }
387387 break;
388388 }
389389 }
390 while (q.size()) {
390 while (!q.empty()) {
391391 sketcherMinimizerAtom* a = q.front();
392392 q.pop();
393393 a->_generalUseVisited = true;
404404 newAtoms.push_back(a);
405405 }
406406 }
407 if (!newAtoms.size()) {
407 if (newAtoms.empty()) {
408408 mols.push_back(mol);
409409 for (sketcherMinimizerMolecule* m : mols) {
410410 for (sketcherMinimizerAtom* a : m->_atoms) {
455455 const sketcherMinimizerAtom* at2,
456456 const sketcherMinimizerAtom* at3)
457457 {
458 if (!at1->rings.size()) {
458 if (at1->rings.empty()) {
459459 return nullptr;
460460 }
461 if (!at2->rings.size()) {
461 if (at2->rings.empty()) {
462462 return nullptr;
463463 }
464 if (!at3->rings.size()) {
464 if (at3->rings.empty()) {
465465 return nullptr;
466466 }
467467 sketcherMinimizerRing* r = nullptr;
532532 if (lastAtom) {
533533 queue<sketcherMinimizerAtom*> q;
534534 q.push(lastAtom);
535 while (q.size()) {
535 while (!q.empty()) {
536536 lastAtom = q.front();
537537 q.pop();
538538 lastAtom->_generalUseVisited = true;
627627 sketcherMinimizerPointF cent(0.f, 0.f);
628628 for (sketcherMinimizerAtom* a : mol->_atoms)
629629 cent += a->coordinates;
630 if (mol->_atoms.size()) {
630 if (!mol->_atoms.empty()) {
631631 cent /= mol->_atoms.size();
632632 }
633633
786786 break;
787787 }
788788 }
789 if (!angles.size()) {
789 if (angles.empty()) {
790790 angles.emplace_back(weight, angle);
791791 }
792792 }
832832 float weight = 1.f;
833833 auto increment = static_cast<float>(M_PI / 6);
834834 for (sketcherMinimizerAtom* a : mol->_atoms) {
835 if (a->rings.size()) {
835 if (!a->rings.empty()) {
836836 continue;
837837 }
838838 if (a->neighbors.size() > 1) {
988988 }
989989 }
990990
991 if (angles.size()) {
991 if (!angles.empty()) {
992992 int bestI = 0;
993993 for (i = 0; i < angles.size(); i++) {
994994 if (angles[i].first > angles[bestI].first) {
10001000 sketcherMinimizerPointF center(0.f, 0.f);
10011001 for (sketcherMinimizerAtom* at : mol->_atoms)
10021002 center += at->coordinates;
1003 if (mol->_atoms.size()) {
1003 if (!mol->_atoms.empty()) {
10041004 center /= mol->_atoms.size();
10051005 }
10061006
10511051 void sketcherMinimizer::findFragments()
10521052 {
10531053
1054 assert(m_molecules.size());
1054 assert(!m_molecules.empty());
10551055 for (sketcherMinimizerMolecule* mol : m_molecules) {
10561056 CoordgenFragmenter::splitIntoFragments(mol);
1057 if (!mol->_fragments.size()) {
1057 if (mol->_fragments.empty()) {
10581058 continue;
10591059 }
10601060 vector<sketcherMinimizerFragment*> fragments = mol->_fragments;
11501150 }
11511151
11521152 sketcherMinimizer min;
1153 if (metaMol->_atoms.size()) {
1153 if (!metaMol->_atoms.empty()) {
11541154 min.setEvenAngles(true);
11551155 min.initialize(metaMol);
11561156 findFragments();
12051205 }
12061206 residueQueue.push(residue);
12071207 visitedResidues.insert(residue);
1208 while (residueQueue.size()) {
1208 while (!residueQueue.empty()) {
12091209 auto topResidue = residueQueue.front();
12101210 finalVec.push_back(topResidue);
12111211 residueQueue.pop();
14551455 sketcherMinimizerPointF position = shape.at(index);
14561456 if (alreadyAResidueHere ||
14571457 (placeOnlyInteracting &&
1458 !residue->residueInteractionPartners.size())) {
1458 residue->residueInteractionPartners.empty())) {
14591459 outliers.insert(residue);
14601460 } else {
14611461 residue->coordinates = position;
16671667 return firstContour.size() > secondContour.size();
16681668 });
16691669 vector<sketcherMinimizerPointF> returnValue;
1670 if (result.size() > 0) {
1670 if (!result.empty()) {
16711671 for (unsigned int i = 0; i < result.at(0).size(); i += 2) {
16721672 returnValue.emplace_back(result.at(0).at(i),
16731673 result.at(0).at(i + 1));
17221722 void sketcherMinimizer::placeResidues(
17231723 const vector<sketcherMinimizerAtom*>& atoms)
17241724 {
1725 if (!m_residues.size()) {
1725 if (m_residues.empty()) {
17261726 return;
17271727 }
1728 if (!atoms.size()) {
1728 if (atoms.empty()) {
17291729 placeResiduesProteinOnlyMode();
17301730 return;
17311731 }
21412141 mol->isPlaced = true;
21422142 continue;
21432143 }
2144 if (mol->m_proximityRelations.size()) {
2144 if (!mol->m_proximityRelations.empty()) {
21452145 sketcherMinimizerPointF atomsCenter =
21462146 sketcherMinimizerPointF(0, 0);
21472147 int atomsN = 0;
22452245
22462246 auto* metaMol = new sketcherMinimizerMolecule;
22472247 for (sketcherMinimizerMolecule* mol : m_molecules) {
2248 if (mol->m_proximityRelations.size()) {
2248 if (!mol->m_proximityRelations.empty()) {
22492249 auto* a = new sketcherMinimizerAtom;
22502250 a->molecule = metaMol;
22512251 metaMol->_atoms.push_back(a);
22762276 }
22772277 sketcherMinimizer min(m_minimizer.getPrecision());
22782278
2279 if (metaMol->_atoms.size()) {
2279 if (!metaMol->_atoms.empty()) {
22802280 min.setEvenAngles(true);
22812281
22822282 min.initialize(metaMol);
22932293 // a bonding pattern
22942294
22952295 for (auto molecule : min.m_molecules) {
2296 if (molecule->_rings.size() >
2297 0) { // if at least three molecules are connected to each other
2296 if (!molecule->_rings.empty()) {
2297 // if at least three molecules are connected to each other
22982298 // (i.e. two residues are connected to each other and both to
22992299 // the ligand) abort the ligandResidue display style)
23002300 ligandResidueStyle = false;
23312331 map<sketcherMinimizerMolecule*, sketcherMinimizerMolecule*> getParent;
23322332
23332333 q.push(centralMol);
2334 while (q.size()) {
2334 while (!q.empty()) {
23352335 sketcherMinimizerMolecule* mol = q.front();
23362336 q.pop();
23372337 if (mol->isPlaced) {
24052405 if (b->isResidueInteraction()) {
24062406 auto* ri = static_cast<sketcherMinimizerResidueInteraction*>(b);
24072407 if (ri->startAtom->molecule == parent &&
2408 ri->m_otherStartAtoms.size()) {
2408 !ri->m_otherStartAtoms.empty()) {
24092409 paddV = sketcherMinimizerAtom::getSingleAdditionVector(
24102410 ri->getAllStartAtoms());
24112411 } else if (ri->endAtom->molecule == parent &&
2412 ri->m_otherEndAtoms.size()) {
2412 !ri->m_otherEndAtoms.empty()) {
24132413 paddV = sketcherMinimizerAtom::getSingleAdditionVector(
24142414 ri->getAllEndAtoms());
24152415 }
25472547 // find centers for molecules bound by proximity relations
25482548 vector<sketcherMinimizerMolecule*> proximityMols;
25492549 for (sketcherMinimizerMolecule* mol : m_molecules) {
2550 if (mol->m_proximityRelations.size()) {
2550 if (!mol->m_proximityRelations.empty()) {
25512551 proximityMols.push_back(mol);
25522552 }
25532553 }
25542554 sketcherMinimizerPointF center(0.f, 0.f);
2555 if (proximityMols.size()) {
2555 if (!proximityMols.empty()) {
25562556 placeMoleculesWithProximityRelations(proximityMols);
25572557 } else {
25582558 int maxI = 0;
27122712 void sketcherMinimizer::initializeFragments()
27132713 {
27142714
2715 if (!_fragments.size()) {
2715 if (_fragments.empty()) {
27162716 cerr << "Sketcherlibs warning: no fragments to initialize" << endl;
27172717 return;
27182718 }
33203320 }
33213321
33223322 bool ok = false;
3323 if (b->rings.size() == 0) {
3323 if (b->rings.empty()) {
33243324 ok = true;
33253325 } else {
33263326 ok = true;
35383538 }
35393539 }
35403540
3541 if (dds.size()) {
3541 if (!dds.empty()) {
35423542 int maxI = 0;
35433543 for (unsigned int i = 0; i < ns.size(); ++i) {
35443544 if (ns[i] > ns[maxI]) {
405405 /* score the position of the given strands */
406406 float scoreSSEPosition(const std::vector<sketcherMinimizerResidue*>& SSE,
407407 const std::vector<sketcherMinimizerPointF>& shape,
408 int shapeN, std::vector<bool>& penalties, float f,
408 int shapeN, std::vector<bool>& penalties, float startingPosition,
409409 float increment);
410410
411411 /* score the distance between the two given points of connected residues */
113113 for (size_t i = 0; i < a.allParents.size(); i++) {
114114 os << a.allParents[i]->atomicNumber << "("
115115 << (*a.scores)[a.allParents[i]] << ")";
116 if ((*a.medals)[a.allParents[i]].size()) {
116 if (!(*a.medals)[a.allParents[i]].empty()) {
117117 cerr << "<";
118118 for (int ii : (*a.medals)[a.allParents[i]]) {
119119 cerr << ii << "|";
231231 {
232232 /* return a ring shared by the two atoms. return a non-macrocycle if
233233 * possible */
234 if (!atom1->rings.size()) {
234 if (atom1->rings.empty()) {
235235 return nullptr;
236236 }
237 if (!atom2->rings.size()) {
237 if (atom2->rings.empty()) {
238238 return nullptr;
239239 }
240240
350350 vector<sketcherMinimizerAtom*>
351351 sketcherMinimizerAtom::clockwiseOrderedNeighbors() const
352352 {
353 vector<pair<float, sketcherMinimizerAtom*>> rankedNeighbors;
354 rankedNeighbors.reserve(neighbors.size());
355 for (auto&& neighbor : neighbors) {
356 float newAngle = sketcherMinimizerMaths::signedAngle(
357 neighbors[0]->coordinates, coordinates,
358 neighbor->coordinates);
359 if (std::isnan(newAngle)) {
360 newAngle = 361;
361 } else if (newAngle < 0) {
362 newAngle += 360;
363 }
364 rankedNeighbors.emplace_back(newAngle, neighbor);
365 }
366 std::sort(rankedNeighbors.begin(), rankedNeighbors.end());
353367 vector<sketcherMinimizerAtom*> orderedNeighs;
354 vector<sketcherMinimizerAtom*> neighs = neighbors;
355 int lastPoppedIndex = 0;
356 sketcherMinimizerAtom* lastPoppedAtom = neighs[lastPoppedIndex];
357 orderedNeighs.push_back(lastPoppedAtom);
358 neighs.erase(neighs.begin() + lastPoppedIndex);
359
360 while (neighs.size()) {
361 float smallestAngle = 361;
362 for (unsigned int i = 0; i < neighs.size(); i++) {
363 float newAngle = sketcherMinimizerMaths::signedAngle(
364 lastPoppedAtom->coordinates, coordinates,
365 neighs[i]->coordinates);
366 if (newAngle < 0) {
367 newAngle += 360;
368 }
369 if (newAngle < smallestAngle) {
370 smallestAngle = newAngle;
371 lastPoppedIndex = i;
372 }
373 }
374 lastPoppedAtom = neighs[lastPoppedIndex];
375 orderedNeighs.push_back(lastPoppedAtom);
376 neighs.erase(neighs.begin() + lastPoppedIndex);
368 orderedNeighs.reserve(neighbors.size());
369 for (const auto& rankedNeighbor : rankedNeighbors) {
370 orderedNeighs.push_back(rankedNeighbor.second);
377371 }
378372 return orderedNeighs;
379373 }
419413 bbonds.erase(bbonds.begin() + lastPoppedIndex);
420414
421415 // TODO: consider using sketcherMinimizerAtom::clockwiseOrderedNeighbors
422 while (neighs.size()) { // order atoms
416 while (!neighs.empty()) { // order atoms
423417 float smallestAngle = 361;
424418 for (unsigned int i = 0; i < neighs.size(); i++) {
425419 float newAngle = sketcherMinimizerMaths::signedAngle(
830824 center->_generalUseVisited = true;
831825 atomPriorities[i].a->_generalUseVisited = true;
832826 int counter = 0;
833 while (q.size()) {
827 while (!q.empty()) {
834828 counter++;
835829 sketcherMinimizerAtom* at = q.front();
836830 q.pop();
968962 assert(center->molecule);
969963 assert(at1->molecule == center->molecule);
970964 assert(at2->molecule == center->molecule);
971 assert(center->molecule->_atoms.size());
965 assert(!center->molecule->_atoms.empty());
972966 assert(at1);
973967 assert(at2);
974968
10181012
10191013 int level = 1;
10201014
1021 while (AN1.size() || AN2.size()) {
1015 while (!AN1.empty() || !AN2.empty()) {
10221016 level++;
10231017
10241018 stable_sort(AN1.begin(), AN1.end());
10681062 vector<CIPAtom> copyV = V;
10691063 V.clear();
10701064 map<sketcherMinimizerAtom*, unsigned int> friendsMask;
1071 while (copyV.size()) {
1065 while (!copyV.empty()) {
10721066 int bestI = 0;
10731067 for (unsigned int i = 1; i < copyV.size(); i++) {
10741068 if (copyV[i].isBetter(copyV[bestI], &friendsMask)) {
11581152 void sketcherMinimizerAtom::assignMedals(vector<CIPAtom>& v)
11591153 {
11601154
1161 if (v.size() < 1) {
1155 if (v.empty()) {
11621156 return;
11631157 }
11641158 map<sketcherMinimizerAtom*, vector<int>>* medals = v[0].medals;
11971191 void sketcherMinimizerAtom::finalizeScores(vector<CIPAtom>& v)
11981192 {
11991193
1200 if (v.size() < 1) {
1194 if (v.empty()) {
12011195 return;
12021196 }
12031197 vector<bool> isEqualToPrevious(v.size());
12771271 bnds.erase(bnds.begin() + lastPoppedIndex);
12781272
12791273 // TODO: consider using sketcherMinimizerAtom::clockwiseOrderedNeighbors
1280 while (neighs.size()) { // order atoms
1274 while (!neighs.empty()) { // order atoms
12811275 float smallestAngle = 361;
12821276 for (unsigned int i = 0; i < neighs.size(); i++) {
12831277 float newAngle = sketcherMinimizerMaths::signedAngle(
15671561 {
15681562 sketcherMinimizerPointF out(0.f, 0.f);
15691563 float totalf = 0.f;
1570 if (neighbors.size()) {
1564 if (!neighbors.empty()) {
15711565 for (auto neighbor : neighbors) {
15721566 float f = 1.f;
15731567 if (sketcherMinimizer::sameRing(this, neighbor)) {
16771671 isVisited[excludedAtom] = true;
16781672 q.push(this);
16791673 isVisited[this] = true;
1680 while (q.size()) {
1674 while (!q.empty()) {
16811675 sketcherMinimizerAtom* atom = q.front();
16821676 subMolecule.push_back(atom);
16831677 q.pop();
123123
124124 int CoordgenScaleFragmentDOF::numberOfStates() const
125125 {
126 if (m_fragment->getRings().size() == 0) {
126 if (m_fragment->getRings().empty()) {
127127 return 1;
128128 }
129129 return 5;
282282 : CoordgenFragmentDOF(pivotAtom->getFragment()), m_pivotAtom(pivotAtom),
283283 m_boundAtom(boundAtom)
284284 {
285 assert(pivotAtom->bondTo(boundAtom) != NULL);
285 assert(pivotAtom->bondTo(boundAtom) != nullptr);
286286 addAtom(boundAtom);
287287 }
288288
7676 return m_grid;
7777 }; // returns a vector of all the data set with setValue.
7878
79 float getNodeValue(unsigned int i, unsigned int j) const;
79 float getNodeValue(unsigned int x, unsigned int y) const;
8080
8181 private:
8282 void addSide(sketcherMinimizerMarchingSquaresPoint* p1,
6161 min.setY(0.f);
6262 max.setX(0.f);
6363 max.setY(0.f);
64 if (_atoms.size()) {
64 if (!_atoms.empty()) {
6565 min = _atoms[0]->coordinates;
6666 max = _atoms[0]->coordinates;
6767 for (auto a : _atoms) {
9393
9494 sketcherMinimizerPointF sketcherMinimizerMolecule::center()
9595 {
96 if (!_atoms.size()) {
96 if (_atoms.empty()) {
9797 return sketcherMinimizerPointF(0.f, 0.f);
9898 }
9999 sketcherMinimizerPointF c(.0f, .0f);
433433 fragmentBuilder.orderRingAtoms(ring);
434434 std::vector<doubleBondConstraint> constraints =
435435 macrocycleBuilder.getDoubleBondConstraints(atoms);
436 BOOST_REQUIRE(constraints.size() == 0);
436 BOOST_REQUIRE(constraints.empty());
437437 }
438438 }
439439 }
488488 BOOST_REQUIRE_EQUAL(orderedNeighbors[1], neigh3);
489489 BOOST_REQUIRE_EQUAL(orderedNeighbors[2], neigh2);
490490 }
491
492 BOOST_AUTO_TEST_CASE(testClockwiseOrderedNaN)
493 {
494 std::unique_ptr<sketcherMinimizerMolecule> mol("CN(C)C"_smiles);
495 auto& atoms = mol->getAtoms();
496 sketcherMinimizerAtom* center = atoms.at(0);
497 sketcherMinimizerAtom* neigh1 = atoms.at(1);
498 neigh1->coordinates = sketcherMinimizerPointF(std::nanf("name"), std::nanf("name"));
499 const auto orderedNeighbors = center->clockwiseOrderedNeighbors();
500 }
501
491502
492503 BOOST_AUTO_TEST_CASE(testbicyclopentane)
493504 {