<commit_before>// $Id$
//
//  Copyright (C) 2013 <NAME>
//
//   @@ 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.
//

#define PY_ARRAY_UNIQUE_SYMBOL rdreducedgraphs_array_API
#include <boost/python.hpp>
#include <boost/python/numeric.hpp>
#include <numpy/arrayobject.h>

#include <RDBoost/Wrap.h>
#include <GraphMol/GraphMol.h>
#include <numpy/arrayobject.h>
#include <boost/foreach.hpp>

#include <GraphMol/ReducedGraphs/ReducedGraphs.h>
#include <Numerics/Vector.h>

#include <vector>

namespace python = boost::python;

namespace {
  RDKit::ROMol *GenerateMolExtendedReducedGraphHelper(const RDKit::ROMol &mol,
                                                      python::object atomTypes){
    if(atomTypes){
      throw_value_error("specification of atom types not yet supported");
    }
    RDKit::ROMol *res=RDKit::ReducedGraphs::generateMolExtendedReducedGraph(mol);
    return res;
  }
  PyObject *GenerateErGFingerprintForReducedGraphHelper(const RDKit::ROMol &mol,
                                                        python::object atomTypes,
                                                        double fuzzIncrement,
                                                        int minPath,
                                                        int maxPath){
    if(atomTypes){
      throw_value_error("specification of atom types not yet supported");
    }
    RDNumeric::DoubleVector *dv=RDKit::ReducedGraphs::generateErGFingerprintForReducedGraph(mol,0,fuzzIncrement,
                                                                                            minPath,maxPath);
    npy_intp dim=dv->size();
    PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1,&dim,NPY_DOUBLE);
    memcpy(static_cast<void *>(res->data),
           static_cast<void *>(dv->getData()),
           dv->size()*sizeof(double));
    delete dv;
    return PyArray_Return(res);
  }
  PyObject *GetErGFingerprintHelper(const RDKit::ROMol &mol,
                                         python::object atomTypes,
                                         double fuzzIncrement,
                                         int minPath,
                                         int maxPath){
    if(atomTypes){
      throw_value_error("specification of atom types not yet supported");
    }
    RDNumeric::DoubleVector *dv=RDKit::ReducedGraphs::getErGFingerprint(mol,0,fuzzIncrement,
                                                                        minPath,maxPath);
    npy_intp dim=dv->size();
    PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1,&dim,NPY_DOUBLE);
    memcpy(static_cast<void *>(res->data),
           static_cast<void *>(dv->getData()),
           dv->size()*sizeof(double));
    delete dv;
    return PyArray_Return(res);
  }


}

BOOST_PYTHON_MODULE(rdReducedGraphs) {
  python::scope().attr("__doc__") =
    "Module containing functions to generate and work with reduced graphs"
    ;

  import_array();
  python::register_exception_translator<IndexErrorException>(&translate_index_error);
  python::register_exception_translator<ValueErrorException>(&translate_value_error);

  std::string docString = "";

  docString="Returns the reduced graph for a molecule";
  python::def("GenerateMolExtendedReducedGraph", GenerateMolExtendedReducedGraphHelper,<commit_msg>fix a python3 build problem<commit_after>// $Id$
//
//  Copyright (C) 2013 <NAME>
//
//   @@ 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.
//

#define PY_ARRAY_UNIQUE_SYMBOL rdreducedgraphs_array_API
#include <boost/python.hpp>
#include <boost/python/numeric.hpp>
#include <numpy/arrayobject.h>

#include <RDBoost/Wrap.h>
#include <GraphMol/GraphMol.h>
#include <numpy/arrayobject.h>
#include <boost/foreach.hpp>
#include <RDBoost/import_array.h>

#include <GraphMol/ReducedGraphs/ReducedGraphs.h>
#include <Numerics/Vector.h>

#include <vector>

namespace python = boost::python;

namespace {
  RDKit::ROMol *GenerateMolExtendedReducedGraphHelper(const RDKit::ROMol &mol,
                                                      python::object atomTypes){
    if(atomTypes){
      throw_value_error("specification of atom types not yet supported");
    }
    RDKit::ROMol *res=RDKit::ReducedGraphs::generateMolExtendedReducedGraph(mol);
    return res;
  }
  PyObject *GenerateErGFingerprintForReducedGraphHelper(const RDKit::ROMol &mol,
                                                        python::object atomTypes,
                                                        double fuzzIncrement,
                                                        int minPath,
                                                        int maxPath){
    if(atomTypes){
      throw_value_error("specification of atom types not yet supported");
    }
    RDNumeric::DoubleVector *dv=RDKit::ReducedGraphs::generateErGFingerprintForReducedGraph(mol,0,fuzzIncrement,
                                                                                            minPath,maxPath);
    npy_intp dim=dv->size();
    PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1,&dim,NPY_DOUBLE);
    memcpy(static_cast<void *>(res->data),
           static_cast<void *>(dv->getData()),
           dv->size()*sizeof(double));
    delete dv;
    return PyArray_Return(res);
  }
  PyObject *GetErGFingerprintHelper(const RDKit::ROMol &mol,
                                         python::object atomTypes,
                                         double fuzzIncrement,
                                         int minPath,
                                         int maxPath){
    if(atomTypes){
      throw_value_error("specification of atom types not yet supported");
    }
    RDNumeric::DoubleVector *dv=RDKit::ReducedGraphs::getErGFingerprint(mol,0,fuzzIncrement,
                                                                        minPath,maxPath);
    npy_intp dim=dv->size();
    PyArrayObject *res = (PyArrayObject *)PyArray_SimpleNew(1,&dim,NPY_DOUBLE);
    memcpy(static_cast<void *>(res->data),
           static_cast<void *>(dv->getData()),
           dv->size()*sizeof(double));
    delete dv;
    return PyArray_Return(res);
  }


}

BOOST_PYTHON_MODULE(rdReducedGraphs) {
  python::scope().attr("__doc__") =
    "Module containing functions to generate and work with reduced graphs"
    ;

  rdkit_import_array();
  python::register_exception_translator<IndexErrorException>(&translate_index_error);
  python::register_exception_translator<ValueErrorException>(&translate_value_error);

  std::string docString = "";

  docString="Returns the reduced graph for a molecule";
  python::def("GenerateMolExtendedReducedGraph", GenerateMolExtendedReducedGraphHelper,
{'fraction_non_alphanumeric': 0.10209049255441008, 'fraction_numerical': 0.002434135166093929, 'mean_word_length': 2.253376804843968, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 50, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6434433', 'n_tokens_mistral': 1923, 'n_tokens_neox': 1867, 'n_words': 385}