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 lib import ansi
39 from lib.compat import pickle
40
41
42
43 SAVE_ERROR_STATE = False
44
45
46 BIN = 'a binary number (0 or 1)'
47 BOOL = 'a Boolean (True or False)'
48 INT = 'an integer'
49 FILE = 'a file object'
50 FLOAT = 'a floating point number'
51 FUNC = 'a function'
52 LIST = 'a list'
53 LIST_FLOAT = 'a list of floating point numbers'
54 LIST_INT = 'a list of integers'
55 LIST_NUM = 'a list of numbers'
56 LIST_STR = 'a list of strings'
57 LIST_VAL = 'a list of values'
58 MATRIX_FLOAT = 'a matrix of floating point numbers'
59 NONE = 'None'
60 NUM = 'a number'
61 TUPLE = 'a tuple'
62 TUPLE_FLOAT = 'a tuple of floating point numbers'
63 TUPLE_INT = 'a tuple of integers'
64 TUPLE_NUM = 'a tuple of numbers'
65 TUPLE_STR = 'a tuple of strings'
66 STR = 'a string'
67 VAL = 'a value'
68
69
71 """Save the program state, for debugging purposes."""
72
73
74 try:
75 from data_store import Relax_data_store; ds = Relax_data_store()
76
77
78 except ImportError:
79 return
80
81
82 now = time.localtime()
83 file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[1], now[2], now[3], now[4], now[5])
84
85
86 if bz2:
87 sys.stderr.write("\nStoring the relax state in the file '%s.bz2'.\n\n" % file_name)
88 file = BZ2File(file_name+'.bz2', 'w')
89 else:
90 sys.stderr.write("\nStoring the relax state in the file '%s'.\n\n" % file_name)
91 file = open(file_name, 'w')
92
93
94 pickle.dump(ds, file, 1)
95
96
97 file.close()
98
99
100 -def list_to_text(data):
101 """Convert the given Python list to a text representation.
102
103 @param data: The list of Python objects.
104 @type data: list
105 @return: The English text version of the list.
106 @rtype: str
107 """
108
109
110 text = ''
111
112
113 for i in range(len(data)):
114
115 text += repr(data[i])
116
117
118 if i < len(data) - 2:
119 text += ', '
120
121
122 if i == len(data) - 2:
123 text += ' and '
124
125
126 return text
127
128
129
130
131
133 """The base class for all RelaxErrors."""
134
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 if pipe == None:
677 self.text = "The spin '%s' does not exist." % id
678 else:
679 self.text = "The spin '%s' does not exist in the '%s' data pipe." % (id, pipe)
680
681
683 - def __init__(self, line, problem=None):
684 if problem == None:
685 self.text = "The sequence data in the line %s is invalid." % line
686 else:
687 self.text = "The sequence data in the line %s is invalid, %s." % (line, problem)
688
689
692 self.text = "The spin information for the spin " + repr(spin_id) + " has not yet been loaded, please use the structure.load_spins user function."
693
694
695
696
697
698
700 - def __init__(self, spin_id1=None, spin_id2=None, pipe=None):
701 if spin_id1 and pipe:
702 self.text = "The interatomic data between the spins '%s' and '%s' for the data pipe '%s' does not exist." % (spin_id1, spin_id2, pipe)
703 elif spin_id1:
704 self.text = "The interatomic data between the spins '%s' and '%s' does not exist." % (spin_id1, spin_id2)
705 elif pipe:
706 self.text = "The interatomic data for the data pipe '%s' does not exist." % pipe
707 else:
708 self.text = "The interatomic data does not exist."
709
710
713 if pipe == None:
714 self.text = "The interatomic data already exists."
715 else:
716 self.text = "The interatomic data for the data pipe " + repr(pipe) + " already exists."
717
718
721 self.text = "The interatomic data is inconsistent between the data pipes '%s' and '%s'." % (pipe1, pipe2)
722
723
724
725
726
727
728
729 -class RelaxNoDomainError(BaseError):
730 - def __init__(self, id=None):
731 if id == None:
732 self.text = "No domains are defined."
733 else:
734 self.text = "The domain '%s' is not defined." % id
735
736
737
738
739
740
741
743 - def __init__(self, pipe_name=None, id=None):
744 self.text = "No spectrometer frequency information"
745 if id != None:
746 self.text += " for the '%s' experiment ID" % id
747 self.text += " is present"
748 if pipe_name != None:
749 self.text += " in the '%s' data pipe" % pipe_name
750 self.text += "."
751
752
753
754
755
756
757
760 if spectrum_id == None:
761 self.text = "No peak intensity data has been loaded."
762 else:
763 self.text = "Peak intensity data for the '%s' spectrum ID does not exist."
764
765
768 self.text = "Spectral data corresponding to the ID string '%s' does not exist." % spectrum_id
769
770
773 self.text = "Spectral data corresponding to the ID string '%s' already exists." % spectrum_id
774
775
776
777
778
779
782 self.text = "Relaxation data corresponding to the ID string '%s' does not exist." % ri_id
783
784
787 self.text = "Relaxation data corresponding to the ID string '%s' already exists." % ri_id
788
789
790
791
792
793
796 self.text = "No J coupling data exists."
797
798
801 self.text = "J coupling data already exists."
802
803
804
805
806
807
809 - def __init__(self, align_id, pipe=None):
810 if pipe != None:
811 self.text = "The alignment ID string '%s' is missing from the data pipe '%s'." % (align_id, pipe)
812 else:
813 self.text = "The alignment ID string '%s' is missing." % align_id
814
815
818 self.text = "Alignment data corresponding to the ID string '%s' already exists." % align_id
819
820
823 if id:
824 self.text = "RDC data corresponding to the identification string " + repr(id) + " does not exist."
825 else:
826 self.text = "No RDC data exists."
827
828
831 self.text = "RDC data corresponding to the identification string " + repr(id) + " already exists."
832
833
836 if id:
837 self.text = "PCS data corresponding to the identification string " + repr(id) + " does not exist."
838 else:
839 self.text = "No PCS data exists."
840
841
844 self.text = "PCS data corresponding to the identification string " + repr(id) + " already exists."
845
846
847
848
849
850
853 self.text = "Model-free data corresponding to the data pipe " + repr(pipe) + " already exists."
854
855
856
857
858
859
862 self.text = "The " + tensor_type + " tensor data already exists."
863
864
866 - def __init__(self, tensor_type, tensor_label=None):
867 if not tensor_label:
868 self.text = "No " + tensor_type + " tensor data exists."
869 else:
870 self.text = "No " + tensor_type + " tensor data exists for the tensor " + repr(tensor_label) + "."
871
872
873
874
875
876
879 if name == None:
880 self.text = "The directory " + repr(dir) + " does not exist."
881 else:
882 self.text = "The " + name + " directory " + repr(dir) + " does not exist."
883
884
886 - def __init__(self, name, file_name=None):
887 if file_name == None:
888 self.text = "The file " + repr(name) + " does not exist."
889 else:
890 self.text = "The " + name + " file " + repr(file_name) + " does not exist."
891
892
895 self.text = "The file contains no data."
896
897
900 self.text = "The file " + repr(file_name) + " already exists. Set the " + flag + " to True to overwrite."
901
902
905 self.text = "The format of the data is invalid."
906
907
908
909
910
911
914 self.text = "The data pipe bundle '%s' already exists." % bundle
915
916
919 if bundle != None:
920 self.text = "The data pipe bundle '%s' has not been created yet." % bundle
921 else:
922 self.text = "No data pipe bundles currently exist. Please use the pipe.bundle user function first."
923
924
927 self.text = "The data pipe " + repr(pipe) + " already exists."
928
929
932 if pipe != None:
933 self.text = "The data pipe " + repr(pipe) + " has not been created yet."
934 else:
935 self.text = "No data pipes currently exist. Please use the pipe.create user function first."
936
937
938
939
940
941
944 self.text = "The selection of molecules is not allowed."
945
946
949 self.text = "The selection of residues is not allowed."
950
951
954 self.text = "The selection of spin systems is not allowed."
955
956
959 self.text = "The spin system must be specified."
960
961
962
963
964
965
966
969 self.text = "This function is not available for " + string + "."
970
971
974 if name != None:
975 self.text = "The " + name + " model already exists."
976 else:
977 self.text = "The model already exists."
978
979
980
983 if name != None:
984 self.text = "The specific " + name + " model has not been selected or set up."
985 else:
986 self.text = "The specific model has not been selected or set up."
987
988
989
990
991
992
995 self.text = "The " + name + " argument " + repr(value) + " is not valid regular expression."
996
997
998
999
1000
1001
1003 - def __init__(self, name, param_type=None):
1004 if param_type != None:
1005 self.text = "The " + name + " parameter, " + repr(param_type) + ", cannot be set."
1006 else:
1007 self.text = "The " + name + " parameter cannot be set."
1008
1009
1011 - def __init__(self, data_type, pipe=None):
1012 if pipe != None:
1013 self.text = "The data type " + repr(data_type) + " already exists for the data pipe " + repr(pipe) + "."
1014 else:
1015 self.text = "The data type " + repr(data_type) + " already exists."
1016
1017
1019 - def __init__(self, name, spin_id=None, spin_id2=None):
1020 if spin_id2 != None:
1021 self.text = "The %s value has not yet been set for spins '%s' and '%s'." % (name, spin_id, spin_id2)
1022 elif spin_id != None:
1023 self.text = "The %s value has not yet been set for spin '%s'." % (name, spin_id)
1024 else:
1025 self.text = "The " + repr(name) + " value has not yet been set."
1026
1027
1030 self.text = "The data type " + repr(name) + " is unknown."
1031
1032
1034 - def __init__(self, name, param_type=None):
1035 if param_type != None:
1036 self.text = "The " + name + " parameter, " + repr(param_type) + ", is unknown."
1037 else:
1038 self.text = "The " + name + " parameter is unknown."
1039
1040
1043 self.text = "The " + repr(name) + " argument " + repr(data) + " represents an unknown parameter combination."
1044
1045
1046
1047
1048
1049
1052 if pipe:
1053 self.text = "Simulations for the data pipe " + repr(pipe) + " have not been setup."
1054 else:
1055 self.text = "Simulations have not been setup."
1056
1057
1058
1059
1060
1061
1064 self.text = "The style " + repr(style) + " is unknown."
1065
1066
1067
1068
1069
1070
1073 self.text = "The colour " + repr(colour) + " is invalid."
1074
1075
1076
1077
1078
1079
1082 self.text = "The invalid " + name + " floating point value of infinity has occurred."
1083
1084
1087 self.text = "The invalid " + name + " floating point value of NaN (Not a Number) has occurred."
1088
1089
1090
1091
1092
1093
1096 self.text = "The " + name + " data structure cannot be recreated from the XML elements as the structure is not empty."
1097
1098
1099
1100
1101
1102
1103
1124
1125
1126 AllRelaxErrors = tuple(all_errors(dir()))
1127