1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 """Module containing all of the RelaxError objects."""
24
25
26
27 try:
28 from bz2 import BZ2File
29 bz2 = True
30 except ImportError:
31 bz2 = False
32 try:
33 from cPickle import dump
34 except ImportError:
35 from pickle import dump
36 from re import match
37 import sys
38 import time
39
40
41 import ansi
42
43
44
45 BIN = 'a binary number (0 or 1)'
46 BOOL = 'a Boolean (True or False)'
47 INT = 'an integer'
48 FILE = 'a file object'
49 FLOAT = 'a floating point number'
50 FUNC = 'a function'
51 LIST = 'a list'
52 LIST_FLOAT = 'a list of floating point numbers'
53 LIST_INT = 'a list of integers'
54 LIST_NUM = 'a list of numbers'
55 LIST_STR = 'a list of strings'
56 LIST_VAL = 'a list of values'
57 MATRIX_FLOAT = 'a matrix of floating point numbers'
58 NONE = 'None'
59 NUM = 'a number'
60 TUPLE = 'a tuple'
61 TUPLE_FLOAT = 'a tuple of floating point numbers'
62 TUPLE_INT = 'a tuple of integers'
63 TUPLE_NUM = 'a tuple of numbers'
64 TUPLE_STR = 'a tuple of strings'
65 STR = 'a string'
66 VAL = 'a value'
67
68
70 """Save the program state, for debugging purposes."""
71
72
73 try:
74 from data import Relax_data_store; ds = Relax_data_store()
75
76
77 except ImportError:
78 return
79
80
81 now = time.localtime()
82 file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[1], now[2], now[3], now[4], now[5])
83
84
85 if bz2:
86 sys.stderr.write("\n\nStoring the relax state in the file '%s.bz2'.\n\n\n" % file_name)
87 file = BZ2File(file_name+'.bz2', 'w')
88 else:
89 sys.stderr.write("\n\nStoring the relax state in the file '%s'.\n\n\n" % file_name)
90 file = open(file_name, 'w')
91
92
93 dump(ds, file, 1)
94
95
96 file.close()
97
98
99 -def list_to_text(data):
100 """Convert the given Python list to a text representation.
101
102 @param data: The list of Python objects.
103 @type data: list
104 @return: The English text version of the list.
105 @rtype: str
106 """
107
108
109 text = ''
110
111
112 for i in range(len(data)):
113
114 text += repr(data[i])
115
116
117 if i < len(data) - 2:
118 text += ', '
119
120
121 if i == len(data) - 2:
122 text += ' and '
123
124
125 return text
126
127
128
129
130
132 """The base class for all RelaxErrors."""
133
147
148
150 """The base class for all the argument related RelaxErrors."""
151
152
153 simple_types = []
154
155
156 list_types = []
157
158
159 - def __init__(self, name, value, size=None):
160 """A default initialisation and error message formatting method."""
161
162
163 self.text = "The %s argument '%s' must be " % (name, value)
164
165
166 if size != None:
167 for i in range(len(self.list_types)):
168 self.list_types[i] = self.list_types[i] + " of size %s" % repr(size)
169
170
171 all_types = self.simple_types + self.list_types
172
173
174 if len(all_types) > 1:
175 self.text = self.text + "either "
176
177
178 for i in range(len(all_types)):
179
180 if i > 0:
181
182 if i == len(all_types)-1:
183 self.text = self.text + ", or "
184
185
186 else:
187 self.text = self.text + ", "
188
189
190 self.text = self.text + all_types[i]
191
192
193 self.text = self.text + "."
194
195
196
197
198
202
203
204
205
206
209 self.text = "The %s module '%s' cannot be found. Please check that it is installed." % (desc, name)
210
211
212
213
214
217 self.text = "Impossible to be here, please re-run relax with the '--debug' flag and summit a bug report at https://web.archive.org/web/https://gna.org/projects/relax/."
218
220
221 save_state()
222
223
224 return ("RelaxError: " + self.text + "\n")
225
226
227
228
229
230
233 if fn_name:
234 self.text = "The %s function has not yet been implemented for the current data pipe." % fn_name
235 else:
236 self.text = "This has not yet been implemented for the current data pipe."
237
238
239
240
241
242
245 self.text = "The program " + repr(name) + " cannot be found."
246
247
248
251 self.text = "The binary executable file " + repr(name) + " does not exist."
252
253
254
257 self.text = "The binary executable file " + repr(name) + " is not executable."
258
259
260
263 self.text = "The binary executable file " + repr(name) + " is not located within the system path."
264
265
266
269 self.text = "Execution of the program " + name + " has failed."
270
271
272
273
274
275
278 if pipe != None:
279 self.text = "PDB data corresponding to the data pipe " + repr(pipe) + " already exists."
280 else:
281 self.text = "PDB data already exists."
282
283
286 if pipe != None:
287 self.text = "No PDB file has been loaded for the data pipe " + repr(pipe) + "."
288 else:
289 self.text = "No PDB file has been loaded."
290
291
294 self.text = "The PDB file " + repr(name) + " could not be loaded properly, no molecular chains could be extracted."
295
296
299 if spin_id != None:
300 self.text = "The multiple unit XH bond vectors for the spin '%s' - this is not supported by the current data pipe type." % spin_id
301 else:
302 self.text = "The multiple unit XH bond vectors per spin - this is not supported by the current data pipe type."
303
304
307 if pipe:
308 self.text = "No unit vectors have been calculated for the data pipe '%s'" % pipe
309 else:
310 self.text = "No unit vectors have been calculated."
311
312
315 self.text = "No peptide or nucleotide chains can be found within the PDB file."
316
317
318
319
320
321
324 if spin_id != None:
325 self.text = "The type of nucleus for the spin '%s' has not yet been set." % spin_id
326 else:
327 self.text = "The type of nucleus has not yet been set."
328
329
332 if spin_id != None:
333 self.text = "The nuclear isotope type for the spin '%s' has not yet been set. Please use the spin.isotope user function to set the type." % spin_id
334 else:
335 self.text = "The nuclear isotope type has not yet been set. Please use the spin.isotope user function to set the type."
336
337
338
339
340
341
342
343
344
345
348 self.text = "The " + name + " argument " + repr(value) + " is invalid."
349
350
353 self.text = "The " + name + " argument " + repr(value) + " is neither "
354 for i in range(len(list)-1):
355 self.text = self.text + repr(list[i]) + ', '
356 self.text = self.text + 'nor ' + repr(list[-1]) + "."
357
358
361 self.text = "The " + name + " argument must be of length " + repr(len) + "."
362
363
366 self.text = "The " + name + " argument has not been supplied."
367
368
371 self.text = "The %s argument of '%s' must be None."
372
373
374
375
376
377
380
381
384
385
388
391
392
395
398
399
402
405
406
409
412
413
416
419
420
421
422
423
424
427
430
431
434
437
438
439
440
441
442
443
446
450
451
454
457
458
461
462
465
466
470
471
474
478
479
482
486
487
488
489
490
491
495
496
500
501
505
509
510
514
518
519
523
524
528
532
533
537
541
542
546
550
551
552
553
554
555
558
562
563
566
567
568
569
570
571
575
576
580
584
585
586
587
588
589
592
595
596
597
598
599
600
601
604 if pipe == None:
605 self.text = "The sequence data does not exist."
606 else:
607 self.text = "The sequence data for the data pipe " + repr(pipe) + " does not exist."
608
609
612 if pipe == None:
613 self.text = "The sequence data already exists."
614 else:
615 self.text = "The sequence data for the data pipe " + repr(pipe) + " already exists."
616
617
620 self.text = "The sequences for the data pipes " + repr(pipe1) + " and " + repr(pipe2) + " are not the same."
621
622
625 self.text = "The number of molecules do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
626
627
630 self.text = "The number of residues do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
631
632
635 self.text = "The number of spins do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
636
637
640 if id == '':
641 self.text = "The empty molecule ID corresponds to more than a single molecule in the current data pipe."
642 else:
643 self.text = "The molecule ID '%s' corresponds to more than a single molecule in the current data pipe." % id
644
645
648 if id == '':
649 self.text = "The empty residue ID corresponds to more than a single residue in the current data pipe."
650 else:
651 self.text = "The residue ID '%s' corresponds to more than a single residue in the current data pipe." % id
652
653
656 if id_list != None and id == '':
657 self.text = "The empty spin ID corresponds to multiple spins, including %s." % list_to_text(id_list)
658 elif id_list == None and id == '':
659 self.text = "The empty spin ID corresponds to more than a single spin in the current data pipe."
660 elif id_list != None:
661 self.text = "The spin ID '%s' corresponds to multiple spins, including %s." % (id, list_to_text(id_list))
662 else:
663 self.text = "The spin ID '%s' corresponds to more than a single spin in the current data pipe." % id
664
665
668 if name == None:
669 self.text = "The residue '" + repr(number) + "' cannot be found in the sequence."
670 else:
671 self.text = "The residue '" + repr(number) + " " + name + "' cannot be found in the sequence."
672
673
676 self.text = "The spin " + repr(id) + " does not exist."
677
678
680 - def __init__(self, line, problem=None):
681 if problem == None:
682 self.text = "The sequence data in the line %s is invalid." % line
683 else:
684 self.text = "The sequence data in the line %s is invalid, %s." % (line, problem)
685
686
689 self.text = "The spin information for the spin " + repr(spin_id) + " has not yet been loaded, please use the structure.load_spins user function."
690
691
692
693
694
695
697 - def __init__(self, spin_id1=None, spin_id2=None, pipe=None):
698 if spin_id1 and pipe:
699 self.text = "The interatomic data between the spins '%s' and '%s' for the data pipe '%s' does not exist." % (spin_id1, spin_id2, pipe)
700 elif spin_id1:
701 self.text = "The interatomic data between the spins '%s' and '%s' does not exist." % (spin_id1, spin_id2)
702 elif pipe:
703 self.text = "The interatomic data for the data pipe '%s' does not exist." % pipe
704 else:
705 self.text = "The interatomic data does not exist."
706
707
710 if pipe == None:
711 self.text = "The interatomic data already exists."
712 else:
713 self.text = "The interatomic data for the data pipe " + repr(pipe) + " already exists."
714
715
716
717
718
719
720
723 self.text = "Spectral data corresponding to the ID string '%s' does not exist." % spectrum_id
724
725
728 self.text = "Spectral data corresponding to the ID string '%s' already exists." % spectrum_id
729
730
731
732
733
734
737 self.text = "Relaxation data corresponding to the ID string '%s' does not exist." % ri_id
738
739
742 self.text = "Relaxation data corresponding to the ID string '%s' already exists." % ri_id
743
744
745
746
747
748
751 self.text = "RDC data corresponding to the identification string " + repr(id) + " does not exist."
752
753
756 self.text = "RDC data corresponding to the identification string " + repr(id) + " already exists."
757
758
761 self.text = "PCS data corresponding to the identification string " + repr(id) + " does not exist."
762
763
766 self.text = "PCS data corresponding to the identification string " + repr(id) + " already exists."
767
768
769
770
771
772
775 self.text = "Model-free data corresponding to the data pipe " + repr(pipe) + " already exists."
776
777
778
779
780
781
784 self.text = "The " + tensor_type + " tensor data already exists."
785
786
788 - def __init__(self, tensor_type, tensor_label=None):
789 if not tensor_label:
790 self.text = "No " + tensor_type + " tensor data exists."
791 else:
792 self.text = "No " + tensor_type + " tensor data exists for the tensor " + repr(tensor_label) + "."
793
794
795
796
797
798
801 if name == None:
802 self.text = "The directory " + repr(dir) + " does not exist."
803 else:
804 self.text = "The " + name + " directory " + repr(dir) + " does not exist."
805
806
808 - def __init__(self, name, file_name=None):
809 if file_name == None:
810 self.text = "The file " + repr(name) + " does not exist."
811 else:
812 self.text = "The " + name + " file " + repr(file_name) + " does not exist."
813
814
817 self.text = "The file contains no data."
818
819
822 self.text = "The file " + repr(file_name) + " already exists. Set the " + flag + " to True to overwrite."
823
824
827 self.text = "The format of the data is invalid."
828
829
830
831
832
833
836 self.text = "The data pipe bundle '%s' already exists." % bundle
837
838
841 if bundle != None:
842 self.text = "The data pipe bundle '%s' has not been created yet." % bundle
843 else:
844 self.text = "No data pipe bundles currently exist. Please use the pipe.bundle user function first."
845
846
849 self.text = "The data pipe " + repr(pipe) + " already exists."
850
851
854 if pipe != None:
855 self.text = "The data pipe " + repr(pipe) + " has not been created yet."
856 else:
857 self.text = "No data pipes currently exist. Please use the pipe.create user function first."
858
859
860
861
862
863
866 self.text = "The selection of molecules is not allowed."
867
868
871 self.text = "The selection of residues is not allowed."
872
873
876 self.text = "The selection of spin systems is not allowed."
877
878
881 self.text = "The spin system must be specified."
882
883
884
885
886
887
888
891 self.text = "This function is not available for " + string + "."
892
893
896 if name != None:
897 self.text = "The " + name + " model already exists."
898 else:
899 self.text = "The model already exists."
900
901
902
905 if name != None:
906 self.text = "The specific " + name + " model has not been selected or set up."
907 else:
908 self.text = "The specific model has not been selected or set up."
909
910
911
912
913
914
917 self.text = "The " + name + " argument " + repr(value) + " is not valid regular expression."
918
919
920
921
922
923
925 - def __init__(self, name, param_type=None):
926 if param_type != None:
927 self.text = "The " + name + " parameter, " + repr(param_type) + ", cannot be set."
928 else:
929 self.text = "The " + name + " parameter cannot be set."
930
931
933 - def __init__(self, data_type, pipe=None):
934 if pipe != None:
935 self.text = "The data type " + repr(data_type) + " already exists for the data pipe " + repr(pipe) + "."
936 else:
937 self.text = "The data type " + repr(data_type) + " already exists."
938
939
941 - def __init__(self, name, spin_id=None, spin_id2=None):
942 if spin_id2 != None:
943 self.text = "The %s value has not yet been set for spins '%s' and '%s'." % (name, spin_id, spin_id2)
944 elif spin_id != None:
945 self.text = "The %s value has not yet been set for spin '%s'." % (name, spin_id)
946 else:
947 self.text = "The " + repr(name) + " value has not yet been set."
948
949
952 self.text = "The data type " + repr(name) + " is unknown."
953
954
956 - def __init__(self, name, param_type=None):
957 if param_type != None:
958 self.text = "The " + name + " parameter, " + repr(param_type) + ", is unknown."
959 else:
960 self.text = "The " + name + " parameter is unknown."
961
962
965 self.text = "The " + repr(name) + " argument " + repr(data) + " represents an unknown parameter combination."
966
967
968
969
970
971
974 if pipe:
975 self.text = "Simulations for the data pipe " + repr(pipe) + " have not been setup."
976 else:
977 self.text = "Simulations have not been setup."
978
979
980
981
982
983
986 self.text = "The style " + repr(style) + " is unknown."
987
988
989
990
991
992
995 self.text = "The colour " + repr(colour) + " is invalid."
996
997
998
999
1000
1001
1004 self.text = "The invalid " + name + " floating point value of infinity has occurred."
1005
1006
1009 self.text = "The invalid " + name + " floating point value of NaN (Not a Number) has occurred."
1010
1011
1012
1013
1014
1015
1018 self.text = "The " + name + " data structure cannot be recreated from the XML elements as the structure is not empty."
1019
1020
1021
1022
1023
1024
1025
1027 """Function for returning all the RelaxErrors to allow the AllRelaxError object to be created."""
1028
1029
1030 list = []
1031
1032
1033 for name in names:
1034
1035 object = globals()[name]
1036
1037
1038 if not (isinstance(object, type(RelaxError)) or isinstance(object, type(type))) or not match('Relax', name):
1039 continue
1040
1041
1042 list.append(object)
1043
1044
1045 return list
1046
1047
1048 AllRelaxErrors = tuple(all_errors(dir()))
1049