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 'sequence' 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 import sequence
31 from relax_errors import RelaxError
32
33
35 """Class for manipulating sequence data."""
36
37 - def copy(self, pipe_from=None, pipe_to=None):
38
39 if self._exec_info.intro:
40 text = self._exec_info.ps3 + "sequence.copy("
41 text = text + "pipe_from=" + repr(pipe_from)
42 text = text + ", pipe_to=" + repr(pipe_to) + ")"
43 print(text)
44
45
46 arg_check.is_str(pipe_from, 'pipe from', can_be_none=True)
47 arg_check.is_str(pipe_to, 'pipe to', can_be_none=True)
48
49
50 if pipe_from == None and pipe_to == None:
51 raise RelaxError("The pipe_from and pipe_to arguments cannot both be set to None.")
52
53
54 sequence.copy(pipe_from=pipe_from, pipe_to=pipe_to)
55
56
57 copy._doc_title = "Copy the molecule, residue, and spin sequence data from one data pipe to another."
58 copy._doc_title_short = "Sequence data copying."
59 copy._doc_args = [
60 ["pipe_from", "The name of the data pipe to copy the sequence data from."],
61 ["pipe_to", "The name of the data pipe to copy the sequence data to."]
62 ]
63 copy._doc_desc = """
64 This will copy the sequence data between data pipes. The destination data pipe must not contain any sequence data. If the source and destination pipes are not specified, then both will default to the current data pipe (hence providing one is essential).
65 """
66 copy._doc_examples = """
67 To copy the sequence from the data pipe 'm1' to the current data pipe, type:
68
69 relax> sequence.copy('m1')
70 relax> sequence.copy(pipe_from='m1')
71
72
73 To copy the sequence from the current data pipe to the data pipe 'm9', type:
74
75 relax> sequence.copy(pipe_to='m9')
76
77
78 To copy the sequence from the data pipe 'm1' to 'm2', type:
79
80 relax> sequence.copy('m1', 'm2')
81 relax> sequence.copy(pipe_from='m1', pipe_to='m2')
82 """
83 _build_doc(copy)
84
85
86 - def display(self, sep=None, mol_name_flag=True, res_num_flag=True, res_name_flag=True, spin_num_flag=True, spin_name_flag=True):
87
88 if self._exec_info.intro:
89 text = self._exec_info.ps3 + "sequence.display("
90 text = text + "sep=" + repr(sep)
91 text = text + ", mol_name_flag=" + repr(mol_name_flag)
92 text = text + ", res_num_flag=" + repr(res_num_flag)
93 text = text + ", res_name_flag=" + repr(res_name_flag)
94 text = text + ", spin_num_flag=" + repr(spin_num_flag)
95 text = text + ", spin_name_flag=" + repr(spin_name_flag) + ")"
96 print(text)
97
98
99 arg_check.is_str(sep, 'column separator', can_be_none=True)
100 arg_check.is_bool(mol_name_flag, 'molecule name flag')
101 arg_check.is_bool(res_num_flag, 'residue number flag')
102 arg_check.is_bool(res_name_flag, 'residue name flag')
103 arg_check.is_bool(spin_num_flag, 'spin number flag')
104 arg_check.is_bool(spin_name_flag, 'spin name flag')
105
106
107 sequence.display(sep=sep, mol_name_flag=mol_name_flag, res_num_flag=res_num_flag, res_name_flag=res_name_flag, spin_num_flag=spin_num_flag, spin_name_flag=spin_name_flag)
108
109
110 display._doc_title = "Display sequences of molecules, residues, and/or spins."
111 display._doc_title_short = "Sequence data display."
112 display._doc_args = [
113 ["sep", "The column separator (the default of None corresponds to white space)."],
114 ["mol_name_flag", "A flag whic if True will cause the molecule name column to be shown."],
115 ["res_num_flag", "A flag whic if True will cause the residue number column to be shown."],
116 ["res_name_flag", "A flag whic if True will cause the residue name column to be shown."],
117 ["spin_num_flag", "A flag whic if True will cause the spin number column to be shown."],
118 ["spin_name_flag", "A flag whic if True will cause the spin name column to be shown."]
119 ]
120 _build_doc(display)
121
122
123 - def read(self, file=None, dir=None, spin_id_col=None, mol_name_col=None, res_num_col=None, res_name_col=None, spin_num_col=None, spin_name_col=None, sep=None, spin_id=None):
124
125 if self._exec_info.intro:
126 text = self._exec_info.ps3 + "sequence.read("
127 text = text + "file=" + repr(file)
128 text = text + ", dir=" + repr(dir)
129 text = text + ", spin_id_col=" + repr(spin_id_col)
130 text = text + ", mol_name_col=" + repr(mol_name_col)
131 text = text + ", res_num_col=" + repr(res_num_col)
132 text = text + ", res_name_col=" + repr(res_name_col)
133 text = text + ", spin_num_col=" + repr(spin_num_col)
134 text = text + ", spin_name_col=" + repr(spin_name_col)
135 text = text + ", sep=" + repr(sep)
136 text = text + ", spin_id=" + repr(spin_id) + ")"
137 print(text)
138
139
140 arg_check.is_str(file, 'file name')
141 arg_check.is_str(dir, 'directory name', can_be_none=True)
142 arg_check.is_int(spin_id_col, 'spin ID string column', can_be_none=True)
143 arg_check.is_int(mol_name_col, 'molecule name column', can_be_none=True)
144 arg_check.is_int(res_num_col, 'residue number column', can_be_none=True)
145 arg_check.is_int(res_name_col, 'residue name column', can_be_none=True)
146 arg_check.is_int(spin_num_col, 'spin number column', can_be_none=True)
147 arg_check.is_int(spin_name_col, 'spin name column', can_be_none=True)
148 arg_check.is_str(sep, 'column separator', can_be_none=True)
149 arg_check.is_str(spin_id, 'spin ID string', can_be_none=True)
150
151
152 sequence.read(file=file, dir=dir, spin_id_col=spin_id_col, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col, sep=sep, spin_id=spin_id)
153
154
155 read._doc_title = "Read the molecule, residue, and spin sequence from a file."
156 read._doc_title_short = "Sequence data reading."
157 read._doc_args = [
158 ["file", "The name of the file containing the sequence data."],
159 ["dir", "The directory where the file is located."],
160 ["spin_id_col", "The spin ID string column (an alternative to the mol, res, and spin name and number columns)."],
161 ["mol_name_col", "The molecule name column (alternative to the spin_id_col)."],
162 ["res_num_col", "The residue number column (alternative to the spin_id_col)."],
163 ["res_name_col", "The residue name column (alternative to the spin_id_col)."],
164 ["spin_num_col", "The spin number column (alternative to the spin_id_col)."],
165 ["spin_name_col", "The spin name column (alternative to the spin_id_col)."],
166 ["sep", "The column separator (the default is white space)."],
167 ["spin_id", "The spin ID string to restrict the loading of data to certain spin subsets."]
168 ]
169 read._doc_desc = """
170 The spin system can be identified in the file using two different formats. The first is the spin ID string column which can include the molecule name, the residue name and number, and the spin name and number. Alternatively the molecule name, residue number, residue name, spin number and/or spin name columns can be supplied allowing this information to be in separate columns. Note that the numbering of columns starts at one. The spin ID string can be used to restrict the reading to certain spin types, for example only 15N spins when only residue information is in the file.
171 """
172 read._doc_examples = """
173 The following commands will read protein backbone 15N sequence data out of a file called
174 'seq' where the residue numbers and names are in the first and second columns respectively:
175
176 relax> sequence.read('seq')
177 relax> sequence.read('seq', res_num_col=1, res_name_col=2)
178 relax> sequence.read(file='seq', res_num_col=1, res_name_col=2, sep=None)
179
180
181 The following commands will read the residue sequence out of the file 'noe.out' which also
182 contains the NOE values:
183
184 relax> sequence.read('noe.out')
185 relax> sequence.read('noe.out', res_num_col=1, res_name_col=2)
186 relax> sequence.read(file='noe.out', res_num_col=1, res_name_col=2)
187
188
189 The following commands will read the sequence out of the file 'noe.600.out' where the
190 residue numbers are in the second column, the names are in the sixth column and the columns
191 are separated by commas:
192
193 relax> sequence.read('noe.600.out', res_num_col=2, res_name_col=6, sep=',')
194 relax> sequence.read(file='noe.600.out', res_num_col=2, res_name_col=6, sep=',')
195
196
197 The following commands will read the RNA residues and atoms (including C2, C5, C6, C8, N1,
198 and N3) from the file '500.NOE', where the residue number, residue name, spin number, and
199 spin name are in the first to fourth columns respectively:
200
201 relax> sequence.read('500.NOE', res_num_col=1, res_name_col=2, spin_num_col=3,
202 spin_name_col=4)
203 relax> sequence.read(file='500.NOE', res_num_col=1, res_name_col=2, spin_num_col=3,
204 spin_name_col=4)
205 """
206 _build_doc(read)
207
208
209 - def write(self, file, dir=None, sep=None, mol_name_flag=False, res_num_flag=False, res_name_flag=False, spin_num_flag=False, spin_name_flag=False, force=False):
210
211 if self._exec_info.intro:
212 text = self._exec_info.ps3 + "sequence.write("
213 text = text + "file=" + repr(file)
214 text = text + ", dir=" + repr(dir)
215 text = text + ", sep=" + repr(sep)
216 text = text + ", mol_name_flag=" + repr(mol_name_flag)
217 text = text + ", res_num_flag=" + repr(res_num_flag)
218 text = text + ", res_name_flag=" + repr(res_name_flag)
219 text = text + ", spin_num_flag=" + repr(spin_num_flag)
220 text = text + ", spin_name_flag=" + repr(spin_name_flag)
221 text = text + ", force=" + repr(force) + ")"
222 print(text)
223
224
225 arg_check.is_str(file, 'file name')
226 arg_check.is_str(dir, 'directory name', can_be_none=True)
227 arg_check.is_str(sep, 'column separator', can_be_none=True)
228 arg_check.is_bool(mol_name_flag, 'molecule name flag')
229 arg_check.is_bool(res_num_flag, 'residue number flag')
230 arg_check.is_bool(res_name_flag, 'residue name flag')
231 arg_check.is_bool(spin_num_flag, 'spin number flag')
232 arg_check.is_bool(spin_name_flag, 'spin name flag')
233 arg_check.is_bool(force, 'force flag')
234
235
236 sequence.write(file=file, dir=dir, sep=sep, mol_name_flag=mol_name_flag, res_num_flag=res_num_flag, res_name_flag=res_name_flag, spin_num_flag=spin_num_flag, spin_name_flag=spin_name_flag, force=force)
237
238
239 write._doc_title = "Write the molecule, residue, and spin sequence to a file."
240 write._doc_title_short = "Sequence data writing."
241 write._doc_args = [
242 ["file", "The name of the file."],
243 ["dir", "The directory name."],
244 ["sep", "The column separator (the default of None corresponds to white space)."],
245 ["mol_name_flag", "A flag which if True will cause the molecule name column to be shown."],
246 ["res_num_flag", "A flag which if True will cause the residue number column to be shown."],
247 ["res_name_flag", "A flag which if True will cause the residue name column to be shown."],
248 ["spin_num_flag", "A flag which if True will cause the spin number column to be shown."],
249 ["spin_name_flag", "A flag which if True will cause the spin name column to be shown."],
250 ["force", "A flag which if True will cause the file to be overwritten."]
251 ]
252 write._doc_desc = """
253 Write the sequence data to file. If no directory name is given, the file will be placed in the current working directory.
254 """
255 _build_doc(write)
256