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 all of the RelaxError objects."""
25
26
27
28 try:
29 from bz2 import BZ2File
30 bz2 = True
31 except ImportError:
32 bz2 = False
33 from re import match
34 import sys
35 import time
36 try:
37 import cPickle as pickle
38 except:
39 import pickle
40
41
42 from lib import ansi
43
44
45
46 SAVE_ERROR_STATE = False
47
48
49 BIN = 'a binary number (0 or 1)'
50 BOOL = 'a Boolean (True or False)'
51 INT = 'an integer'
52 FILE = 'a file object'
53 FLOAT = 'a floating point number'
54 FUNC = 'a function'
55 LIST = 'a list'
56 LIST_FLOAT = 'a list of floating point numbers'
57 LIST_INT = 'a list of integers'
58 LIST_NUM = 'a list of numbers'
59 LIST_STR = 'a list of strings'
60 LIST_VAL = 'a list of values'
61 MATRIX_FLOAT = 'a matrix of floating point numbers'
62 NONE = 'None'
63 NUM = 'a number'
64 TUPLE = 'a tuple'
65 TUPLE_FLOAT = 'a tuple of floating point numbers'
66 TUPLE_INT = 'a tuple of integers'
67 TUPLE_NUM = 'a tuple of numbers'
68 TUPLE_STR = 'a tuple of strings'
69 STR = 'a string'
70 VAL = 'a value'
71
72
74 """Save the program state, for debugging purposes."""
75
76
77 try:
78 from data_store import Relax_data_store; ds = Relax_data_store()
79
80
81 except ImportError:
82 return
83
84
85 now = time.localtime()
86 file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[1], now[2], now[3], now[4], now[5])
87
88
89 if bz2:
90 sys.stderr.write("\nStoring the relax state in the file '%s.bz2'.\n\n" % file_name)
91 file = BZ2File(file_name+'.bz2', 'w')
92 else:
93 sys.stderr.write("\nStoring the relax state in the file '%s'.\n\n" % file_name)
94 file = open(file_name, 'w')
95
96
97 pickle.dump(ds, file, 1)
98
99
100 file.close()
101
102
103 -def list_to_text(data):
104 """Convert the given Python list to a text representation.
105
106 @param data: The list of Python objects.
107 @type data: list
108 @return: The English text version of the list.
109 @rtype: str
110 """
111
112
113 text = ''
114
115
116 for i in range(len(data)):
117
118 text += repr(data[i])
119
120
121 if i < len(data) - 2:
122 text += ', '
123
124
125 if i == len(data) - 2:
126 text += ' and '
127
128
129 return text
130
131
132
133
134
136 """The base class for all RelaxErrors."""
137
150
151
153 """The base class for all the argument related RelaxErrors."""
154
155
156 simple_types = []
157
158
159 list_types = []
160
161
162 - def __init__(self, name, value, size=None):
163 """A default initialisation and error message formatting method."""
164
165
166 self.text = "The %s argument '%s' must be " % (name, value)
167
168
169 if size != None:
170 for i in range(len(self.list_types)):
171 self.list_types[i] = self.list_types[i] + " of size %s" % repr(size)
172
173
174 all_types = self.simple_types + self.list_types
175
176
177 if len(all_types) > 1:
178 self.text = self.text + "either "
179
180
181 for i in range(len(all_types)):
182
183 if i > 0:
184
185 if i == len(all_types)-1:
186 self.text = self.text + ", or "
187
188
189 else:
190 self.text = self.text + ", "
191
192
193 self.text = self.text + all_types[i]
194
195
196 self.text = self.text + "."
197
198
199
200
201
205
206
207
208
209
212 self.text = "The %s module '%s' cannot be found. Please check that it is installed." % (desc, name)
213
214
215
216
217
220 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/."
221
223
224 save_state()
225
226
227 return ("RelaxError: " + self.text + "\n")
228
229
230
231
232
233
236 if fn_name:
237 self.text = "The %s function has not yet been implemented for the current data pipe." % fn_name
238 else:
239 self.text = "This has not yet been implemented for the current data pipe."
240
241
242
243
244
245
248 self.text = "The program " + repr(name) + " cannot be found."
249
250
251
254 self.text = "The binary executable file " + repr(name) + " does not exist."
255
256
257
260 self.text = "The binary executable file " + repr(name) + " is not executable."
261
262
263
266 self.text = "The binary executable file " + repr(name) + " is not located within the system path."
267
268
269
272 self.text = "Execution of the program " + name + " has failed."
273
274
275
276
277
278
281 if pipe != None:
282 self.text = "PDB data corresponding to the data pipe " + repr(pipe) + " already exists."
283 else:
284 self.text = "PDB data already exists."
285
286
289 if pipe != None:
290 self.text = "No PDB file has been loaded for the data pipe " + repr(pipe) + "."
291 else:
292 self.text = "No PDB file has been loaded."
293
294
297 self.text = "The PDB file " + repr(name) + " could not be loaded properly, no molecular chains could be extracted."
298
299
302 if spin_id != None:
303 self.text = "The multiple unit XH bond vectors for the spin '%s' - this is not supported by the current data pipe type." % spin_id
304 else:
305 self.text = "The multiple unit XH bond vectors per spin - this is not supported by the current data pipe type."
306
307
310 if pipe:
311 self.text = "No unit vectors have been calculated for the data pipe '%s'" % pipe
312 else:
313 self.text = "No unit vectors have been calculated."
314
315
318 self.text = "No peptide or nucleotide chains can be found within the PDB file."
319
320
321
322
323
324
327 if spin_id != None:
328 self.text = "The type of nucleus for the spin '%s' has not yet been set." % spin_id
329 else:
330 self.text = "The type of nucleus has not yet been set."
331
332
335 if spin_id != None:
336 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
337 else:
338 self.text = "The nuclear isotope type has not yet been set. Please use the spin.isotope user function to set the type."
339
340
341
342
343
344
345
346
347
348
351 self.text = "The " + name + " argument " + repr(value) + " is invalid."
352
353
356 self.text = "The " + name + " argument " + repr(value) + " is neither "
357 for i in range(len(list)-1):
358 self.text = self.text + repr(list[i]) + ', '
359 self.text = self.text + 'nor ' + repr(list[-1]) + "."
360
361
364 self.text = "The " + name + " argument must be of length " + repr(len) + "."
365
366
369 self.text = "The " + name + " argument has not been supplied."
370
371
374 self.text = "The %s argument of '%s' must be None."
375
376
377
378
379
380
383
384
387
388
391
394
395
398
401
402
405
408
409
412
415
416
419
422
423
424
425
426
427
430
433
434
437
440
441
442
443
444
445
446
449
453
454
457
460
461
464
465
468
469
473
474
477
481
482
485
489
490
491
492
493
494
498
499
503
504
508
512
513
517
521
522
526
527
531
535
536
540
544
545
549
553
554
555
556
557
558
561
565
566
569
570
571
572
573
574
578
579
583
587
588
589
590
591
592
595
598
599
600
601
602
603
604
607 if pipe == None:
608 self.text = "The sequence data does not exist."
609 else:
610 self.text = "The sequence data for the data pipe " + repr(pipe) + " does not exist."
611
612
615 if pipe == None:
616 self.text = "The sequence data already exists."
617 else:
618 self.text = "The sequence data for the data pipe " + repr(pipe) + " already exists."
619
620
623 self.text = "The sequences for the data pipes " + repr(pipe1) + " and " + repr(pipe2) + " are not the same."
624
625
628 self.text = "The number of molecules do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
629
630
633 self.text = "The number of residues do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
634
635
638 self.text = "The number of spins do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
639
640
643 if id == '':
644 self.text = "The empty molecule ID corresponds to more than a single molecule in the current data pipe."
645 else:
646 self.text = "The molecule ID '%s' corresponds to more than a single molecule in the current data pipe." % id
647
648
651 if id == '':
652 self.text = "The empty residue ID corresponds to more than a single residue in the current data pipe."
653 else:
654 self.text = "The residue ID '%s' corresponds to more than a single residue in the current data pipe." % id
655
656
659 if id_list != None and id == '':
660 self.text = "The empty spin ID corresponds to multiple spins, including %s." % list_to_text(id_list)
661 elif id_list == None and id == '':
662 self.text = "The empty spin ID corresponds to more than a single spin in the current data pipe."
663 elif id_list != None:
664 self.text = "The spin ID '%s' corresponds to multiple spins, including %s." % (id, list_to_text(id_list))
665 else:
666 self.text = "The spin ID '%s' corresponds to more than a single spin in the current data pipe." % id
667
668
671 if name == None:
672 self.text = "The residue '" + repr(number) + "' cannot be found in the sequence."
673 else:
674 self.text = "The residue '" + repr(number) + " " + name + "' cannot be found in the sequence."
675
676
679 if pipe == None:
680 self.text = "The spin '%s' does not exist." % id
681 else:
682 self.text = "The spin '%s' does not exist in the '%s' data pipe." % (id, pipe)
683
684
686 - def __init__(self, line, problem=None):
687 if problem == None:
688 self.text = "The sequence data in the line %s is invalid." % line
689 else:
690 self.text = "The sequence data in the line %s is invalid, %s." % (line, problem)
691
692
695 self.text = "The spin information for the spin " + repr(spin_id) + " has not yet been loaded, please use the structure.load_spins user function."
696
697
698
699
700
701
703 - def __init__(self, spin_id1=None, spin_id2=None, pipe=None):
704 if spin_id1 and pipe:
705 self.text = "The interatomic data between the spins '%s' and '%s' for the data pipe '%s' does not exist." % (spin_id1, spin_id2, pipe)
706 elif spin_id1:
707 self.text = "The interatomic data between the spins '%s' and '%s' does not exist." % (spin_id1, spin_id2)
708 elif pipe:
709 self.text = "The interatomic data for the data pipe '%s' does not exist." % pipe
710 else:
711 self.text = "The interatomic data does not exist."
712
713
716 if pipe == None:
717 self.text = "The interatomic data already exists."
718 else:
719 self.text = "The interatomic data for the data pipe " + repr(pipe) + " already exists."
720
721
724 self.text = "The interatomic data is inconsistent between the data pipes '%s' and '%s'." % (pipe1, pipe2)
725
726
727
728
729
730
731
732 -class RelaxNoDomainError(BaseError):
733 - def __init__(self, id=None):
734 if id == None:
735 self.text = "No domains are defined."
736 else:
737 self.text = "The domain '%s' is not defined." % id
738
739
740
741
742
743
744
746 - def __init__(self, pipe_name=None, id=None):
747 self.text = "No spectrometer frequency information"
748 if id != None:
749 self.text += " for the '%s' experiment ID" % id
750 self.text += " is present"
751 if pipe_name != None:
752 self.text += " in the '%s' data pipe" % pipe_name
753 self.text += "."
754
755
756
757
758
759
760
763 if spectrum_id == None:
764 self.text = "No peak intensity data has been loaded."
765 else:
766 self.text = "Peak intensity data for the '%s' spectrum ID does not exist."
767
768
771 self.text = "Spectral data corresponding to the ID string '%s' does not exist." % spectrum_id
772
773
776 self.text = "Spectral data corresponding to the ID string '%s' already exists." % spectrum_id
777
778
779
780
781
782
785 self.text = "Relaxation data corresponding to the ID string '%s' does not exist." % ri_id
786
787
790 self.text = "Relaxation data corresponding to the ID string '%s' already exists." % ri_id
791
792
793
794
795
796
799 self.text = "No J coupling data exists."
800
801
804 self.text = "J coupling data already exists."
805
806
807
808
809
810
812 - def __init__(self, align_id, pipe=None):
813 if pipe != None:
814 self.text = "The alignment ID string '%s' is missing from the data pipe '%s'." % (align_id, pipe)
815 else:
816 self.text = "The alignment ID string '%s' is missing." % align_id
817
818
821 self.text = "Alignment data corresponding to the ID string '%s' already exists." % align_id
822
823
826 if id:
827 self.text = "RDC data corresponding to the identification string " + repr(id) + " does not exist."
828 else:
829 self.text = "No RDC data exists."
830
831
834 self.text = "RDC data corresponding to the identification string " + repr(id) + " already exists."
835
836
839 if id:
840 self.text = "PCS data corresponding to the identification string " + repr(id) + " does not exist."
841 else:
842 self.text = "No PCS data exists."
843
844
847 self.text = "PCS data corresponding to the identification string " + repr(id) + " already exists."
848
849
850
851
852
853
856 self.text = "Model-free data corresponding to the data pipe " + repr(pipe) + " already exists."
857
858
859
860
861
862
865 self.text = "The " + tensor_type + " tensor data already exists."
866
867
869 - def __init__(self, tensor_type, tensor_label=None):
870 if not tensor_label:
871 self.text = "No " + tensor_type + " tensor data exists."
872 else:
873 self.text = "No " + tensor_type + " tensor data exists for the tensor " + repr(tensor_label) + "."
874
875
876
877
878
879
882 if name == None:
883 self.text = "The directory " + repr(dir) + " does not exist."
884 else:
885 self.text = "The " + name + " directory " + repr(dir) + " does not exist."
886
887
889 - def __init__(self, name, file_name=None):
890 if file_name == None:
891 self.text = "The file " + repr(name) + " does not exist."
892 else:
893 self.text = "The " + name + " file " + repr(file_name) + " does not exist."
894
895
898 self.text = "The file contains no data."
899
900
903 self.text = "The file " + repr(file_name) + " already exists. Set the " + flag + " to True to overwrite."
904
905
908 self.text = "The format of the data is invalid."
909
910
911
912
913
914
917 self.text = "The data pipe bundle '%s' already exists." % bundle
918
919
922 if bundle != None:
923 self.text = "The data pipe bundle '%s' has not been created yet." % bundle
924 else:
925 self.text = "No data pipe bundles currently exist. Please use the pipe.bundle user function first."
926
927
930 self.text = "The data pipe " + repr(pipe) + " already exists."
931
932
935 if pipe != None:
936 self.text = "The data pipe " + repr(pipe) + " has not been created yet."
937 else:
938 self.text = "No data pipes currently exist. Please use the pipe.create user function first."
939
940
941
942
943
944
947 self.text = "The selection of molecules is not allowed."
948
949
952 self.text = "The selection of residues is not allowed."
953
954
957 self.text = "The selection of spin systems is not allowed."
958
959
962 self.text = "The spin system must be specified."
963
964
965
966
967
968
969
972 self.text = "This function is not available for " + string + "."
973
974
977 if name != None:
978 self.text = "The " + name + " model already exists."
979 else:
980 self.text = "The model already exists."
981
982
983
986 if name != None:
987 self.text = "The specific " + name + " model has not been selected or set up."
988 else:
989 self.text = "The specific model has not been selected or set up."
990
991
992
993
994
995
998 self.text = "The " + name + " argument " + repr(value) + " is not valid regular expression."
999
1000
1001
1002
1003
1004
1006 - def __init__(self, name, param_type=None):
1007 if param_type != None:
1008 self.text = "The " + name + " parameter, " + repr(param_type) + ", cannot be set."
1009 else:
1010 self.text = "The " + name + " parameter cannot be set."
1011
1012
1014 - def __init__(self, data_type, pipe=None):
1015 if pipe != None:
1016 self.text = "The data type " + repr(data_type) + " already exists for the data pipe " + repr(pipe) + "."
1017 else:
1018 self.text = "The data type " + repr(data_type) + " already exists."
1019
1020
1022 - def __init__(self, name, spin_id=None, spin_id2=None):
1023 if spin_id2 != None:
1024 self.text = "The %s value has not yet been set for spins '%s' and '%s'." % (name, spin_id, spin_id2)
1025 elif spin_id != None:
1026 self.text = "The %s value has not yet been set for spin '%s'." % (name, spin_id)
1027 else:
1028 self.text = "The " + repr(name) + " value has not yet been set."
1029
1030
1033 self.text = "The data type " + repr(name) + " is unknown."
1034
1035
1037 - def __init__(self, name, param_type=None):
1038 if param_type != None:
1039 self.text = "The " + name + " parameter, " + repr(param_type) + ", is unknown."
1040 else:
1041 self.text = "The " + name + " parameter is unknown."
1042
1043
1046 self.text = "The " + repr(name) + " argument " + repr(data) + " represents an unknown parameter combination."
1047
1048
1049
1050
1051
1052
1055 if pipe:
1056 self.text = "Simulations for the data pipe " + repr(pipe) + " have not been setup."
1057 else:
1058 self.text = "Simulations have not been setup."
1059
1060
1061
1062
1063
1064
1067 self.text = "The style " + repr(style) + " is unknown."
1068
1069
1070
1071
1072
1073
1076 self.text = "The colour " + repr(colour) + " is invalid."
1077
1078
1079
1080
1081
1082
1085 self.text = "The invalid " + name + " floating point value of infinity has occurred."
1086
1087
1090 self.text = "The invalid " + name + " floating point value of NaN (Not a Number) has occurred."
1091
1092
1093
1094
1095
1096
1099 self.text = "The " + name + " data structure cannot be recreated from the XML elements as the structure is not empty."
1100
1101
1102
1103
1104
1105
1106
1127
1128
1129 AllRelaxErrors = tuple(all_errors(dir()))
1130