File: SubstanceGroup.i

package info (click to toggle)
rdkit 202503.1-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 220,160 kB
  • sloc: cpp: 399,240; python: 77,453; ansic: 25,517; java: 8,173; javascript: 4,005; sql: 2,389; yacc: 1,565; lex: 1,263; cs: 1,081; makefile: 578; xml: 229; fortran: 183; sh: 105
file content (92 lines) | stat: -rw-r--r-- 3,099 bytes parent folder | download | duplicates (2)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// Created by Gareth Jones on 9/2/2020.
//
// Copyright 2020 Schrodinger, Inc
//  @@ 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.



%{
#include <GraphMol/SubstanceGroup.h>

const RDKit::SubstanceGroup *getSubstanceGroupWithIdx(RDKit::ROMol &mol, unsigned int idx) {
  auto &groups = RDKit::getSubstanceGroups(mol);
  return &(groups[idx]);
}

unsigned int getSubstanceGroupCount(RDKit::ROMol &mol) {
    return RDKit::getSubstanceGroups(mol).size();
}
%}


// Base class RDProps is wrapped with shared_ptr, so SubstanceGroup must be too.
%shared_ptr(RDKit::SubstanceGroup)
%ignore getSubstanceGroups;

RDKit::SubstanceGroup *getSubstanceGroupWithIdx(RDKit::ROMol &mol, unsigned int idx);
unsigned int getSubstanceGroupCount(RDKit::ROMol &mol);

%ignore RDKit::SubstanceGroup::getAtoms;
%rename(getAtoms) RDKit::SubstanceGroup::getSgAtoms;
%ignore RDKit::SubstanceGroup::getBonds;
%rename(getBonds) RDKit::SubstanceGroup::getSgBonds;
%ignore RDKit::SubstanceGroup::getBrackets;
%ignore RDKit::SubstanceGroup::getCStates;
%ignore RDKit::SubstanceGroup::getAttachPoints;

%include <GraphMol/SubstanceGroup.h>

%extend RDKit::SubstanceGroup {
  // Wrap getAtoms, getParentAtoms and getBonds to return vector<int> by value (not reference).
  // int instead of unsigned int as vector<unsigned int> is not wrapped in C#
  // Not using references to avoid a free() error from Java
  const std::vector<int> getSgAtoms() {
    auto atoms = $self->getAtoms();
    std::vector<int> atomIdxs(atoms.begin(), atoms.end());
    return atomIdxs;
  }
  const std::vector<int> getSgBonds() {
    auto bonds = $self->getBonds();
    std::vector<int> bondIdxs(bonds.begin(), bonds.end());
    return bondIdxs;
  }
  const std::vector<int> getSgParentAtoms() {
    auto atoms = $self->getParentAtoms();
    std::vector<int> atomIdxs(atoms.begin(), atoms.end());
    return atomIdxs;
  }

  // SWIG does not do well wrapping vectors of objects, so provide accessors
  const RDKit::SubstanceGroup::Bracket *getBracket(unsigned int idx)  {
    auto &brackets = $self->getBrackets();
    return &(brackets[idx]);
  }
  const RDKit::SubstanceGroup::CState *getCState(unsigned int idx)  {
    auto &cstates = $self->getCStates();
    return &(cstates[idx]);
  }
  const RDKit::SubstanceGroup::AttachPoint *getAttachPoint(unsigned int idx)  {
    auto &attachPoints = $self->getAttachPoints();
    return &(attachPoints[idx]);
  }
  size_t getBracketCount() {
    return $self->getBrackets().size();
  }
  size_t getCStateCount() {
    return $self->getCStates().size();
  }
  size_t getAttachPointCount() {
    return $self->getAttachPoints().size();
  }
}

%template(getStringProp) RDKit::SubstanceGroup::getProp<std::string>;
%template(getUIntProp) RDKit::SubstanceGroup::getProp<unsigned int>;
%template(getStringVectProp) RDKit::SubstanceGroup::getProp<RDKit::STR_VECT>;
%template(getUIntVectProp) RDKit::SubstanceGroup::getProp<RDKit::UINT_VECT>;