File: MolChemicalFeature.cpp

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (76 lines) | stat: -rw-r--r-- 3,227 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// $Id$
//
//  Copyright (C) 2004-2006 Rational Discovery LLC
//
//   @@ 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 NO_IMPORT_ARRAY
#include <RDBoost/python.h>

#include <RDGeneral/types.h>
#include <RDBoost/pyint_api.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/MolChemicalFeatures/MolChemicalFeature.h>
#include <GraphMol/MolChemicalFeatures/MolChemicalFeatureFactory.h>

namespace python = boost::python;

namespace RDKit {
PyObject *getFeatAtomIds(const MolChemicalFeature &feat) {
  const MolChemicalFeature::AtomPtrContainer &atoms = feat.getAtoms();
  PyObject *res = PyTuple_New(atoms.size());
  MolChemicalFeature::AtomPtrContainer_CI aci;
  int idx = 0;
  for (aci = atoms.begin(); aci != atoms.end(); ++aci) {
    PyTuple_SetItem(res, idx, PyInt_FromLong((*aci)->getIdx()));
    idx++;
  }
  return res;
}

std::string featClassDoc =
    "Class to represent a chemical feature.\n\
    These chemical features may or may not have been derived from molecule object;\n\
    i.e. it is possible to have a chemical feature that was created just from its type\n\
    and location.\n";
struct feat_wrapper {
  static void wrap() {
    python::class_<MolChemicalFeature, FeatSPtr>(
        "MolChemicalFeature", featClassDoc.c_str(), python::no_init)

        .def("GetId", &MolChemicalFeature::getId,
             "Returns the identifier of the feature\n")
        .def("GetFamily", &MolChemicalFeature::getFamily,
             "Get the family to which the feature belongs; donor, acceptor, "
             "etc.",
             python::return_value_policy<python::copy_const_reference>())
        .def("GetType", &MolChemicalFeature::getType,
             "Get the specific type for the feature",
             python::return_value_policy<python::copy_const_reference>())
        .def("GetPos",
             (RDGeom::Point3D(MolChemicalFeature::*)(int) const) &
                 MolChemicalFeature::getPos,
             (python::arg("self"), python::arg("confId") = -1),
             "Get the location of the chemical feature")
        .def("GetAtomIds", getFeatAtomIds,
             "Get the IDs of the atoms that participate in the feature")
        .def("GetMol", &MolChemicalFeature::getMol,
             "Get the molecule used to derive the features",
             python::return_value_policy<python::reference_existing_object>())
        .def("GetFactory", &MolChemicalFeature::getFactory,
             "Get the factory used to generate this feature",
             python::return_value_policy<python::reference_existing_object>())
        .def("ClearCache", &MolChemicalFeature::clearCache,
             "Clears the cache used to store position information.")
        .def("SetActiveConformer", &MolChemicalFeature::setActiveConformer,
             "Sets the conformer to use (must be associated with a molecule).")
        .def("GetActiveConformer", &MolChemicalFeature::getActiveConformer,
             "Gets the conformer to use.");
  };
};
}  // namespace RDKit
void wrap_MolChemicalFeat() { RDKit::feat_wrapper::wrap(); }