1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 """Module containing the 'residue' user function class."""
25 __docformat__ = 'plaintext'
26
27
28 from base_class import User_fn_class, _build_doc
29 import arg_check
30 from generic_fns.mol_res_spin import copy_residue, create_residue, delete_residue, display_residue, id_string_doc, name_residue, number_residue
31
32
34 """Class for manipulating the residue data."""
35
36 - def copy(self, pipe_from=None, res_from=None, pipe_to=None, res_to=None):
37
38 if self._exec_info.intro:
39 text = self._exec_info.ps3 + "residue.copy("
40 text = text + "pipe_from=" + repr(pipe_from)
41 text = text + ", res_from=" + repr(res_from)
42 text = text + ", pipe_to=" + repr(pipe_to)
43 text = text + ", res_to=" + repr(res_to) + ")"
44 print(text)
45
46
47 arg_check.is_str(pipe_from, 'pipe from', can_be_none=True)
48 arg_check.is_str(res_from, 'residue from')
49 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True)
50 arg_check.is_str(res_to, 'residue to', can_be_none=True)
51
52
53 copy_residue(pipe_from=pipe_from, res_from=res_from, pipe_to=pipe_to, res_to=res_to)
54
55
56 copy._doc_title = "Copy all data associated with a residue."
57 copy._doc_title_short = "Residue copying."
58 copy._doc_args = [
59 ["pipe_from", "The data pipe containing the residue from which the data will be copied. This defaults to the current data pipe."],
60 ["res_from", "The residue ID string of the residue to copy the data from."],
61 ["pipe_to", "The data pipe to copy the data to. This defaults to the current data pipe."],
62 ["res_to", "The residue ID string of the residue to copy the data to."]]
63 copy._doc_desc = """
64 This will copy all the data associated with the identified residue to the new, non-existent residue. The new residue cannot currently exist.
65 """
66 copy._doc_examples = """
67 To copy the residue data from residue 1 to the new residue 2, type:
68
69 relax> residue.copy(res_from=':1', res_to=':2')
70
71
72 To copy residue 1 of the molecule 'Old mol' to residue 5 of the molecule 'New mol', type:
73
74 relax> residue.copy(res_from='#Old mol:1', res_to='#New mol:5')
75
76
77 To copy the residue data of residue 1 from the data pipe 'm1' to 'm2', assuming the current
78 data pipe is 'm1', type:
79
80 relax> residue.copy(res_from=':1', pipe_to='m2')
81 relax> residue.copy(pipe_from='m1', res_from=':1', pipe_to='m2', res_to=':1')
82 """
83 _build_doc(copy)
84
85
86 - def create(self, res_num=None, res_name=None, mol_name=None):
87
88 if self._exec_info.intro:
89 text = self._exec_info.ps3 + "residue.create("
90 text = text + "res_num=" + repr(res_num)
91 text = text + ", res_name=" + repr(res_name)
92 text = text + ", mol_name=" + repr(mol_name) + ")"
93 print(text)
94
95
96 arg_check.is_int(res_num, 'residue number')
97 arg_check.is_str(res_name, 'residue name', can_be_none=True)
98 arg_check.is_str(mol_name, 'molecule name', can_be_none=True)
99
100
101 create_residue(res_num=res_num, res_name=res_name, mol_name=mol_name)
102
103
104 create._doc_title = "Create a new residue."
105 create._doc_title_short = "Residue creation."
106 create._doc_args = [
107 ["res_num", "The residue number."],
108 ["res_name", "The name of the residue."],
109 ["mol_name", "The name of the molecule to add the residue to."]]
110 create._doc_desc = """
111 Using this, a new sequence can be generated without using the sequence user functions. However if the sequence already exists, the new residue will be added to the end of the residue list (the residue numbers of this list need not be sequential). The same residue number cannot be used more than once. A corresponding single spin system will be created for this residue. The spin system number and name or additional spin systems can be added later if desired.
112 """
113 create._doc_examples = """
114 The following sequence of commands will generate the sequence 1 ALA, 2 GLY, 3 LYS:
115
116 relax> residue.create(1, 'ALA')
117 relax> residue.create(2, 'GLY')
118 relax> residue.create(3, 'LYS')
119 """
120 _build_doc(create)
121
122
123 - def delete(self, res_id=None):
124
125 if self._exec_info.intro:
126 text = self._exec_info.ps3 + "residue.delete("
127 text = text + "res_id=" + repr(res_id) + ")"
128 print(text)
129
130
131 arg_check.is_str(res_id, 'residue ID string')
132
133
134 delete_residue(res_id=res_id)
135
136
137 delete._doc_title = "Delete residues from the current data pipe."
138 delete._doc_title_short = "Residue deletion."
139 delete._doc_args = [
140 ["res_id", "The residue ID string."]]
141 delete._doc_desc = """
142 This can be used to delete a single or sets of residues. See the ID string documentation for more information. If spin system/atom ids are included a RelaxError will be raised.
143 """
144 delete._doc_additional = [id_string_doc]
145 _build_doc(delete)
146
147
149
150 if self._exec_info.intro:
151 text = self._exec_info.ps3 + "residue.display("
152 text = text + "res_id=" + repr(res_id) + ")"
153 print(text)
154
155
156 arg_check.is_str(res_id, 'residue ID string', can_be_none=True)
157
158
159 display_residue(res_id=res_id)
160
161
162 display._doc_title = "Display information about the residue(s)."
163 display._doc_args = [
164 ["res_id", "The residue ID string."]]
165 display._doc_additional = [id_string_doc]
166 _build_doc(display)
167
168
169 - def name(self, res_id=None, name=None, force=False):
185
186
187 name._doc_title = "Name the residues."
188 name._doc_title_short = "Residue naming."
189 name._doc_args = [
190 ["res_id", "The residue ID string corresponding to one or more residues."],
191 ["name", "The new name."],
192 ["force", "A flag which if True will cause the residue to be renamed."]]
193 name._doc_desc = """
194 This simply allows residues to be named (or renamed).
195 """
196 name._doc_examples = """
197 The following sequence of commands will rename the sequence {1 ALA, 2 GLY, 3 LYS} to {1 XXX,
198 2 XXX, 3 XXX}:
199
200 relax> residue.name(':1', 'XXX', force=True)
201 relax> residue.name(':2', 'XXX', force=True)
202 relax> residue.name(':3', 'XXX', force=True)
203
204 Alternatively:
205
206 relax> residue.name(':1,2,3', 'XXX', force=True)
207 """
208 name._doc_additional = [id_string_doc]
209 _build_doc(name)
210
211
212 - def number(self, res_id=None, number=None, force=False):
228
229
230 number._doc_title = "Number the residues."
231 number._doc_title_short = "Residue numbering."
232 number._doc_args = [
233 ["res_id", "The residue ID string corresponding to a single residue."],
234 ["number", "The new residue number."],
235 ["force", "A flag which if True will cause the residue to be renumbered."]]
236 number._doc_desc = """
237 This simply allows residues to be numbered. The new number cannot correspond to an existing residue.
238 """
239 number._doc_examples = """
240 The following sequence of commands will renumber the sequence {1 ALA, 2 GLY, 3 LYS} to
241 {101 ALA, 102 GLY, 103 LYS}:
242
243 relax> residue.number(':1', 101, force=True)
244 relax> residue.number(':2', 102, force=True)
245 relax> residue.number(':3', 103, force=True)
246 """
247 number._doc_additional = [id_string_doc]
248 _build_doc(number)
249