1#A* -------------------------------------------------------------------
2#B* This file contains source code for the PyMOL computer program
3#C* Copyright (c) Schrodinger, LLC.
4#D* -------------------------------------------------------------------
5#E* It is unlawful to modify or remove this copyright notice.
6#F* -------------------------------------------------------------------
7#G* Please see the accompanying LICENSE file for further information.
8#H* -------------------------------------------------------------------
9#I* Additional authors of this source file include:
10#-*
11#-*
12#-*
13#Z* -------------------------------------------------------------------
14
15if True:
16
17    from . import selector
18    from .cmd import _cmd,lock,unlock,Shortcut,QuietException, \
19          DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error
20    cmd = __import__("sys").modules["pymol.cmd"]
21    import threading
22    import pymol
23    import string
24
25    def get_bond_print(obj,max_bond,max_type,_self=cmd):
26        r = DEFAULT_ERROR
27        try:
28            _self.lock(_self)
29            r = _cmd.get_bond_print(_self._COb,str(obj),int(max_bond),int(max_type))
30        finally:
31            _self.unlock(r,_self)
32        if _self._raising(r,_self): raise pymol.CmdException
33        return r
34
35    def spheroid(object="",average=0,_self=cmd):  # EXPERIMENTAL
36        '''
37DESCRIPTION
38
39    "spheroid" averages trajectory frames together to create
40    an ellipsoid-like approximation of the actual anisotropic
41    motion exhibited by the atom over a series of trajectory frames.
42
43USAGE
44
45    spheroid object,average
46
47    average = number of states to average for each resulting spheroid state
48
49    '''
50        print("Warning: 'spheroid' is experimental, incomplete, and unstable.")
51        with _self.lockcm:
52            r = _cmd.spheroid(_self._COb,str(object),int(average))
53        return r
54
55    def mem(_self=cmd):
56        '''
57DESCRIPTION
58
59    "mem" Dumps current memory state to standard output. This is a
60    debugging feature, not an official part of the API.
61
62    '''
63        r = DEFAULT_ERROR
64        try:
65            _self.lock(_self)
66            r = _cmd.mem(_self._COb)
67        finally:
68            _self.unlock(r,_self)
69        if _self._raising(r,_self): raise pymol.CmdException
70        return r
71
72
73    def check(selection=None, preserve=0):
74        '''
75DESCRIPTION
76
77    "check" is unsupported command that may eventually have something
78    to do with assigning forcefield parameters to a selection of
79    atoms.
80
81'''
82        # This function relies on code that is not currently part of PyMOL/ChemPy
83        # NOTE: the realtime module relies on code that is not yet part of PyMOL/ChemPy
84        from chempy.tinker import realtime
85        if selection is None:
86            arg = cmd.get_names("objects")
87            arg = arg[0:1]
88            if arg:
89                if len(arg):
90                    selection = arg
91        if selection is not None:
92            selection = selector.process(selection)
93            realtime.assign("("+selection+")",int(preserve))
94            realtime.setup("("+selection+")")
95
96    def fast_minimize(*args, **kwargs):
97        '''
98DESCRIPTION
99
100    "fast_minimize" is an unsupported nonfunctional command that may
101    eventually have something to do with doing a quick clean up of the
102    molecular structure.
103
104'''
105        kwargs['_setup'] = 0
106        return minimize(*args, **kwargs)
107
108    def minimize(sele='', iter=500, grad=0.01, interval=50, _setup=1, _self=cmd):
109        '''
110DESCRIPTION
111
112    "fast_minimize" is an unsupported nonfunctional command that may
113    eventually have something to do with minimization.
114
115'''
116        from chempy.tinker import realtime
117
118        if not sele:
119            names = _self.get_names("objects")
120            if not names:
121                return
122            sele = names[0]
123        sele = '(' + sele + ')'
124
125        if not int(_setup) or realtime.setup(sele):
126            _self.async_(realtime.mini, int(iter), float(grad), int(interval), sele)
127        else:
128            print(" minimize: missing parameters, can't continue")
129
130
131    def dump(fnam, obj, state=1, quiet=1, _self=cmd):
132        '''
133DESCRIPTION
134
135    The dump command writes the geometry of an isosurface, isomesh,
136    isodot, or map object to a simple text file. Each line contains one
137    vertex in case of representations, or one grid point in case of a map.
138
139    For surface objects, XYZ coordinates and the normal are exported.
140    Three lines make one triangle (like GL_TRIANGLES).
141
142    For mesh objects, XYZ coordinates are exported (no normals).
143    The vertices form line strips (like GL_LINE_STRIP), a blank
144    line starts a new strip.
145
146    For dot objects, XYZ coordinates are exported.
147
148    For map objects, XYZ coordinates and the value at the point are
149    exported. This forms a grid map.
150
151USAGE
152
153    dump filename, object, state=1, quiet=1
154
155ARGUMENTS
156
157    filename = str: file that will be written
158    object = str: object name
159
160EXAMPLE
161
162    fetch 1ubq, mymap, type=2fofc, async=0
163
164    dump gridmap.txt, mymap
165
166    isosurface mysurface, mymap
167    dump surfacegeometry.txt, mysurface
168
169    isomesh mymesh, mymap
170    dump meshgeometry.txt, mymesh
171
172    isodot mydot, mymap, quiet=1
173    dump dotgeometry.txt, mydot
174
175SEE ALSO
176
177    COLLADA export
178
179    '''
180        r = DEFAULT_ERROR
181        try:
182            _self.lock(_self)
183            r = _cmd.dump(_self._COb, str(fnam), obj, int(state) - 1, int(quiet))
184        finally:
185            _self.unlock(r,_self)
186        if _self._raising(r,_self): raise pymol.CmdException
187        return r
188
189
190    def dummy(*arg):
191        return None
192
193    def test(group=0,index=0,_self=cmd): # generic test routine for development
194        '''
195DESCRIPTION
196
197    "dump" is an unsupported internal command.
198
199    '''
200        r = DEFAULT_ERROR
201        try:
202            _self.lock(_self)
203            r=_cmd.test(_self._COb,int(group),int(index))
204        finally:
205            _self.unlock(r,_self)
206        if _self._raising(r,_self): raise pymol.CmdException
207        return r
208
209    def load_coords(model, oname, state=1): # UNSUPPORTED
210        '''
211        WARNING: buggy argument list, state get's decremented twice!
212        '''
213        return pymol.importing.load_coordset(model, oname, int(state)-1)
214
215    def focal_blur(aperture=2.0, samples=10, ray=0, filename='', quiet=1, _self=cmd):
216        '''
217DESCRIPTION
218
219    Creates fancy figures by introducing a focal blur to the image.
220    The object at the origin will be in focus.
221
222USAGE
223
224    focal_blur [ aperture [, samples [, ray [, filename ]]]]
225
226ARGUMENTS
227
228    aperture = float: aperture angle in degrees {default: 2.0}
229
230    samples = int: number of images for averaging {default: 10}
231
232    ray = 0/1: {default: 0}
233
234    filename = str: write image to file {default: temporary}
235
236AUTHORS
237
238    Jarl Underhaug, Jason Vertrees and Thomas Holder
239
240EXAMPLES
241
242    focal_blur 3.0, 50
243        '''
244        raise pymol.IncentiveOnlyException()
245
246    def callout(name, label, pos='', screen='auto', state=-1, color='front',
247            quiet=1, _self=cmd):
248        '''
249DESCRIPTION
250
251    Create a new screen-stabilized callout object.
252
253ARGUMENTS
254
255    name = str: object name
256
257    label = str: label text
258
259    pos = str or list: anchor in model space as 3-float coord list or atom
260    selection. If empty, don't draw an arrow. {default: }
261
262    screen = str or list: position on screen as 2-float list between [-1,-1]
263    (lower left) and [1,1] (upper right) or "auto" for smart placement.
264    {default: auto}
265        '''
266        raise pymol.IncentiveOnlyException()
267
268    def desaturate(selection="all", a=0.5, quiet=1, _self=cmd):
269        '''
270DESCRIPTION
271
272    Desaturate the colors in the given selection.
273
274ARGUMENTS
275
276    selection = str: atom selection {default: all}
277
278    a = float [0..1]: desaturation factor {default: 0.5}
279        '''
280        raise pymol.IncentiveOnlyException()
281