File: __init__.py

package info (click to toggle)
pymol 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 74,084 kB
  • sloc: cpp: 482,660; python: 89,328; ansic: 29,512; javascript: 6,792; sh: 84; makefile: 25
file content (312 lines) | stat: -rw-r--r-- 9,411 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#A* -------------------------------------------------------------------
#B* This file contains source code for the PyMOL computer program
#C* copyright 1998-2000 by Warren Lyford Delano of DeLano Scientific.
#D* -------------------------------------------------------------------
#E* It is unlawful to modify or remove this copyright notice.
#F* -------------------------------------------------------------------
#G* Please see the accompanying LICENSE file for further information.
#H* -------------------------------------------------------------------
#I* Additional authors of this source file include:
#-*
#-*
#-*
#Z* -------------------------------------------------------------------

try:
    from . import _champ
except ImportError:
    print(" Error: unable to import architecture-dependent _champ module.")

# okay, this module is going to take some planning, since Champ
# has the potential to evolve into a full-blown
# chemical informatics system

# what do we need to be prepared to handle?
#
# - single structures
# - single patterns
# - lists of patterns
# - lists of compounds
# - dictionaries of compounds (key/value)
# - molecules in other class formats (chempy models, etc.)
# - subsets of protein structures
# - scripts which apply rules according to patterns
# - synchronized chempy models

# what does the architecture-dependent modules need to support?

# - Smiles/SMARTS/etc. conversion (bidirectional)
# - ChemPy model conversion (bidirectional)
# - modification recipe for extant chempy models?...

