-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterface.py
88 lines (68 loc) · 4.76 KB
/
interface.py
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
#!/usr/bin/env python2
class PymolCommander(object):
''' This class should not be modified directly, except for adding
more methods to the interface. Instead, this class should
be subclassed and the methods overriden with an actual implementation'''
''' Parameter conventions
model := (Session unique) Model number; a model is defined as a single structure/trajectory loaded into the program; In the order of loaded models; starts with 0; Numbers of deleted models are not reused.
sel := Selection string (independent of molecule)
color := String specifying a color, f.e. 'red' or 'blue'
All functions which select anything (either by id or selection string, etc.),
must check if the selection is valid (i.e., the selection contains at least
one atom)
Unless stated otherwise, all functions should be error-permissive, i.e. failed actions should not throw an Exception. For example if a selected molecule
does not exist (anymore), the function should return instantly, but print a WARNING to stderr using a logger from the python logging module.
Selections
When selection strings are to be generated by the functions (i.e., not supplied as an argument), only molecule number, residue index, residue name and atom name may be used for self-generated selection strings. The reason is that some programs do not set the chain attribute correctly.
'''
def showModel(self, model, chainColors, stickColors):
''' Show model. Polypeptide chains should be shown as Cartoon, all other structures as Sticks. Chains should be colored according to the colors list.
The function must determine itself how to select and colorize the different polypeptide chains in the model.
Everything which is not shown as a cartoon should be shown as sticks (if more than one Atom) or sphere (if exactly one atom).
The sticks/spheres should have atom type coloring according to the program defaults. Stick color should only affect carbons,
non-carbons should be colored according to their type. If there are fewer colors than chains or stick represented molecules,
color according to the last color of the respective list and print a WARNING.'''
raise NotImplementedError()
def hideModel(self, model):
''' Hide model'''
raise NotImplementedError()
def showSticks(self, model, sel, color):
''' Color should only color carbon atoms. Non-carbons should be colored according to their atom type as per program defaults'''
raise NotImplementedError()
def hideSticks(self, model, sel):
raise NotImplementedError()
def showSpheres(self, model, sel, color):
raise NotImplementedError()
def hideSpheres(self, model,sel):
raise NotImplementedError()
def showConnection(self, model, atom1, atom2, color):
''' Show connection between two atoms as dashed line. The dashes should be long
and thick enough so that they should always be adequately visible.
The function should check that the atom selections atom1 and atom2
contain only a single atom each, and return at once while logging an ERROR
otherwise.'''
raise NotImplementedError()
def hideConnection(self, model, atom1, atom2):
raise NotImplementedError()
def loadModel(self,path,form):
''' Load model using path and format form. Should throw an exception if anything goes wrong. For now, formats "pdb" and "prmtop" needs to be implemented'''
raise NotImplementedError()
def loadTraj(self, model,path,form):
''' Load trajectory into model from path using format form. Should throw an exception if anything goes wrong. For now, only the formats "pdb" and "netcdf" need to be implemented.'''
raise NotImplementedError()
def deleteModel(self, model):
''' Remove model from the program.'''
raise NotImplementedError()
def center(self, model):
''' Set center of view rotation to the center of the molecule '''
raise NotImplementedError()
def zoom(self, model, sel):
''' Move view to zoom in on selection. Old viewpoint should be saved.'''
raise NotImplementedError()
def undoZoom(self):
''' Go to viewpoint before the last zoom. Can be called up to 10 times in a row.
If the list of previous viewpoints is exhausted, do nothing. If the model used for the previous zoom does not exist anymore, do nothing.'''
raise NotImplementedError()
def setFrame(self, model, n):
''' Set the frame of model to n. n=0 should select the first frame of the structure. If model does not exist, print a WARNING and return. If n does not exist, throw an Exception.'''
raise NotImplementedError()