Ignore:
Timestamp:
Jan 24, 2024, 4:53:03 PM (21 months ago)
Author:
Frederik Heber <frederik.heber@…>
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)
Message:

Added python actions to generate all graph6 strings.

  • graph6 strings don't take permutations in the adjacency matrix into account. Hence, we are going through every permutation of non-hydrogens and generate the respective graph6 string.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Python/getGraph6String.cpp

    rd083cc r5a479d  
    3939#include "CodePatterns/Assert.hpp"
    4040#include "CodePatterns/Log.hpp"
     41#include <algorithm>
    4142#include <string>
    4243
     44#include "Element/element.hpp"
    4345#include "Graph/Graph6Writer.hpp"
    4446#include "World.hpp"
     
    6870  return output.str();
    6971}
     72
     73MoleCuilder::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
     95MoleCuilder::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.