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 from re import match
33 import sys
34 import time
35
36
37 from compat import pickle
38 from lib import ansi
39
40
41
42 BIN = 'a binary number (0 or 1)'
43 BOOL = 'a Boolean (True or False)'
44 INT = 'an integer'
45 FILE = 'a file object'
46 FLOAT = 'a floating point number'
47 FUNC = 'a function'
48 LIST = 'a list'
49 LIST_FLOAT = 'a list of floating point numbers'
50 LIST_INT = 'a list of integers'
51 LIST_NUM = 'a list of numbers'
52 LIST_STR = 'a list of strings'
53 LIST_VAL = 'a list of values'
54 MATRIX_FLOAT = 'a matrix of floating point numbers'
55 NONE = 'None'
56 NUM = 'a number'
57 TUPLE = 'a tuple'
58 TUPLE_FLOAT = 'a tuple of floating point numbers'
59 TUPLE_INT = 'a tuple of integers'
60 TUPLE_NUM = 'a tuple of numbers'
61 TUPLE_STR = 'a tuple of strings'
62 STR = 'a string'
63 VAL = 'a value'
64
65
67 """Save the program state, for debugging purposes."""
68
69
70 try:
71 from data_store import Relax_data_store; ds = Relax_data_store()
72
73
74 except ImportError:
75 return
76
77
78 now = time.localtime()
79 file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[1], now[2], now[3], now[4], now[5])
80
81
82 if bz2:
83 sys.stderr.write("\n\nStoring the relax state in the file '%s.bz2'.\n\n\n" % file_name)
84 file = BZ2File(file_name+'.bz2', 'w')
85 else:
86 sys.stderr.write("\n\nStoring the relax state in the file '%s'.\n\n\n" % file_name)
87 file = open(file_name, 'w')
88
89
90 pickle.dump(ds, file, 1)
91
92
93 file.close()
94
95
96 -def list_to_text(data):
97 """Convert the given Python list to a text representation.
98
99 @param data: The list of Python objects.
100 @type data: list
101 @return: The English text version of the list.
102 @rtype: str
103 """
104
105
106 text = ''
107
108
109 for i in range(len(data)):
110
111 text += repr(data[i])
112
113
114 if i < len(data) - 2:
115 text += ', '
116
117
118 if i == len(data) - 2:
119 text += ' and '
120
121
122 return text
123
124
125
126
127
129 """The base class for all RelaxErrors."""
130
144
145
147 """The base class for all the argument related RelaxErrors."""
148
149
150 simple_types = []
151
152
153 list_types = []
154
155
156 - def __init__(self, name, value, size=None):
157 """A default initialisation and error message formatting method."""
158
159
160 self.text = "The %s argument '%s' must be " % (name, value)
161
162
163 if size != None:
164 for i in range(len(self.list_types)):
165 self.list_types[i] = self.list_types[i] + " of size %s" % repr(size)
166
167
168 all_types = self.simple_types + self.list_types
169
170
171 if len(all_types) > 1:
172 self.text = self.text + "either "
173
174
175 for i in range(len(all_types)):
176
177 if i > 0:
178
179 if i == len(all_types)-1:
180 self.text = self.text + ", or "
181
182
183 else:
184 self.text = self.text + ", "
185
186
187 self.text = self.text + all_types[i]
188
189
190 self.text = self.text + "."
191
192
193
194
195
199
200
201
202
203
206 self.text = "The %s module '%s' cannot be found. Please check that it is installed." % (desc, name)
207
208
209
210
211
214 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/."
215
217
218 save_state()
219
220
221 return ("RelaxError: " + self.text + "\n")
222
223
224
225
226
227
230 if fn_name:
231 self.text = "The %s function has not yet been implemented for the current data pipe." % fn_name
232 else:
233 self.text = "This has not yet been implemented for the current data pipe."
234
235
236
237
238
239
242 self.text = "The program " + repr(name) + " cannot be found."
243
244
245
248 self.text = "The binary executable file " + repr(name) + " does not exist."
249
250
251
254 self.text = "The binary executable file " + repr(name) + " is not executable."
255
256
257
260 self.text = "The binary executable file " + repr(name) + " is not located within the system path."
261
262
263
266 self.text = "Execution of the program " + name + " has failed."
267
268
269
270
271
272
275 if pipe != None:
276 self.text = "PDB data corresponding to the data pipe " + repr(pipe) + " already exists."
277 else:
278 self.text = "PDB data already exists."
279
280
283 if pipe != None:
284 self.text = "No PDB file has been loaded for the data pipe " + repr(pipe) + "."
285 else:
286 self.text = "No PDB file has been loaded."
287
288
291 self.text = "The PDB file " + repr(name) + " could not be loaded properly, no molecular chains could be extracted."
292
293
296 if spin_id != None:
297 self.text = "The multiple unit XH bond vectors for the spin '%s' - this is not supported by the current data pipe type." % spin_id
298 else:
299 self.text = "The multiple unit XH bond vectors per spin - this is not supported by the current data pipe type."
300
301
304 if pipe:
305 self.text = "No unit vectors have been calculated for the data pipe '%s'" % pipe
306 else:
307 self.text = "No unit vectors have been calculated."
308
309
312 self.text = "No peptide or nucleotide chains can be found within the PDB file."
313
314
315
316
317
318
321 if spin_id != None:
322 self.text = "The type of nucleus for the spin '%s' has not yet been set." % spin_id
323 else:
324 self.text = "The type of nucleus has not yet been set."
325
326
329 if spin_id != None:
330 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
331 else:
332 self.text = "The nuclear isotope type has not yet been set. Please use the spin.isotope user function to set the type."
333
334
335
336
337
338
339
340
341
342
345 self.text = "The " + name + " argument " + repr(value) + " is invalid."
346
347
350 self.text = "The " + name + " argument " + repr(value) + " is neither "
351 for i in range(len(list)-1):
352 self.text = self.text + repr(list[i]) + ', '
353 self.text = self.text + 'nor ' + repr(list[-1]) + "."
354
355
358 self.text = "The " + name + " argument must be of length " + repr(len) + "."
359
360
363 self.text = "The " + name + " argument has not been supplied."
364
365
368 self.text = "The %s argument of '%s' must be None."
369
370
371
372
373
374
377
378
381
382
385
388
389
392
395
396
399
402
403
406
409
410
413
416
417
418
419
420
421
424
427
428
431
434
435
436
437
438
439
440
443
447
448
451
454
455
458
459
462
463
467
468
471
475
476
479
483
484
485
486
487
488
492
493
497
498
502
506
507
511
515
516
520
521
525
529
530
534
538
539
543
547
548
549
550
551
552
555
559
560
563
564
565
566
567
568
572
573
577
581
582
583
584
585
586
589
592
593
594
595
596
597
598
601 if pipe == None:
602 self.text = "The sequence data does not exist."
603 else:
604 self.text = "The sequence data for the data pipe " + repr(pipe) + " does not exist."
605
606
609 if pipe == None:
610 self.text = "The sequence data already exists."
611 else:
612 self.text = "The sequence data for the data pipe " + repr(pipe) + " already exists."
613
614
617 self.text = "The sequences for the data pipes " + repr(pipe1) + " and " + repr(pipe2) + " are not the same."
618
619
622 self.text = "The number of molecules do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
623
624
627 self.text = "The number of residues do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
628
629
632 self.text = "The number of spins do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
633
634
637 if id == '':
638 self.text = "The empty molecule ID corresponds to more than a single molecule in the current data pipe."
639 else:
640 self.text = "The molecule ID '%s' corresponds to more than a single molecule in the current data pipe." % id
641
642
645 if id == '':
646 self.text = "The empty residue ID corresponds to more than a single residue in the current data pipe."
647 else:
648 self.text = "The residue ID '%s' corresponds to more than a single residue in the current data pipe." % id
649
650
653 if id_list != None and id == '':
654 self.text = "The empty spin ID corresponds to multiple spins, including %s." % list_to_text(id_list)
655 elif id_list == None and id == '':
656 self.text = "The empty spin ID corresponds to more than a single spin in the current data pipe."
657 elif id_list != None:
658 self.text = "The spin ID '%s' corresponds to multiple spins, including %s." % (id, list_to_text(id_list))
659 else:
660 self.text = "The spin ID '%s' corresponds to more than a single spin in the current data pipe." % id
661
662
665 if name == None:
666 self.text = "The residue '" + repr(number) + "' cannot be found in the sequence."
667 else:
668 self.text = "The residue '" + repr(number) + " " + name + "' cannot be found in the sequence."
669
670
673 if pipe == None:
674 self.text = "The spin '%s' does not exist." % id
675 else:
676 self.text = "The spin '%s' does not exist in the '%s' data pipe." % (id, pipe)
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
718 self.text = "The interatomic data is inconsistent between the data pipes '%s' and '%s'." % (pipe1, pipe2)
719
720
721
722
723
724
725
726 -class RelaxNoDomainError(BaseError):
727 - def __init__(self, id=None):
728 if id == None:
729 self.text = "No domains are defined."
730 else:
731 self.text = "The domain '%s' is not defined." % id
732
733
734
735
736
737
738
740 - def __init__(self, pipe_name=None, id=None):
741 self.text = "No spectrometer frequency information"
742 if id != None:
743 self.text += " for the '%s' experiment ID" % id
744 self.text += " is present"
745 if pipe_name != None:
746 self.text += " in the '%s' data pipe" % pipe_name
747 self.text += "."
748
749
750
751
752
753
754
757 if spectrum_id == None:
758 self.text = "No peak intensity data has been loaded."
759 else:
760 self.text = "Peak intensity data for the '%s' spectrum ID does not exist."
761
762
765 self.text = "Spectral data corresponding to the ID string '%s' does not exist." % spectrum_id
766
767
770 self.text = "Spectral data corresponding to the ID string '%s' already exists." % spectrum_id
771
772
773
774
775
776
779 self.text = "Relaxation data corresponding to the ID string '%s' does not exist." % ri_id
780
781
784 self.text = "Relaxation data corresponding to the ID string '%s' already exists." % ri_id
785
786
787
788
789
790
793 self.text = "No J coupling data exists."
794
795
798 self.text = "J coupling data already exists."
799
800
801
802
803
804
806 - def __init__(self, align_id, pipe=None):
807 if pipe != None:
808 self.text = "The alignment ID string '%s' is missing from the data pipe '%s'." % (align_id, pipe)
809 else:
810 self.text = "The alignment ID string '%s' is missing." % align_id
811
812
815 self.text = "Alignment data corresponding to the ID string '%s' already exists." % align_id
816
817
820 if id:
821 self.text = "RDC data corresponding to the identification string " + repr(id) + " does not exist."
822 else:
823 self.text = "No RDC data exists."
824
825
828 self.text = "RDC data corresponding to the identification string " + repr(id) + " already exists."
829
830
833 if id:
834 self.text = "PCS data corresponding to the identification string " + repr(id) + " does not exist."
835 else:
836 self.text = "No PCS data exists."
837
838
841 self.text = "PCS data corresponding to the identification string " + repr(id) + " already exists."
842
843
844
845
846
847
850 self.text = "Model-free data corresponding to the data pipe " + repr(pipe) + " already exists."
851
852
853
854
855
856
859 self.text = "The " + tensor_type + " tensor data already exists."
860
861
863 - def __init__(self, tensor_type, tensor_label=None):
864 if not tensor_label:
865 self.text = "No " + tensor_type + " tensor data exists."
866 else:
867 self.text = "No " + tensor_type + " tensor data exists for the tensor " + repr(tensor_label) + "."
868
869
870
871
872
873
876 if name == None:
877 self.text = "The directory " + repr(dir) + " does not exist."
878 else:
879 self.text = "The " + name + " directory " + repr(dir) + " does not exist."
880
881
883 - def __init__(self, name, file_name=None):
884 if file_name == None:
885 self.text = "The file " + repr(name) + " does not exist."
886 else:
887 self.text = "The " + name + " file " + repr(file_name) + " does not exist."
888
889
892 self.text = "The file contains no data."
893
894
897 self.text = "The file " + repr(file_name) + " already exists. Set the " + flag + " to True to overwrite."
898
899
902 self.text = "The format of the data is invalid."
903
904
905
906
907
908
911 self.text = "The data pipe bundle '%s' already exists." % bundle
912
913
916 if bundle != None:
917 self.text = "The data pipe bundle '%s' has not been created yet." % bundle
918 else:
919 self.text = "No data pipe bundles currently exist. Please use the pipe.bundle user function first."
920
921
924 self.text = "The data pipe " + repr(pipe) + " already exists."
925
926
929 if pipe != None:
930 self.text = "The data pipe " + repr(pipe) + " has not been created yet."
931 else:
932 self.text = "No data pipes currently exist. Please use the pipe.create user function first."
933
934
935
936
937
938
941 self.text = "The selection of molecules is not allowed."
942
943
946 self.text = "The selection of residues is not allowed."
947
948
951 self.text = "The selection of spin systems is not allowed."
952
953
956 self.text = "The spin system must be specified."
957
958
959
960
961
962
963
966 self.text = "This function is not available for " + string + "."
967
968
971 if name != None:
972 self.text = "The " + name + " model already exists."
973 else:
974 self.text = "The model already exists."
975
976
977
980 if name != None:
981 self.text = "The specific " + name + " model has not been selected or set up."
982 else:
983 self.text = "The specific model has not been selected or set up."
984
985
986
987
988
989
992 self.text = "The " + name + " argument " + repr(value) + " is not valid regular expression."
993
994
995
996
997
998
1000 - def __init__(self, name, param_type=None):
1001 if param_type != None:
1002 self.text = "The " + name + " parameter, " + repr(param_type) + ", cannot be set."
1003 else:
1004 self.text = "The " + name + " parameter cannot be set."
1005
1006
1008 - def __init__(self, data_type, pipe=None):
1009 if pipe != None:
1010 self.text = "The data type " + repr(data_type) + " already exists for the data pipe " + repr(pipe) + "."
1011 else:
1012 self.text = "The data type " + repr(data_type) + " already exists."
1013
1014
1016 - def __init__(self, name, spin_id=None, spin_id2=None):
1017 if spin_id2 != None:
1018 self.text = "The %s value has not yet been set for spins '%s' and '%s'." % (name, spin_id, spin_id2)
1019 elif spin_id != None:
1020 self.text = "The %s value has not yet been set for spin '%s'." % (name, spin_id)
1021 else:
1022 self.text = "The " + repr(name) + " value has not yet been set."
1023
1024
1027 self.text = "The data type " + repr(name) + " is unknown."
1028
1029
1031 - def __init__(self, name, param_type=None):
1032 if param_type != None:
1033 self.text = "The " + name + " parameter, " + repr(param_type) + ", is unknown."
1034 else:
1035 self.text = "The " + name + " parameter is unknown."
1036
1037
1040 self.text = "The " + repr(name) + " argument " + repr(data) + " represents an unknown parameter combination."
1041
1042
1043
1044
1045
1046
1049 if pipe:
1050 self.text = "Simulations for the data pipe " + repr(pipe) + " have not been setup."
1051 else:
1052 self.text = "Simulations have not been setup."
1053
1054
1055
1056
1057
1058
1061 self.text = "The style " + repr(style) + " is unknown."
1062
1063
1064
1065
1066
1067
1070 self.text = "The colour " + repr(colour) + " is invalid."
1071
1072
1073
1074
1075
1076
1079 self.text = "The invalid " + name + " floating point value of infinity has occurred."
1080
1081
1084 self.text = "The invalid " + name + " floating point value of NaN (Not a Number) has occurred."
1085
1086
1087
1088
1089
1090
1093 self.text = "The " + name + " data structure cannot be recreated from the XML elements as the structure is not empty."
1094
1095
1096
1097
1098
1099
1100
1121
1122
1123 AllRelaxErrors = tuple(all_errors(dir()))
1124