class Champ:

    def __init__(self):
        '''
        creates a new champ object, which contains
        a collect of comparable, searchable patterns 
        '''
        self._champ = _champ.new()

    def insert_pattern_string(self,pattern):
        '''
        adds a new pattern, and
        returns the index to this pattern
        '''
        (e,r) = _champ.insert_pattern_string(self._champ,str(pattern))
        if e: raise RuntimeError
        return r

    def pattern_free(self,index):
        '''
        frees a pattern
        '''
        (e,r) = _champ.pattern_free(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_clear_tags(self,index):
        '''
        resets a pattern\'s tags
        '''
        (e,r) = _champ.pattern_clear_tags(self._champ,int(index))
        if e: raise RuntimeError
        return r


    def pattern_get_string(self,index):
        '''
        retrieves the smiles string for a given pattern index
        '''
        (e,r) = _champ.pattern_get_string(self._champ,int(index),0)
        if e: raise RuntimeError
        return r

    def pattern_get_string_with_names(self,index):
        '''
        retrieves the smiles string for a given pattern index
        '''
        (e,r) = _champ.pattern_get_string(self._champ,int(index),1)
        if e: raise RuntimeError
        return r

    def insert_model(self,model):
        '''
        inserts the pattern from a ChemPy model pattern and returns the index
        '''
        (e,r) = _champ.insert_model(self._champ,model)
        if e: raise RuntimeError
        return r

    def list_prepend_pattern_strings(self,handle,pattern):
        '''
        adds pattern string to the top of a list
        '''
        (e,r) = _champ.list_prepend_pattern_strings(self._champ,int(handle),pattern)
        if e: raise RuntimeError
        return r

    def list_prepend_pattern_index(self,handle,index):
        '''
        adds pattern index to the top of a list
        '''
        (e,r) = _champ.list_prepend_pattern_index(self._champ,int(handle),int(index))
        if e: raise RuntimeError
        return r

    def list_new(self):
        '''
        returns a new list handle
        '''
        (e,r) = _champ.list_new(self._champ)
        if e: raise RuntimeError
        return r

    def list_free(self,handle,purge=1):
        '''
        destroys a list and associated patterns (if purge = 1)
        '''
        (e,r) = _champ.list_free(self._champ,int(handle),int(purge))
        if e: raise RuntimeError
        return r

    def list_get_pattern_indices(self,handle):
        '''
        returns pattern indices in a list as a list
        '''
        (e,r) = _champ.list_get_pattern_indices(self._champ,int(handle))
        if e: raise RuntimeError
        return r

    def list_get_pattern_strings(self,handle):
        '''
        returns list of smiles strings contained in a list
        '''
        (e,r) = _champ.list_get_pattern_strings(self._champ,int(handle))
        if e: raise RuntimeError
        return r

    def match_1v1_b(self,pattern,target): # boolean
        '''
        returns whether or not pattern can be found in target
        as a boolean result
        '''
        (e,r) = _champ.match_1v1_b(self._champ,
                                    int(pattern),int(target))
        if e: raise RuntimeError
        return r

    def match_1v1_n(self,pattern,target,limit,tag=0):
        '''
        returns tag list for single pattern on target
        '''
        (e,r) = _champ.match_1v1_n(self._champ,
                                    int(pattern),int(target),
                                            int(limit),int(tag))
        if e: raise RuntimeError
        return r

    def match_1v1_map(self,pattern,target,limit,tag=0): # boolean
        '''
        returns mappings (if any) between two patterns
        '''
        (e,r) = _champ.match_1v1_map(self._champ,
                                    int(pattern),int(target),int(limit),int(tag))
        if e: raise RuntimeError
        return r

    def match_Nv1_n(self,pattern,target,limit,tag):
        '''
        returns count of matches
        '''
        (e,r) = _champ.match_Nv1_n(self._champ,
                                    int(pattern),int(target),
                                            int(limit),int(tag))
        if e: raise RuntimeError
        return r


    def match_1vN_n(self,pattern,handle):
        '''
        returns count of how many times pattern occurs in list
        '''
        (e,r) = _champ.match_1vN_n(self._champ,
                                    int(pattern),int(handle))
        if e: raise RuntimeError
        return r

    def exact_1vN_n(self,pattern,handle):
        '''
        returns count of how many times exact compound occurs in list
        
        NOTE: should call generalize first as patterns are loaded...
                otherwise, equivalent aromatic bonds will be missed.
        '''
        (e,r) = _champ.exact_1vN_n(self._champ,
                                    int(pattern),int(handle))
        if e: raise RuntimeError
        return r

    def memory_dump(self):
        '''
        dump bulk memory information
        '''
        (e,r) = _champ.memory_dump(self._champ)
        if e: raise RuntimeError
        return r

    def pattern_get_cycle(self,index):
        '''
        debugging routine
        '''
        (e,r) = _champ.pattern_get_cycle(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_get_class(self,index):
        '''
        debugging routine
        '''
        (e,r) = _champ.pattern_get_class(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_get_codes(self,index):
        '''
        debugging routine
        '''
        (e,r) = _champ.pattern_get_codes(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_get_tag_masks(self,index):
        '''
        get tags as bit masks
        '''
        (e,r) = _champ.pattern_get_tag_masks(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_get_tags(self,index):
        '''
        get tags (numeric lists)
        '''
        (e,r) = _champ.pattern_get_tags(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_get_ext_indices_with_tags(self,index):
        '''
        get tags (numeric lists)
        '''
        (e,r) = _champ.pattern_get_ext_indices_with_tags(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_get_atom_symbols(self,index):
        '''
        debugging routine
        '''
        (e,r) = _champ.pattern_get_atom_symbols(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_get_atom_names(self,index):
        '''
        debugging routine
        '''
        (e,r) = _champ.pattern_get_atom_names(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_dump(self,index):
        '''
        debugging routine
        '''
        (e,r) = _champ.pattern_dump(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_orient_bonds(self,index):
        '''
        experimental
        '''
        (e,r) = _champ.pattern_orient_bonds(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_detect_chirality(self,index):
        '''
        experimental
        '''
        (e,r) = _champ.pattern_detect_chirality(self._champ,int(index))
        if e: raise RuntimeError
        return r

    def pattern_generalize(self,index):
        '''
        experimental
        '''
        (e,r) = _champ.pattern_generalize(self._champ,int(index))
        if e: raise RuntimeError
        return r