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 'spin' 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_spin, create_pseudo_spin, create_spin, delete_spin, display_spin, id_string_doc, name_spin, number_spin, set_spin_element
31
32
33 -class Spin(User_fn_class):
34 """Class for manipulating the spin data."""
35
36 - def copy(self, pipe_from=None, spin_from=None, pipe_to=None, spin_to=None):
37
38 if self._exec_info.intro:
39 text = self._exec_info.ps3 + "spin.copy("
40 text = text + "pipe_from=" + repr(pipe_from)
41 text = text + ", spin_from=" + repr(spin_from)
42 text = text + ", pipe_to=" + repr(pipe_to)
43 text = text + ", spin_to=" + repr(spin_to) + ")"
44 print(text)
45
46
47 arg_check.is_str(pipe_from, 'pipe from', can_be_none=True)
48 arg_check.is_str(spin_from, 'spin from')
49 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True)
50 arg_check.is_str(spin_to, 'spin to', can_be_none=True)
51
52
53 copy_spin(pipe_from=pipe_from, spin_from=spin_from, pipe_to=pipe_to, spin_to=spin_to)
54
55
56 copy._doc_title = "Copy all data associated with a spin."
57 copy._doc_title_short = "Spin copying."
58 copy._doc_args = [
59 ["pipe_from", "The data pipe containing the spin from which the data will be copied. This defaults to the current data pipe."],
60 ["spin_from", "The spin identifier string of the spin to copy the data from."],
61 ["pipe_to", "The data pipe to copy the data to. This defaults to the current data pipe."],
62 ["spin_to", "The spin identifier string of the spin to copy the data to."]]
63 copy._doc_desc = """
64 This will copy all the data associated with the identified spin to the new, non-existent spin. The new spin must not already exist.
65 """
66 copy._doc_examples = """
67 To copy the spin data from spin 1 to the new spin 2, type:
68
69 relax> spin.copy(spin_from='@1', spin_to='@2')
70
71
72 To copy spin 1 of the molecule 'Old mol' to spin 5 of the molecule 'New mol', type:
73
74 relax> spin.copy(spin_from='#Old mol@1', spin_to='#New mol@5')
75
76
77 To copy the spin data of spin 1 from the data pipe 'm1' to 'm2', assuming the current
78 data pipe is 'm1', type:
79
80 relax> spin.copy(spin_from='@1', pipe_to='m2')
81 relax> spin.copy(pipe_from='m1', spin_from='@1', pipe_to='m2', spin_to='@1')
82 """
83 _build_doc(copy)
84
85
86 - def create(self, spin_num=None, spin_name=None, res_num=None, res_name=None, mol_name=None):
87
88 if self._exec_info.intro:
89 text = self._exec_info.ps3 + "spin.create("
90 text = text + "spin_num=" + repr(spin_num)
91 text = text + ", spin_name=" + repr(spin_name)
92 text = text + ", res_num=" + repr(res_num)
93 text = text + ", res_name=" + repr(res_name)
94 text = text + ", mol_name=" + repr(mol_name) + ")"
95 print(text)
96
97
98 arg_check.is_int(spin_num, 'spin number', can_be_none=True)
99 arg_check.is_str(spin_name, 'spin name', can_be_none=True)
100 arg_check.is_int(res_num, 'residue number', can_be_none=True)
101 arg_check.is_str(res_name, 'residue name', can_be_none=True)
102 arg_check.is_str(mol_name, 'molecule name', can_be_none=True)
103
104
105 create_spin(spin_num=spin_num, spin_name=spin_name, res_num=res_num, res_name=res_name, mol_name=mol_name)
106
107
108 create._doc_title = "Create a new spin."
109 create._doc_title_short = "Spin creation."
110 create._doc_args = [
111 ["spin_num", "The spin number."],
112 ["spin_name", "The name of the spin."],
113 ["res_num", "The number of the residue to add the spin to."],
114 ["res_name", "The name of the residue to add the spin to."],
115 ["mol_name", "The name of the molecule to add the spin to."]]
116 create._doc_desc = """
117 This will add a new spin data container to the relax data storage object. The same spin number cannot be used more than once.
118 """
119 create._doc_examples = """
120 The following sequence of commands will generate the sequence 1 C4, 2 C9, 3 C15:
121
122 relax> spin.create(1, 'C4')
123 relax> spin.create(2, 'C9')
124 relax> spin.create(3, 'C15')
125 """
126 _build_doc(create)
127
128
129 - def create_pseudo(self, spin_name=None, spin_num=None, res_id=None, members=None, averaging='linear'):
130
131 if self._exec_info.intro:
132 text = self._exec_info.ps3 + "spin.create_pseudo("
133 text = text + "spin_name=" + repr(spin_name)
134 text = text + ", spin_num=" + repr(spin_num)
135 text = text + ", res_id=" + repr(res_id)
136 text = text + ", members=" + repr(members)
137 text = text + ", averaging=" + repr(averaging) + ")"
138 print(text)
139
140
141 arg_check.is_str(spin_name, 'spin name')
142 arg_check.is_int(spin_num, 'spin number', can_be_none=True)
143 arg_check.is_str(res_id, 'residue ID string', can_be_none=True)
144 arg_check.is_str_list(members, 'members')
145 arg_check.is_str(averaging, 'positional averaging technique')
146
147
148 create_pseudo_spin(spin_num=spin_num, spin_name=spin_name, res_id=res_id, members=members, averaging=averaging)
149
150
151 create_pseudo._doc_title = "Create a spin system representing a pseudo-atom."
152 create_pseudo._doc_title_short = "Pseudo-atom creation."
153 create_pseudo._doc_args = [
154 ["spin_name", "The name of the pseudo-atom spin."],
155 ["spin_num", "The spin number."],
156 ["res_id", "The molecule and residue ID string identifying the position to add the pseudo-spin to."],
157 ["members", "A list of the atoms (as spin ID strings) that the pseudo-atom is composed of."],
158 ["averaging", "The positional averaging technique."]]
159 create_pseudo._doc_desc = """
160 This will create a spin data container representing a number of pre-existing spin containers as a pseudo-atom. The optional spin number must not already exist.
161 """
162 create_pseudo._doc_examples = """
163 The following will create the pseudo-atom named 'Q9' consisting of the protons '@H16',
164 '@H17', '@H18':
165
166 relax> spin.create_pseudo('Q9', members=['@H16', '@H17', '@H18'])
167 """
168 create_pseudo._doc_additional = [id_string_doc]
169 _build_doc(create_pseudo)
170
171
172 - def delete(self, spin_id=None):
173
174 if self._exec_info.intro:
175 text = self._exec_info.ps3 + "spin.delete("
176 text = text + "spin_id=" + repr(spin_id) + ")"
177 print(text)
178
179
180 arg_check.is_str(spin_id, 'spin identification string')
181
182
183 delete_spin(spin_id=spin_id)
184
185
186 delete._doc_title = "Delete spins."
187 delete._doc_title_short = "Spin deletion."
188 delete._doc_args = [
189 ["spin_id", "The spin identifier string."]]
190 delete._doc_desc = """
191 This can be used to delete a single or sets of spins. See the identification string documentation below for more information.
192 """
193 delete._doc_additional = [id_string_doc]
194 _build_doc(delete)
195
196
198
199 if self._exec_info.intro:
200 text = self._exec_info.ps3 + "spin.display("
201 text = text + "spin_id=" + repr(spin_id) + ")"
202 print(text)
203
204
205 arg_check.is_str(spin_id, 'spin identification string', can_be_none=True)
206
207
208 display_spin(spin_id=spin_id)
209
210
211 display._doc_title = "Display information about the spin(s)."
212 display._doc_title_short = "Spin information."
213 display._doc_args = [
214 ["spin_id", "The spin identification string."]]
215 display._doc_additional = [id_string_doc]
216 _build_doc(display)
217
218
219 - def element(self, spin_id=None, element=None, force=False):
235
236
237 element._doc_title = "Set the element type of the spin."
238 element._doc_title_short = "Spin element setting."
239 element._doc_args = [
240 ["spin_id", "The spin identification string corresponding to one or more spins."],
241 ["element", "The IUPAC element name."],
242 ["force", "A flag which if True will cause the element to be changed."]]
243 element._doc_desc = """
244 This allows the element type of the spins to be set.
245 """
246 element._doc_examples = """
247 The set all spins of residue 1 to be carbons, type one of:
248
249 relax> spin.element('@1', 'C', force=True)
250 relax> spin.element(spin_id='@1', element='C', force=True)
251 """
252 element._doc_additional = [id_string_doc]
253 _build_doc(element)
254
255
256 - def name(self, spin_id=None, name=None, force=False):
272
273
274 name._doc_title = "Name the spins."
275 name._doc_title_short = "Spin naming."
276 name._doc_args = [
277 ["spin_id", "The spin identification string corresponding to one or more spins."],
278 ["name", "The new name."],
279 ["force", "A flag which if True will cause the spin to be renamed."]]
280 name._doc_desc = """
281 This simply allows spins to be named (or renamed). Spin naming often essential. For example when reading Sparky peak list files, then the spin name must match that in the file.
282 """
283 name._doc_examples = """
284 The following sequence of commands will rename the sequence {1 C1, 2 C2, 3 C3} to {1 C11,
285 2 C12, 3 C13}:
286
287 relax> spin.name('@1', 'C11', force=True)
288 relax> spin.name('@2', 'C12', force=True)
289 relax> spin.name('@3', 'C13', force=True)
290 """
291 name._doc_additional = [id_string_doc]
292 _build_doc(name)
293
294
295 - def number(self, spin_id=None, number=None, force=False):
311
312
313 number._doc_title = "Number the spins."
314 number._doc_title_short = "Spin numbering."
315 number._doc_args = [
316 ["spin_id", "The spin identification string corresponding to a single spin."],
317 ["number", "The new spin number."],
318 ["force", "A flag which if True will cause the spin to be renumbered."]]
319 number._doc_desc = """
320 This simply allows spins to be numbered. The new number cannot correspond to an existing spin number.
321 """
322 number._doc_examples = """
323 The following sequence of commands will renumber the sequence {1 C1, 2 C2, 3 C3} to
324 {-1 C1, -2 C2, -3 C3}:
325
326 relax> spin.number('@1', -1, force=True)
327 relax> spin.number('@2', -2, force=True)
328 relax> spin.number('@3', -3, force=True)
329 """
330 number._doc_additional = [id_string_doc]
331 _build_doc(number)
332