<commit_before>// $Id$
//
//  Copyright (C) 2004-2006 Rational Discovery LLC
//
//   @@ All Rights Reserved  @@
//
#include <DistGeom/BoundsMatrix.h>
#include "rdDistGeom.h"

#include <GraphMol/GraphMol.h>
#include <RDBoost/Wrap.h>

#include <GraphMol/DistGeomHelpers/BoundsMatrixBuilder.h>
#include <GraphMol/DistGeomHelpers/Embedder.h>

namespace python = boost::python;

namespace RDKit {
  int EmbedMolecule(ROMol &mol, unsigned int maxAttempts=30,
                    int seed=-1, bool clearConfs=true,
                    bool randNegEig=true, unsigned int numZeroFail=1){
   
    int res = DGeomHelpers::EmbedMolecule(mol, maxAttempts, 
                                          seed, clearConfs, randNegEig,
                                          numZeroFail);
    return res;
  }

  INT_VECT EmbedMultipleConfs(ROMol &mol, unsigned int numConfs=10, unsigned int maxAttempts=30, 
                              int seed=-1, bool clearConfs=true, 
                              bool randNegEig=true, unsigned int numZeroFail=1, double pruneRmsThresh=-1.0) {
    INT_VECT res = DGeomHelpers::EmbedMultipleConfs(mol, numConfs, maxAttempts,
                                                    seed, clearConfs,
                                                    randNegEig, numZeroFail, 1e-3, 5.0, pruneRmsThresh);
    return res;
  } 

  PyObject *getMolBoundsMatrix(ROMol &mol, bool set15bounds=true,
                               bool scaleVDW=false) {
    int dims[2];
    unsigned int nats = mol.getNumAtoms();
    dims[0] = nats;
    dims[1] = nats;

    DistGeom::BoundsMatPtr mat(new DistGeom::BoundsMatrix(nats));
    DGeomHelpers::initBoundsMat(mat);
    DGeomHelpers::setTopolBounds(mol,mat, set15bounds, scaleVDW);
    PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE);
    memcpy(static_cast<void *>(res->data),
	   static_cast<void *>(mat->getData()),
	   nats*nats*sizeof(double));
	   
    return (PyObject *) res;
  }

}

