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
37
38 from compat import pickle
39 from lib import ansi
40
41
42
43 BIN = 'a binary number (0 or 1)'
44 BOOL = 'a Boolean (True or False)'
45 INT = 'an integer'
46 FILE = 'a file object'
47 FLOAT = 'a floating point number'
48 FUNC = 'a function'
49 LIST = 'a list'
50 LIST_FLOAT = 'a list of floating point numbers'
51 LIST_INT = 'a list of integers'
52 LIST_NUM = 'a list of numbers'
53 LIST_STR = 'a list of strings'
54 LIST_VAL = 'a list of values'
55 MATRIX_FLOAT = 'a matrix of floating point numbers'
56 NONE = 'None'
57 NUM = 'a number'
58 TUPLE = 'a tuple'
59 TUPLE_FLOAT = 'a tuple of floating point numbers'
60 TUPLE_INT = 'a tuple of integers'
61 TUPLE_NUM = 'a tuple of numbers'
62 TUPLE_STR = 'a tuple of strings'
63 STR = 'a string'
64 VAL = 'a value'
65
66
68 """Save the program state, for debugging purposes."""
69
70
71 try:
72 from data_store import Relax_data_store; ds = Relax_data_store()
73
74
75 except ImportError:
76 return
77
78
79 now = time.localtime()
80 file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[1], now[2], now[3], now[4], now[5])
81
82
83 if bz2:
84 sys.stderr.write("\n\nStoring the relax state in the file '%s.bz2'.\n\n\n" % file_name)
85 file = BZ2File(file_name+'.bz2', 'w')
86 else:
87 sys.stderr.write("\n\nStoring the relax state in the file '%s'.\n\n\n" % file_name)
88 file = open(file_name, 'w')
89
90
91 pickle.dump(ds, file, 1)
92
93
94 file.close()
95
96
97 -def list_to_text(data):
98 """Convert the given Python list to a text representation.
99
100 @param data: The list of Python objects.
101 @type data: list
102 @return: The English text version of the list.
103 @rtype: str
104 """
105
106
107 text = ''
108
109
110 for i in range(len(data)):
111
112 text += repr(data[i])
113
114
115 if i < len(data) - 2:
116 text += ', '
117
118
119 if i == len(data) - 2:
120 text += ' and '
121
122
123 return text
124
125
126
127
128
130 """The base class for all RelaxErrors."""
131
145
146
148 """The base class for all the argument related RelaxErrors."""
149
150
151 simple_types = []
152
153
154 list_types = []
155
156
157 - def __init__(self, name, value, size=None):
158 """A default initialisation and error message formatting method."""
159
160
161 self.text = "The %s argument '%s' must be " % (name, value)
162
163
164 if size != None:
165 for i in range(len(self.list_types)):
166 self.list_types[i] = self.list_types[i] + " of size %s" % repr(size)
167
168
169 all_types = self.simple_types + self.list_types
170
171
172 if len(all_types) > 1:
173 self.text = self.text + "either "
174
175
176 for i in range(len(all_types)):
177
178 if i > 0:
179
180 if i == len(all_types)-1:
181 self.text = self.text + ", or "
182
183
184 else:
185 self.text = self.text + ", "
186
187
188 self.text = self.text + all_types[i]
189
190
191 self.text = self.text + "."
192
193
194
195
196
200
201
202
203
204
207 self.text = "The %s module '%s' cannot be found. Please check that it is installed." % (desc, name)
208
209
210
211
212
215 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/."
216
218
219 save_state()
220
221
222 return ("RelaxError: " + self.text + "\n")
223
224
225
226
227
228
231 if fn_name:
232 self.text = "The %s function has not yet been implemented for the current data pipe." % fn_name
233 else:
234 self.text = "This has not yet been implemented for the current data pipe."
235
236
237
238
239
240
243 self.text = "The program " + repr(name) + " cannot be found."
244
245
246
249 self.text = "The binary executable file " + repr(name) + " does not exist."
250
251
252
255 self.text = "The binary executable file " + repr(name) + " is not executable."
256
257
258
261 self.text = "The binary executable file " + repr(name) + " is not located within the system path."
262
263
264
267 self.text = "Execution of the program " + name + " has failed."
268
269
270
271
272
273
276 if pipe != None:
277 self.text = "PDB data corresponding to the data pipe " + repr(pipe) + " already exists."
278 else:
279 self.text = "PDB data already exists."
280
281
284 if pipe != None:
285 self.text = "No PDB file has been loaded for the data pipe " + repr(pipe) + "."
286 else:
287 self.text = "No PDB file has been loaded."
288
289
292 self.text = "The PDB file " + repr(name) + " could not be loaded properly, no molecular chains could be extracted."
293
294
297 if spin_id != None:
298 self.text = "The multiple unit XH bond vectors for the spin '%s' - this is not supported by the current data pipe type." % spin_id
299 else:
300 self.text = "The multiple unit XH bond vectors per spin - this is not supported by the current data pipe type."
301
302
305 if pipe:
306 self.text = "No unit vectors have been calculated for the data pipe '%s'" % pipe
307 else:
308 self.text = "No unit vectors have been calculated."
309
310
313 self.text = "No peptide or nucleotide chains can be found within the PDB file."
314
315
316
317
318
319
322 if spin_id != None:
323 self.text = "The type of nucleus for the spin '%s' has not yet been set." % spin_id
324 else:
325 self.text = "The type of nucleus has not yet been set."
326
327
330 if spin_id != None:
331 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
332 else:
333 self.text = "The nuclear isotope type has not yet been set. Please use the spin.isotope user function to set the type."
334
335
336
337
338
339
340
341
342
343
346 self.text = "The " + name + " argument " + repr(value) + " is invalid."
347
348
351 self.text = "The " + name + " argument " + repr(value) + " is neither "
352 for i in range(len(list)-1):
353 self.text = self.text + repr(list[i]) + ', '
354 self.text = self.text + 'nor ' + repr(list[-1]) + "."
355
356
359 self.text = "The " + name + " argument must be of length " + repr(len) + "."
360
361
364 self.text = "The " + name + " argument has not been supplied."
365
366
369 self.text = "The %s argument of '%s' must be None."
370
371
372
373
374
375
378
379
382
383
386
389
390
393
396
397
400
403
404
407
410
411
414
417
418
419
420
421
422
425
428
429
432
435
436
437
438
439
440
441
444
448
449
452
455
456
459
460
463
464
468
469
472
476
477
480
484
485
486
487
488
489
493
494
498
499
503
507
508
512
516
517
521
522
526
530
531
535
539
540
544
548
549
550
551
552
553
556
560
561
564
565
566
567
568
569
573
574
578
582
583
584
585
586
587
590
593
594
595
596
597
598
599
602 if pipe == None:
603 self.text = "The sequence data does not exist."
604 else:
605 self.text = "The sequence data for the data pipe " + repr(pipe) + " does not exist."
606
607
610 if pipe == None:
611 self.text = "The sequence data already exists."
612 else:
613 self.text = "The sequence data for the data pipe " + repr(pipe) + " already exists."
614
615
618 self.text = "The sequences for the data pipes " + repr(pipe1) + " and " + repr(pipe2) + " are not the same."
619
620
623 self.text = "The number of molecules do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
624
625
628 self.text = "The number of residues do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
629
630
633 self.text = "The number of spins do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
634
635
638 if id == '':
639 self.text = "The empty molecule ID corresponds to more than a single molecule in the current data pipe."
640 else:
641 self.text = "The molecule ID '%s' corresponds to more than a single molecule in the current data pipe." % id
642
643
646 if id == '':
647 self.text = "The empty residue ID corresponds to more than a single residue in the current data pipe."
648 else:
649 self.text = "The residue ID '%s' corresponds to more than a single residue in the current data pipe." % id
650
651
654 if id_list != None and id == '':
655 self.text = "The empty spin ID corresponds to multiple spins, including %s." % list_to_text(id_list)
656 elif id_list == None and id == '':
657 self.text = "The empty spin ID corresponds to more than a single spin in the current data pipe."
658 elif id_list != None:
659 self.text = "The spin ID '%s' corresponds to multiple spins, including %s." % (id, list_to_text(id_list))
660 else:
661 self.text = "The spin ID '%s' corresponds to more than a single spin in the current data pipe." % id
662
663
666 if name == None:
667 self.text = "The residue '" + repr(number) + "' cannot be found in the sequence."
668 else:
669 self.text = "The residue '" + repr(number) + " " + name + "' cannot be found in the sequence."
670
671
674 if pipe == None:
675 self.text = "The spin '%s' does not exist." % id
676 else:
677 self.text = "The spin '%s' does not exist in the '%s' data pipe." % (id, pipe)
678
679
681 - def __init__(self, line, problem=None):
682 if problem == None:
683 self.text = "The sequence data in the line %s is invalid." % line
684 else:
685 self.text = "The sequence data in the line %s is invalid, %s." % (line, problem)
686
687
690 self.text = "The spin information for the spin " + repr(spin_id) + " has not yet been loaded, please use the structure.load_spins user function."
691
692
693
694
695
696
698 - def __init__(self, spin_id1=None, spin_id2=None, pipe=None):
699 if spin_id1 and pipe:
700 self.text = "The interatomic data between the spins '%s' and '%s' for the data pipe '%s' does not exist." % (spin_id1, spin_id2, pipe)
701 elif spin_id1:
702 self.text = "The interatomic data between the spins '%s' and '%s' does not exist." % (spin_id1, spin_id2)
703 elif pipe:
704 self.text = "The interatomic data for the data pipe '%s' does not exist." % pipe
705 else:
706 self.text = "The interatomic data does not exist."
707
708
711 if pipe == None:
712 self.text = "The interatomic data already exists."
713 else:
714 self.text = "The interatomic data for the data pipe " + repr(pipe) + " already exists."
715
716
719 self.text = "The interatomic data is inconsistent between the data pipes '%s' and '%s'." % (pipe1, pipe2)
720
721
722
723
724
725
726
727 -class RelaxNoDomainError(BaseError):
728 - def __init__(self, id=None):
729 if id == None:
730 self.text = "No domains are defined."
731 else:
732 self.text = "The domain '%s' is not defined." % id
733
734
735
736
737
738
739
741 - def __init__(self, pipe_name=None, id=None):
742 self.text = "No spectrometer frequency information"
743 if id != None:
744 self.text += " for the '%s' experiment ID" % id
745 self.text += " is present"
746 if pipe_name != None:
747 self.text += " in the '%s' data pipe" % pipe_name
748 self.text += "."
749
750
751
752
753
754
755
758 if spectrum_id == None:
759 self.text = "No peak intensity data has been loaded."
760 else:
761 self.text = "Peak intensity data for the '%s' spectrum ID does not exist."
762
763
766 self.text = "Spectral data corresponding to the ID string '%s' does not exist." % spectrum_id
767
768
771 self.text = "Spectral data corresponding to the ID string '%s' already exists." % spectrum_id
772
773
774
775
776
777
780 self.text = "Relaxation data corresponding to the ID string '%s' does not exist." % ri_id
781
782
785 self.text = "Relaxation data corresponding to the ID string '%s' already exists." % ri_id
786
787
788
789
790
791
794 self.text = "No J coupling data exists."
795
796
799 self.text = "J coupling data already exists."
800
801
802
803
804
805
807 - def __init__(self, align_id, pipe=None):
808 if pipe != None:
809 self.text = "The alignment ID string '%s' is missing from the data pipe '%s'." % (align_id, pipe)
810 else:
811 self.text = "The alignment ID string '%s' is missing." % align_id
812
813
816 self.text = "Alignment data corresponding to the ID string '%s' already exists." % align_id
817
818
821 if id:
822 self.text = "RDC data corresponding to the identification string " + repr(id) + " does not exist."
823 else:
824 self.text = "No RDC data exists."
825
826
829 self.text = "RDC data corresponding to the identification string " + repr(id) + " already exists."
830
831
834 if id:
835 self.text = "PCS data corresponding to the identification string " + repr(id) + " does not exist."
836 else:
837 self.text = "No PCS data exists."
838
839
842 self.text = "PCS data corresponding to the identification string " + repr(id) + " already exists."
843
844
845
846
847
848
851 self.text = "Model-free data corresponding to the data pipe " + repr(pipe) + " already exists."
852
853
854
855
856
857
860 self.text = "The " + tensor_type + " tensor data already exists."
861
862
864 - def __init__(self, tensor_type, tensor_label=None):
865 if not tensor_label:
866 self.text = "No " + tensor_type + " tensor data exists."
867 else:
868 self.text = "No " + tensor_type + " tensor data exists for the tensor " + repr(tensor_label) + "."
869
870
871
872
873
874
877 if name == None:
878 self.text = "The directory " + repr(dir) + " does not exist."
879 else:
880 self.text = "The " + name + " directory " + repr(dir) + " does not exist."
881
882
884 - def __init__(self, name, file_name=None):
885 if file_name == None:
886 self.text = "The file " + repr(name) + " does not exist."
887 else:
888 self.text = "The " + name + " file " + repr(file_name) + " does not exist."
889
890
893 self.text = "The file contains no data."
894
895
898 self.text = "The file " + repr(file_name) + " already exists. Set the " + flag + " to True to overwrite."
899
900
903 self.text = "The format of the data is invalid."
904
905
906
907
908
909
912 self.text = "The data pipe bundle '%s' already exists." % bundle
913
914
917 if bundle != None:
918 self.text = "The data pipe bundle '%s' has not been created yet." % bundle
919 else:
920 self.text = "No data pipe bundles currently exist. Please use the pipe.bundle user function first."
921
922
925 self.text = "The data pipe " + repr(pipe) + " already exists."
926
927
930 if pipe != None:
931 self.text = "The data pipe " + repr(pipe) + " has not been created yet."
932 else:
933 self.text = "No data pipes currently exist. Please use the pipe.create user function first."
934
935
936
937
938
939
942 self.text = "The selection of molecules is not allowed."
943
944
947 self.text = "The selection of residues is not allowed."
948
949
952 self.text = "The selection of spin systems is not allowed."
953
954
957 self.text = "The spin system must be specified."
958
959
960
961
962
963
964
967 self.text = "This function is not available for " + string + "."
968
969
972 if name != None:
973 self.text = "The " + name + " model already exists."
974 else:
975 self.text = "The model already exists."
976
977
978
981 if name != None:
982 self.text = "The specific " + name + " model has not been selected or set up."
983 else:
984 self.text = "The specific model has not been selected or set up."
985
986
987
988
989
990
993 self.text = "The " + name + " argument " + repr(value) + " is not valid regular expression."
994
995
996
997
998
999
1001 - def __init__(self, name, param_type=None):
1002 if param_type != None:
1003 self.text = "The " + name + " parameter, " + repr(param_type) + ", cannot be set."
1004 else:
1005 self.text = "The " + name + " parameter cannot be set."
1006
1007
1009 - def __init__(self, data_type, pipe=None):
1010 if pipe != None:
1011 self.text = "The data type " + repr(data_type) + " already exists for the data pipe " + repr(pipe) + "."
1012 else:
1013 self.text = "The data type " + repr(data_type) + " already exists."
1014
1015
1017 - def __init__(self, name, spin_id=None, spin_id2=None):
1018 if spin_id2 != None:
1019 self.text = "The %s value has not yet been set for spins '%s' and '%s'." % (name, spin_id, spin_id2)
1020 elif spin_id != None:
1021 self.text = "The %s value has not yet been set for spin '%s'." % (name, spin_id)
1022 else:
1023 self.text = "The " + repr(name) + " value has not yet been set."
1024
1025
1028 self.text = "The data type " + repr(name) + " is unknown."
1029
1030
1032 - def __init__(self, name, param_type=None):
1033 if param_type != None:
1034 self.text = "The " + name + " parameter, " + repr(param_type) + ", is unknown."
1035 else:
1036 self.text = "The " + name + " parameter is unknown."
1037
1038
1041 self.text = "The " + repr(name) + " argument " + repr(data) + " represents an unknown parameter combination."
1042
1043
1044
1045
1046
1047
1050 if pipe:
1051 self.text = "Simulations for the data pipe " + repr(pipe) + " have not been setup."
1052 else:
1053 self.text = "Simulations have not been setup."
1054
1055
1056
1057
1058
1059
1062 self.text = "The style " + repr(style) + " is unknown."
1063
1064
1065
1066
1067
1068
1071 self.text = "The colour " + repr(colour) + " is invalid."
1072
1073
1074
1075
1076
1077
1080 self.text = "The invalid " + name + " floating point value of infinity has occurred."
1081
1082
1085 self.text = "The invalid " + name + " floating point value of NaN (Not a Number) has occurred."
1086
1087
1088
1089
1090
1091
1094 self.text = "The " + name + " data structure cannot be recreated from the XML elements as the structure is not empty."
1095
1096
1097
1098
1099
1100
1101
1122
1123
1124 AllRelaxErrors = tuple(all_errors(dir()))
1125