Repository navigation
Expand file tree
/
Copy pathquerying.py
More file actions
1626 lines (1258 loc) · 47.2 KB
/
Copy pathquerying.py
File metadata and controls
1626 lines (1258 loc) · 47.2 KB
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#A* -------------------------------------------------------------------
#B* This file contains source code for the PyMOL computer program
#C* Copyright (c) Schrodinger, LLC.
#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* -------------------------------------------------------------------
from .constants import CURRENT_STATE, ALL_STATES
if True:
import time
from . import selector
import pymol
cmd = __import__("sys").modules["pymol.cmd"]
from .cmd import _cmd,lock,unlock, \
_feedback,fb_module,fb_mask,is_list, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error
def auto_measure(*, _self=cmd):
lst = _self.get_names("selections")
if "pk1" in lst:
if "pk2" in lst:
if "pk3" in lst:
if "pk4" in lst:
_self.dihedral()
else:
_self.angle()
else:
_self.distance()
_self.unpick()
def get_volume_field(objName, state=1, copy=1, *, _self=cmd):
'''
DESCRIPTION
EXPERIMENTAL AND SUBJECT TO CHANGE - DO NOT USE
API only. Get the raw data of a map or volume object.
ARGUMENTS
objName = str: object name
state = int: state index {default: 1}
copy = 0/1: {default: 1} WARNING: only use copy=0 if you know what you're
doing. copy=0 will return a numpy array which is a wrapper of the internal
memory. If the internal memory gets freed or reallocated, this wrapper
will become invalid.
'''
with _self.lockcm:
r = _self._cmd.get_volume_field(_self._COb, objName, int(state) - 1, int(copy))
return r
def get_volume_histogram(objName, bins=64, range=None, *, _self=cmd):
'''
DESCRIPTION
API ONLY. Get min, max, mean, stdev and histogram of a map or volume
object as a list of length bins + 4.
'''
with _self.lockcm:
r = _self._cmd.get_volume_histogram(_self._COb,objName,
int(bins), range or (0., 0.))
return r
def get_unused_name(prefix="tmp", alwaysnumber=1, *, _self=cmd):
with _self.lockcm:
r = _cmd.get_unused_name(_self._COb, prefix, alwaysnumber)
return r
def get_modal_draw(*, _self=cmd, quiet=1):
with _self.lockcm:
r = _cmd.get_modal_draw(_self._COb)
return r
def get_drag_object_name(*, _self=cmd):
with _self.lockcm:
r = _cmd.get_drag_object_name(_self._COb)
return r
def get_object_matrix(object,state=1, incl_ttt=1, *, _self=cmd):
'''
DESCRIPTION
"get_object_matrix" is an unsupported command that may have
something to do with querying the transformation matrices
associated with an object
'''
object = str(object)
with _self.lockcm:
r = _cmd.get_object_matrix(_self._COb,str(object), int(state)-1, int(incl_ttt))
return r
def get_object_ttt(object, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_object_ttt" is an unsupported command
'''
quiet = int(quiet)
with _self.lockcm:
r = _cmd.get_object_ttt(_self._COb, str(object), -1, quiet)
if not quiet:
if r is None:
print('TTT is None')
else:
for i in range(4):
if i == 3:
print('TTT ---------------------------+---------')
print('TTT %8.2f %8.2f %8.2f | %8.2f' % tuple(r[i * 4:i * 4 + 4]))
return r
def get_object_settings(object, state=ALL_STATES, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_object_settings" is an unsupported command
'''
with _self.lockcm:
r = _cmd.get_object_settings(_self._COb, str(object), int(state) - 1)
return r
def get_object_list(selection="(all)", quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_object_list" is an unsupported command that may have
something to do with querying the objects covered by a selection.
'''
selection = selector.process(selection)
with _self.lockcm:
r = _cmd.get_object_list(_self._COb,str(selection))
if not quiet:
if(is_list(r)):
print(" get_object_list: ",str(r))
return r
def get_symmetry(selection="(all)", state=CURRENT_STATE, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_symmetry" can be used to obtain the crystal
and spacegroup parameters for a molecule or map.
USAGE
get_symmetry object-name-or-selection
PYMOL API
cmd.get_symmetry(string selection, int state, int quiet)
'''
selection = selector.process(selection)
with _self.lockcm:
r = _cmd.get_symmetry(_self._COb,str(selection),int(state) - 1)
if not quiet:
if r:
print(" get_symmetry: A = %7.3f B = %7.3f C = %7.3f"%tuple(r[0:3]))
print(" get_symmetry: Alpha = %7.3f Beta = %7.3f Gamma = %7.3f"%tuple(r[3:6]))
print(" get_symmetry: SpaceGroup = %s"%r[6])
else:
print(" get_symmetry: No symmetry defined.")
return r
def get_title(object, state, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_title" retrieves a text string to the state of a particular
object which will be displayed when the state is active.
USAGE
set_title object, state
PYMOL API
cmd.set_title(string object, int state, string text)
'''
with _self.lockcm:
r = _cmd.get_title(_self._COb,str(object),int(state)-1)
if not quiet:
if r is not None:
print(" get_title: %s"%r)
return r
def angle(name=None, selection1="(pk1)", selection2="(pk2)",
selection3="(pk3)", mode=None, label=1, reset=0,
zoom=0, state=ALL_STATES, quiet=1, *,
state1=-3, state2=-3, state3=-3, _self=cmd):
'''
DESCRIPTION
"angle" shows the angle formed between any three atoms.
USAGE
angle [ name [, selection1 [, selection2 [, selection3 ]]]]
NOTES
"angle" alone will show the angle angle formed by selections (pk1),
(pk2), (pk3) which can be set using the "PkAt" mouse action
(typically, Ctrl-middle-click)
PYMOL API
cmd.angle(string name, string selection1, string selection2,
string selection3)
SEE ALSO
distance, dihedral
'''
r = DEFAULT_SUCCESS
if selection1=="(pk1)":
if "pk1" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk1' selection is undefined.")
r = DEFAULT_ERROR
if selection2=="(pk2)":
if "pk2" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk2' selection is undefined.")
r = DEFAULT_ERROR
if selection3=="(pk3)":
if "pk3" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk3' selection is undefined.")
r = DEFAULT_ERROR
if is_ok(r):
r = DEFAULT_ERROR
# if unlabeled, then get next name in series
if name is not None:
nam=name
else:
try:
_self.lock(_self)
cnt = _self.get_setting_int("dist_counter") + 1
r = _self.set("dist_counter", cnt)
nam = "angle%02.0f" % cnt
finally:
_self.unlock(r,_self)
# defaults
if mode is None:
mode = 0
# preprocess selections
selection1 = selector.process(selection1)
selection2 = selector.process(selection2)
selection3 = selector.process(selection3)
# now do the deed
try:
_self.lock(_self)
if selection2!="same":
selection2 = "("+selection2+")"
if selection3!="same":
selection3 = "("+selection3+")"
r = _cmd.angle(_self._COb,str(nam),"("+str(selection1)+")",
str(selection2),
str(selection3),
int(mode),int(label),int(reset),
int(zoom),int(quiet),int(state)-1,
int(state1)-1, int(state2)-1, int(state3)-1)
finally:
_self.unlock(r,_self)
if _raising(r,_self): raise pymol.CmdException
return r
def dihedral(name=None, selection1="(pk1)", selection2="(pk2)",
selection3="(pk3)", selection4="(pk4)", mode=None,
label=1, reset=0, zoom=0, state=ALL_STATES, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"dihedral" shows dihedral angles formed between any four atoms.
USAGE
dihedral [ name [, selection1 [, selection2 [, selection3 [, selection4 ]]]]]
NOTES
"dihedral" alone will show the dihedral angle formed by selections
(pk1), (pk2), (pk3), and (pk4), which can be set using the "PkAt"
mouse action (typically, Ctrl-middle-click)
PYMOL API
cmd.dihedral(string name, string selection1, string selection2,
string selection3, string selection4)
SEE ALSO
distance, angle
'''
r = DEFAULT_SUCCESS
if selection1=="(pk1)":
if "pk1" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk1' selection is undefined.")
r = DEFAULT_ERROR
if selection2=="(pk2)":
if "pk2" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk2' selection is undefined.")
r = DEFAULT_ERROR
if selection3=="(pk3)":
if "pk3" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk3' selection is undefined.")
r = DEFAULT_ERROR
if selection3=="(pk4)":
if "pk4" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk4' selection is undefined.")
r = DEFAULT_ERROR
if is_ok(r):
r = DEFAULT_ERROR
# if unlabeled, then get next name in series
if name is not None:
nam=name
else:
try:
_self.lock(_self)
cnt = _self.get_setting_int("dist_counter") + 1
r = _self.set("dist_counter", cnt)
nam = "dihedral%02.0f" % cnt
finally:
_self.unlock(r,_self)
# defaults
if mode is None:
mode = 0
# preprocess selections
selection1 = selector.process(selection1)
selection2 = selector.process(selection2)
selection3 = selector.process(selection3)
selection4 = selector.process(selection4)
# now do the deed
try:
_self.lock(_self)
if selection2!="same":
selection2 = "("+selection2+")"
if selection3!="same":
selection3 = "("+selection3+")"
if selection4!="same":
selection4 = "("+selection4+")"
r = _cmd.dihedral(_self._COb,str(nam),"("+str(selection1)+")",
str(selection2),
str(selection3),
str(selection4),
int(mode),int(label),
int(reset),int(zoom),
int(quiet),int(state)-1)
finally:
_self.unlock(r,_self)
if _raising(r,_self): raise pymol.CmdException
return r
def distance(name=None, selection1="(pk1)", selection2="(pk2)",
cutoff=None, mode=None, zoom=0, width=None, length=None,
gap=None, label=1, quiet=1, reset=0, state=ALL_STATES,
state1=-3, state2=-3, *, _self=cmd):
'''
DESCRIPTION
"distance" creates a new distance object between two selections.
USAGE
distance [name [, selection1 [, selection2 [, cutoff [, mode ]]]]]
ARGUMENTS
name = string: name of the distance object to create
selection1 = string: first atom selection
selection2 = string: second atom selection
cutoff = float: longest distance to show
mode = 0: all interatomic distances
mode = 1: only bond distances
mode = 2: only show polar contact distances
mode = 3: like mode=0, but use distance_exclusion setting
mode = 4: distance between centroids (does not support
dynamic_measures; new in PyMOL 1.8.2)
mode = 5: pi-pi and pi-cation interactions
mode = 6: pi-pi interactions
mode = 7: pi-cation interactions
mode = 8: like mode=3, but cutoff is the ratio between
distance and sum of VDW radii
state = int: object state to create the measurement object in
and to get coordinates from {default: 0 (all states)}
state1, state2 = int: overrule 'state' argument to measure distances
between different states {default: use state}
EXAMPLES
distance mydist, 14/CA, 29/CA
distance hbonds, all, all, 3.2, mode=2
NOTES
The distance wizard makes measuring distances easier than using
the "dist" command for real-time operations.
"dist" alone will show distances between selections (pk1) and (pk1),
which can be set using the PkAt mouse action (usually CTRL-middle-click).
PYMOL API
cmd.distance(string name, string selection1, string selection2,
string cutoff, string mode )
'''
# handle unnamed distance
r = DEFAULT_SUCCESS
if name is not None:
if len(name):
if name[0]=='(' or ' ' in name or '/' in name: # we're one argument off...
if cutoff is not None:
mode = cutoff
if selection2!="(pk2)":
cutoff = selection2
if selection1!="(pk1)":
selection2 = selection1
selection1=name
name = None
if selection1=="(pk1)":
if "pk1" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk1' selection is undefined.")
r = DEFAULT_ERROR
if selection2=="(pk2)":
if "pk2" not in _self.get_names('selections'):
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: The 'pk2' selection is undefined.")
r = DEFAULT_ERROR
if is_ok(r):
r = DEFAULT_ERROR
# if unlabeled, then get next name in series
if name is not None:
nam=name
else:
try:
_self.lock(_self)
cnt = _self.get_setting_int("dist_counter") + 1
r = _self.set("dist_counter", cnt)
nam = "dist%02.0f" % cnt
finally:
_self.unlock(r,_self)
# defaults
if mode is None:
mode = 0
if cutoff is None:
cutoff = -1.0
# preprocess selections
selection1 = selector.process(selection1)
selection2 = selector.process(selection2)
# now do the deed
try:
_self.lock(_self)
if selection2!="same":
selection2 = "("+selection2+")"
r = _cmd.dist(_self._COb,str(nam),"("+str(selection1)+")",
str(selection2),int(mode),float(cutoff),
int(label),int(quiet),int(reset),
int(state)-1,int(zoom),
int(state1)-1, int(state2)-1)
if width is not None:
_self.set("dash_width",width,nam)
if length is not None:
_self.set("dash_length",length,nam)
if gap is not None:
_self.set("dash_gap",gap,nam)
finally:
_self.unlock(r,_self)
if (r<0.0) and (not quiet):
# a negative value is an warning signal from PyMOL...
r = DEFAULT_ERROR
if _raising(r,_self): raise pymol.CmdException
return r
# LEGACY support for cmd.dist
dist = distance
def pi_interactions(name="",
selection1="all",
selection2="same",
state=ALL_STATES,
state1=-3,
state2=-3,
quiet=1,
reset=0,
*, _self=cmd):
'''
DESCRIPTION
Find pi-pi and pi-cation interactions.
Identical to cmd.distance(..., mode=5, label=0)
SEE ALSO
distance
'''
raise pymol.IncentiveOnlyException()
def get_povray(*, _self=cmd):
'''
DESCRIPTION
"get_povray" returns a tuple corresponding to strings for a PovRay
input file.
PYMOL API
cmd.get_povray()
'''
with _self.lockcm:
r = _cmd.get_povray(_self._COb)
return r
def get_idtf(quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_idft" is under development, but should eventually return an
idtf file containing multiple objects and scenes.
PYMOL API
cmd.idtf()
'''
with _self.lockcm:
r = _cmd.get_idtf(_self._COb)
if not quiet:
fov = _self.get_setting_float("field_of_view")
dist = _self.get_view()[11]
print(" 3Daac=%3.1f, 3Droll=0, 3Dc2c=0 0 1, 3Droo=%1.2f, 3Dcoo=0 0 %1.2f" % (fov, -dist, dist))
return r
def get_mtl_obj(*, _self=cmd):
'''
DESCRIPTION
NOTE: this is an incomplete and unsupported feature.
"get_mtl_obj" returns a tuple containing mtl and obj input files
for use with Maya.
PYMOL API
cmd.get_obj_mtl()
'''
with _self.lockcm:
r = _cmd.get_mtl_obj(_self._COb)
return r
def get_version(quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_version" returns a tuple of length six containing text,
floating point, and integer representations of the current PyMOL
version number, build date as unix timestamp, GIT SHA and SVN
code revision so far available.
PYMOL API
cmd.get_version(int quiet)
'''
# get_version doesn't need the _COb and doesn't require a lock
r = _cmd.get_version()
if True:
quiet = int(quiet)
if quiet < 1 and _feedback(fb_module.cmd, fb_mask.results, _self):
import re
p = pymol.get_version_message(r)
print(re.sub(r'^', ' ', p, re.M))
if quiet < 0:
if r[3]:
print(' build date:', time.strftime('%c %Z', time.localtime(r[3])))
if r[4]:
print(' git sha:', r[4])
return r
def get_vrml(version=2, *, _self=cmd):
'''
DESCRIPTION
"get_vrml" returns a VRML2 string representing the content
currently displayed.
PYMOL API
cmd.get_vrml()
'''
with _self.lockcm:
r = _cmd.get_vrml(_self._COb,int(version))
return r
def get_collada(version=2, *, _self=cmd):
'''
DESCRIPTION
"get_collada" returns a COLLADA string representing the content
currently displayed.
PYMOL API
cmd.get_collada()
'''
with _self.lockcm:
r = _cmd.get_collada(_self._COb,int(version))
return r
def get_gltf(filename, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_gltf" saves a gltf file representing the content
currently displayed.
PYMOL API
cmd.get_gltf()
'''
import shutil
exe = shutil.which('collada2gltf') or shutil.which('COLLADA2GLTF-bin')
if exe is None:
raise pymol.CmdException('could not find collada2gltf')
# https://github.com/schrodinger/pymol-open-source/issues/107
_self.set('collada_geometry_mode', 1, quiet=quiet)
r = _self.get_collada()
# write collada file
with open(filename, 'w') as handle:
handle.write(r)
import subprocess
result = subprocess.call([exe, '-i', filename, '-o', filename])
# convert collada file to gltf by using collada2gltf binary
if not quiet:
if result == 0:
print(' Save: wrote "' + filename + '".')
else:
print(' Save-Error: no file written')
return result
def count_states(selection="(all)", quiet=1, *, _self=cmd):
'''
DESCRIPTION
"count_states" returns the number of states in the selection.
USAGE
count_states
PYMOL API
cmd.count_states(string selection)
SEE ALSO
frame
'''
# preprocess selection
selection = selector.process(selection)
#
with _self.lockcm:
r = _cmd.count_states(_self._COb,selection)
if not quiet:
print(" cmd.count_states: %d states."%r)
return r
def get_movie_length(quiet=1, images=-1, *, _self=cmd):
'''
DESCRIPTION
"get_movie_length" returns the number of frames explicitly defined
in the movie, not including molecular states.
PYMOL API
cmd.count_frames()
SEE ALSO
frame, count_states, count_frames
'''
with _self.lockcm:
r = _cmd.get_movie_length(_self._COb)
if r<0:
if images==0:
r = 0
elif images<0:
r = -r
if images == 1:
if r>0:
r = 0
if r>=0 and not quiet:
print(" cmd.get_movie_length: %d frames"%r)
return r
def count_frames(quiet=1, *, _self=cmd):
'''
DESCRIPTION
"count_frames" returns the number of frames defined for the PyMOL
movie.
USAGE
count_frames
PYMOL API
cmd.count_frames()
SEE ALSO
frame, count_states
'''
with _self.lockcm:
r = _cmd.count_frames(_self._COb)
if not quiet: print(" cmd.count_frames: %d frames"%r)
return r
def overlap(selection1, selection2, state1=1, state2=1, adjust=0.0, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"overlap" is an unsupported command that sums up
[(VDWi + VDWj) - distance_ij]/2 between pairs of
selected atoms.
PYMOL API
cmd.overlap(string selection1, string selection2 [, int state1=1, int state2=1, float adjust=0.0])
NOTES
It does not compute the volume overlap,
selections with more atoms will have a larger
sum.
'''
# preprocess selections
selection1 = selector.process(selection1)
selection2 = selector.process(selection2)
#
with _self.lockcm:
r = _cmd.overlap(_self._COb,str(selection1),str(selection2),
int(state1)-1,int(state2)-1,
float(adjust))
if not quiet: print(" cmd.overlap: %5.3f Angstroms."%r)
return r
def get_movie_locked(*, _self=cmd):
with _self.lockcm:
r = _cmd.get_movie_locked(_self._COb)
return r
def get_object_color_index(name, *, _self=cmd):
name = str(name)
with _self.lockcm:
r = _cmd.get_object_color_index(_self._COb,name)
return r
def get_color_tuple(name, mode=0, *, _self=cmd):
'''Get the RGB color tuple for a color (range 0.0 to 1.0)
:param name: color name or index
:param mode: don't use (mode 4 returns negative R for special colors)
'''
name=str(name)
mod = int(mode)
if mode in (1, 2):
print(' Warning: use get_color_indices instead of get_color_tuple(mode={})'.format(mode))
elif mode == 3:
print(' Warning: use get_color_index instead of get_color_tuple(mode=3)')
with _self.lockcm:
r = _cmd.get_color(_self._COb,name,mode)
if r is None:
if _feedback(fb_module.cmd,fb_mask.errors,_self):
print("cmd-Error: Unknown color '%s'."%name)
return r
def get_color_indices(all=0, *, _self=cmd):
with _self.lockcm:
if all:
r = _cmd.get_color(_self._COb,'',2)
else:
r = _cmd.get_color(_self._COb,'',1)
return r
def get_color_index_from_string_or_list(color, *, _self=cmd):
if isinstance(color, str) and color[:1] in '[(':
color = _self.safe_list_eval(color)
if isinstance(color, (list, tuple)):
color = '0x%02x%02x%02x' % tuple(int(v * 255) for v in color)
return get_color_index(color, _self=_self)
def get_color_index(color,*, _self=cmd):
with _self.lockcm:
r = _cmd.get_color(_self._COb,str(color),3)
return r
def get_renderer(quiet=1, *, _self=cmd):
'''
DESCRIPTION
Prints OpenGL renderer information.
'''
with _self.lockcm:
r = _cmd.get_renderer(_self._COb)
if not int(quiet):
print(" OpenGL graphics engine:")
print(" GL_VENDOR: ", r[0])
print(" GL_RENDERER: ", r[1])
print(" GL_VERSION: ", r[2])
return r
def get_phipsi(selection="(name CA)", state=CURRENT_STATE, *, _self=cmd):
# preprocess selections
selection = selector.process(selection)
#
with _self.lockcm:
r = _cmd.get_phipsi(_self._COb,"("+str(selection)+")",int(state)-1)
return r
def get_atom_coords(selection, state=ALL_STATES, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_atom_coords" returns the 3D coordinates of a single atom.
'''
# low performance way to get coords for a single atom
selection = selector.process(selection)
with _self.lockcm:
r = _cmd.get_atom_coords(_self._COb,str(selection),int(state)-1,int(quiet))
if not quiet:
for a in r:
print(" cmd.get_atom_coords: [%8.3f,%8.3f,%8.3f]"%(a))
return r
def get_coords(selection='all', state=1, quiet=1, *, _self=cmd):
'''
DESCRIPTION
API only. Get selection coordinates as numpy array.
ARGUMENTS
selection = str: atom selection {default: all}
state = int: state index or all states if state=0 {default: 1}
'''
selection = selector.process(selection)
with _self.lockcm:
r = _cmd.get_coords(_self._COb, selection, int(state) - 1)
return r
def get_coordset(name, state=1, copy=1, quiet=1, *, _self=cmd):
'''
DESCRIPTION
API only. Get object coordinates as numpy array.
ARGUMENTS
selection = str: atom selection {default: all}
state = int: state index {default: 1}
copy = 0/1: {default: 1} WARNING: only use copy=0 if you know what you're
doing. copy=0 will return a numpy array which is a wrapper of the internal
coordinate set memory. If the internal memory gets freed or reallocated,
this wrapper will become invalid.
'''
with _self.lockcm:
r = _cmd.get_coordset(_self._COb, name, int(state) - 1, int(copy))
return r
def get_position(quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_position" returns the 3D coordinates of the center of the
viewer window.
'''
with _self.lockcm:
r = _cmd.get_position(_self._COb)
if not quiet:
print(" cmd.get_position: [%8.3f,%8.3f,%8.3f]"%(r[0],r[1],r[2]))
return r
def get_distance(atom1="pk1", atom2="pk2", state=CURRENT_STATE, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_distance" returns the distance between two atoms. By default, the
coordinates used are from the current state, however an alternate
state identifier can be provided.
USAGE
get_distance atom1, atom2, [,state ]
EXAMPLES
get_distance 4/n,4/c
get_distance 4/n,4/c,state=4
PYMOL API
cmd.get_distance(atom1="pk1",atom2="pk2",state=-1)
'''
# preprocess selections
atom1 = selector.process(atom1)
atom2 = selector.process(atom2)
#
with _self.lockcm:
r = _cmd.get_distance(_self._COb,str(atom1),str(atom2),int(state)-1)
if not quiet:
print(" cmd.get_distance: %5.3f Angstroms."%r)
return r
def get_angle(atom1="pk1", atom2="pk2", atom3="pk3", state=CURRENT_STATE, quiet=1, *, _self=cmd):
'''
DESCRIPTION
"get_angle" returns the angle between three atoms. By default, the
coordinates used are from the current state, however an alternate
state identifier can be provided.
USAGE
get_angle atom1, atom2, atom3, [,state ]