BOOST_PYTHON_MODULE(rdDistGeom) {
  python::scope().attr("__doc__") =
    "Module containing functions to compute starting atomic coordinates in 3D using distance geometry"
    ;

  import_array();

  //RegisterListConverter<RDKit::Atom*>();

  std::string docString = "Use distance geometry to obtain intial coordinates for a molecule\n\n\
 \n\
 ARGUMENTS:\n\n\
    - mol : the molecule of interest\n\
    - maxAttempts : the maximum number of attempts to try embedding \n\
    - randomSeed : provide a seed for the random number generator so that the same coordinates can be obtained \n\
                   for a molecule on multiple runs. The default (-1) produces a random embedding\n\
    - clearConfs : clear all existing conformations on the molecule\n\
    - randNegEig : If the embedding yields a negative eigen value, pick coordinates that correspond \n\
                   to this component at random \n\
    - numZeroFail : fail embedding is we have this more zero eigen values \n\
                  \n\
 RETURNS:\n\n\
    ID of the new conformation added to the molecule \n\
\n";
  python::def("EmbedMolecule", RDKit::EmbedMolecule,
              (python::arg("mol"), python::arg("maxAttempts")=30,
               python::arg("randomSeed")=-1, python::arg("clearConfs")=true,
               python::arg("randNegEig")=true, python::arg("numZeroFail")=1),
              docString.c_str());

  docString = "Use distance geometry to obtain intial coordinates for a molecule\n\n\
 \n\
 ARGUMENTS:\n\n\
    - mol : the molecule of interest\n\
    - numConfs : the number of conformers to generate \n\
    - maxAttempts : the maximum number of attempts to try embedding \n\
    - randomSeed : provide a seed for the random number generator so that the same coordinates can be obtained \n\
                   for a molecule on multiple runs. The default (-1) produces a random embedding\n\
    - clearConfs : clear all existing conformations on the molecule\n\
    - randNegEig : If the embedding yields a negative eigen value, pick coordinates that correspond \n\
                   to this component at random \n\
    - numZeroFail : fail embedding is we have this more zero eigen values \n\
    - pruneRmsThresh : Retain only the conformations out of 'numConfs' after embedding that are atleast 
                       this far apart from each other. RMSD is computed on the heavy atoms.
                       Prunining is greedy; i.e. the first embedded conformation is retained and fro
		       then on only those that are atleast pruneRmsThresh away from already 
		       retained conformations are kept. The pruning is done after embedding and 
		       bounds violation minimization. No pruning by default.
                  \n\
 RETURNS:\n\n\
    List of new conformation IDs \n\
\n";
  python::def("EmbedMultipleConfs", RDKit::EmbedMultipleConfs,<commit_msg>add backslashes to extended doc strings<commit_after>// $Id$
//
//  Copyright (C) 2004-2006 Rational Discovery LLC
//
//   @@ All Rights Reserved  @@
//
#include <DistGeom/BoundsMatrix.h>
#include "rdDistGeom.h"

#include <GraphMol/GraphMol.h>
#include <RDBoost/Wrap.h>

#include <GraphMol/DistGeomHelpers/BoundsMatrixBuilder.h>
#include <GraphMol/DistGeomHelpers/Embedder.h>

namespace python = boost::python;

namespace RDKit {
  int EmbedMolecule(ROMol &mol, unsigned int maxAttempts=30,
                    int seed=-1, bool clearConfs=true,
                    bool randNegEig=true, unsigned int numZeroFail=1){
   
    int res = DGeomHelpers::EmbedMolecule(mol, maxAttempts, 
                                          seed, clearConfs, randNegEig,
                                          numZeroFail);
    return res;
  }

  INT_VECT EmbedMultipleConfs(ROMol &mol, unsigned int numConfs=10, unsigned int maxAttempts=30, 
                              int seed=-1, bool clearConfs=true, 
                              bool randNegEig=true, unsigned int numZeroFail=1, double pruneRmsThresh=-1.0) {
    INT_VECT res = DGeomHelpers::EmbedMultipleConfs(mol, numConfs, maxAttempts,
                                                    seed, clearConfs,
                                                    randNegEig, numZeroFail, 1e-3, 5.0, pruneRmsThresh);
    return res;
  } 

  PyObject *getMolBoundsMatrix(ROMol &mol, bool set15bounds=true,
                               bool scaleVDW=false) {
    int dims[2];
    unsigned int nats = mol.getNumAtoms();
    dims[0] = nats;
    dims[1] = nats;

    DistGeom::BoundsMatPtr mat(new DistGeom::BoundsMatrix(nats));
    DGeomHelpers::initBoundsMat(mat);
    DGeomHelpers::setTopolBounds(mol,mat, set15bounds, scaleVDW);
    PyArrayObject *res = (PyArrayObject *)PyArray_FromDims(2,dims,PyArray_DOUBLE);
    memcpy(static_cast<void *>(res->data),
	   static_cast<void *>(mat->getData()),
	   nats*nats*sizeof(double));
	   
    return (PyObject *) res;
  }

}

BOOST_PYTHON_MODULE(rdDistGeom) {
  python::scope().attr("__doc__") =
    "Module containing functions to compute starting atomic coordinates in 3D using distance geometry"
    ;

  import_array();

  //RegisterListConverter<RDKit::Atom*>();

  std::string docString = "Use distance geometry to obtain intial coordinates for a molecule\n\n\
 \n\
 ARGUMENTS:\n\n\
    - mol : the molecule of interest\n\
    - maxAttempts : the maximum number of attempts to try embedding \n\
    - randomSeed : provide a seed for the random number generator so that the same coordinates can be obtained \n\
                   for a molecule on multiple runs. The default (-1) produces a random embedding\n\
    - clearConfs : clear all existing conformations on the molecule\n\
    - randNegEig : If the embedding yields a negative eigen value, pick coordinates that correspond \n\
                   to this component at random \n\
    - numZeroFail : fail embedding is we have this more zero eigen values \n\
                  \n\
 RETURNS:\n\n\
    ID of the new conformation added to the molecule \n\
\n";
  python::def("EmbedMolecule", RDKit::EmbedMolecule,
              (python::arg("mol"), python::arg("maxAttempts")=30,
               python::arg("randomSeed")=-1, python::arg("clearConfs")=true,
               python::arg("randNegEig")=true, python::arg("numZeroFail")=1),
              docString.c_str());

  docString = "Use distance geometry to obtain intial coordinates for a molecule\n\n\
 \n\
 ARGUMENTS:\n\n\
    - mol : the molecule of interest\n\
    - numConfs : the number of conformers to generate \n\
    - maxAttempts : the maximum number of attempts to try embedding \n\
    - randomSeed : provide a seed for the random number generator so that the same coordinates can be obtained \n\
                   for a molecule on multiple runs. The default (-1) produces a random embedding\n\
    - clearConfs : clear all existing conformations on the molecule\n\
    - randNegEig : If the embedding yields a negative eigen value, pick coordinates that correspond \n\
                   to this component at random \n\
    - numZeroFail : fail embedding is we have this more zero eigen values \n\
    - pruneRmsThresh : Retain only the conformations out of 'numConfs' after embedding that are atleast \
                       this far apart from each other. RMSD is computed on the heavy atoms. \
                       Prunining is greedy; i.e. the first embedded conformation is retained and from \
		       then on only those that are atleast pruneRmsThresh away from already  \
		       retained conformations are kept. The pruning is done after embedding and  \
		       bounds violation minimization. No pruning by default. \
                  \n\
 RETURNS:\n\n\
    List of new conformation IDs \n\
\n";
  python::def("EmbedMultipleConfs", RDKit::EmbedMultipleConfs,
{'fraction_non_alphanumeric': 0.09221606079277059, 'fraction_numerical': 0.008009858287122612, 'mean_word_length': 2.4695404346277163, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3826661', 'n_tokens_mistral': 2939, 'n_tokens_neox': 2769, 'n_words': 898}