Changeset 5a479d for src/Python/getGraph6String.cpp
- Timestamp:
- Jan 24, 2024, 4:53:03 PM (21 months ago)
- Branches:
- Candidate_v1.7.0, stable
- Children:
- d203d1e
- Parents:
- d083cc
- git-author:
- Frederik Heber <frederik.heber@…> (01/22/24 22:21:29)
- git-committer:
- Frederik Heber <frederik.heber@…> (01/24/24 16:53:03)
- File:
-
- 1 edited
-
src/Python/getGraph6String.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Python/getGraph6String.cpp
rd083cc r5a479d 39 39 #include "CodePatterns/Assert.hpp" 40 40 #include "CodePatterns/Log.hpp" 41 #include <algorithm> 41 42 #include <string> 42 43 44 #include "Element/element.hpp" 43 45 #include "Graph/Graph6Writer.hpp" 44 46 #include "World.hpp" … … 68 70 return output.str(); 69 71 } 72 73 MoleCuilder::detail::stringVec MoleCuilder::detail::module_getAllGraph6Strings() 74 { 75 /* 76 * Returns all graph6 representation by creating all permutations 77 * of the non-hydrogen atoms. 78 */ 79 std::vector<const atom *> selected_atoms = World::getConstInstance().getSelectedAtoms(); 80 // split set into hydrogen and non-hydrogen 81 const std::vector<const atom *>::iterator partitioner = 82 std::partition(selected_atoms.begin(), selected_atoms.end(), [](const atom * walker) { return walker->getElement().getAtomicNumber() != (atomicNumber_t)1; }); 83 std::sort(selected_atoms.begin(), partitioner); 84 MoleCuilder::detail::stringVec returnlist; 85 do { 86 Graph6Writer writer(selected_atoms); 87 std::stringstream output; 88 writer.write_graph6(output); 89 returnlist.push_back(output.str()); 90 } while(std::next_permutation(selected_atoms.begin(), partitioner)); 91 92 return returnlist; 93 } 94 95 MoleCuilder::detail::stringVec MoleCuilder::detail::module_getAllElementListAsStrings() 96 { 97 /* 98 * Returns non-hydrogen element lists by creating all permutations 99 * of the non-hydrogen atoms. 100 */ 101 std::vector<const atom *> selected_atoms = World::getConstInstance().getSelectedAtoms(); 102 // split set into non-hydrogen and hydrogen 103 const std::vector<const atom *>::iterator partitioner = 104 std::partition(selected_atoms.begin(), selected_atoms.end(), [](const atom * walker) { return walker->getElement().getAtomicNumber() != (atomicNumber_t)1; }); 105 std::sort(selected_atoms.begin(), partitioner); 106 MoleCuilder::detail::stringVec returnlist; 107 do { 108 Graph6Writer writer(selected_atoms); 109 std::stringstream output; 110 writer.write_simple_elementlist(output); 111 returnlist.push_back(output.str()); 112 } while(std::next_permutation(selected_atoms.begin(), partitioner)); 113 114 return returnlist; 115 }
Note:
See TracChangeset
for help on using the changeset viewer.
