We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cf8ac1d commit a69e7d3Copy full SHA for a69e7d3
simple_smarts.py
@@ -0,0 +1,28 @@
1
+#!/usr/bin/env python
2
+"""
3
+simple_smarts.py - simple example on how to use SMARTS patterns
4
+ via the Open Babel API
5
6
+import openbabel
7
+
8
+filename = '1UAO.pdb'
9
+pattern = "[$(CN)][$(C=O)]"
10
11
+# OpenBabel utilities
12
+obmol = openbabel.OBMol()
13
+obconv = openbabel.OBConversion()
14
+obpat = openbabel.OBSmartsPattern()
15
16
+# load the molecule
17
+obconv.SetInFormat(filename[-3:])
18
+obconv.ReadFile(obmol, filename)
19
20
+# initialize pattern matching
21
+obpat.Init(pattern)
22
23
+# apply pattern matching to the molecule
24
+obpat.Match(obmol)
25
26
+# avoid getting lots of <openbabel.vectorvInt; proxy ... > etc.
27
+matches = [m for m in obpat.GetUMapList()]
28
+print matches
0 commit comments