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 cPickle import dump
34 from re import match
35 import sys
36 import time
37 from types import ClassType
38
39
40 import ansi
41
42
43
44 BIN = 'a binary number (0 or 1)'
45 BOOL = 'a Boolean (True or False)'
46 INT = 'an integer'
47 FILE = 'a file object'
48 FLOAT = 'a floating point number'
49 FUNC = 'a function'
50 LIST = 'a list'
51 LIST_FLOAT = 'a list of floating point numbers'
52 LIST_INT = 'a list of integers'
53 LIST_NUM = 'a list of numbers'
54 LIST_STR = 'a list of strings'
55 LIST_VAL = 'a list of values'
56 MATRIX_FLOAT = 'a matrix of floating point numbers'
57 NONE = 'None'
58 NUM = 'a number'
59 TUPLE = 'a tuple'
60 TUPLE_FLOAT = 'a tuple of floating point numbers'
61 TUPLE_INT = 'a tuple of integers'
62 TUPLE_NUM = 'a tuple of numbers'
63 TUPLE_STR = 'a tuple of strings'
64 STR = 'a string'
65 VAL = 'a value'
66
67
69 """Save the program state, for debugging purposes."""
70
71
72 try:
73 from data import Relax_data_store; ds = Relax_data_store()
74
75
76 except ImportError:
77 return
78
79
80 now = time.localtime()
81 file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[1], now[2], now[3], now[4], now[5])
82
83
84 if bz2:
85 sys.stderr.write("\n\nStoring the relax state in the file '%s.bz2'.\n\n\n" % file_name)
86 file = BZ2File(file_name+'.bz2', 'w')
87 else:
88 sys.stderr.write("\n\nStoring the relax state in the file '%s'.\n\n\n" % file_name)
89 file = open(file_name, 'w')
90
91
92 dump(ds, file, 1)
93
94
95 file.close()
96
97
98
99
100
102 """The base class for all RelaxErrors."""
103
117
118
120 """The base class for all the argument related RelaxErrors."""
121
122
123 simple_types = []
124
125
126 list_types = []
127
128
129 - def __init__(self, name, value, size=None):
130 """A default initialisation and error message formatting method."""
131
132
133 self.text = "The %s argument '%s' must be " % (name, value)
134
135
136 if size != None:
137 for i in range(len(self.list_types)):
138 self.list_types[i] = self.list_types[i] + " of size %s" % repr(size)
139
140
141 all_types = self.simple_types + self.list_types
142
143
144 if len(all_types) > 1:
145 self.text = self.text + "either "
146
147
148 for i in range(len(all_types)):
149
150 if i > 0:
151
152 if i == len(all_types)-1:
153 self.text = self.text + ", or "
154
155
156 else:
157 self.text = self.text + ", "
158
159
160 self.text = self.text + all_types[i]
161
162
163 self.text = self.text + "."
164
165
166
167
168
172
173
174
175
176
179 self.text = "The %s module '%s' cannot be found. Please check that it is installed." % (desc, name)
180
181
182
183
184
187 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/."
188
190
191 save_state()
192
193
194 return ("RelaxError: " + self.text + "\n")
195
196
197
198
199
200
203 if fn_name:
204 self.text = "The %s function has not yet been implemented for the current data pipe." % fn_name
205 else:
206 self.text = "This has not yet been implemented for the current data pipe."
207
208
209
210
211
212
215 self.text = "The program " + repr(name) + " cannot be found."
216
217
218
221 self.text = "The binary executable file " + repr(name) + " does not exist."
222
223
224
227 self.text = "The binary executable file " + repr(name) + " is not executable."
228
229
230
233 self.text = "The binary executable file " + repr(name) + " is not located within the system path."
234
235
236
239 self.text = "Execution of the program " + name + " has failed."
240
241
242
243
244
245
248 if pipe != None:
249 self.text = "PDB data corresponding to the data pipe " + repr(pipe) + " already exists."
250 else:
251 self.text = "PDB data already exists."
252
253
256 if pipe != None:
257 self.text = "No PDB file has been loaded for the data pipe " + repr(pipe) + "."
258 else:
259 self.text = "No PDB file has been loaded."
260
261
264 self.text = "The PDB file " + repr(name) + " could not be loaded properly, no molecular chains could be extracted."
265
266
269 if spin_id != None:
270 self.text = "The multiple unit XH bond vectors for the spin '%s' - this is not supported by the current data pipe type." % spin_id
271 else:
272 self.text = "The multiple unit XH bond vectors per spin - this is not supported by the current data pipe type."
273
274
277 self.text = "The unit XH bond vectors for the data pipe " + repr(pipe) + " have not been calculated."
278
279
282 self.text = "No peptide or nucleotide chains can be found within the PDB file."
283
284
285
286
287
288
291 self.text = "The type of nucleus has not yet been set."
292
293
296 self.text = "The spin type has not yet been set. Please use the value.set user function to set the heteronucleus type."
297
298
301 self.text = "The type of proton attached to the spin has not yet been set. Please use the value.set user function to set the proton type."
302
303
304
305
306
307
308
309
310
311
314 self.text = "The " + name + " argument " + repr(value) + " is invalid."
315
316
319 self.text = "The " + name + " argument " + repr(value) + " is neither "
320 for i in xrange(len(list)-1):
321 self.text = self.text + repr(list[i]) + ', '
322 self.text = self.text + 'nor ' + repr(list[-1]) + "."
323
324
327 self.text = "The " + name + " argument must be of length " + repr(len) + "."
328
329
332 self.text = "The " + name + " argument has not been supplied."
333
334
337 self.text = "The %s argument of '%s' must be None."
338
339
340
341
342
343
346
347
350
351
354
357
358
361
364
365
368
371
372
375
378
379
382
385
386
387
388
389
390
393
396
397
400
403
404
405
406
407
408
409
412
416
417
420
423
424
427
428
431
432
436
437
440
444
445
448
452
453
454
455
456
457
461
462
466
467
471
475
476
480
484
485
489
490
494
498
499
503
507
508
512
516
517
518
519
520
521
524
528
529
532
533
534
535
536
537
541
542
546
550
551
552
553
554
555
558
561
562
563
564
565
566
567
570 if pipe == None:
571 self.text = "The sequence data does not exist."
572 else:
573 self.text = "The sequence data for the data pipe " + repr(pipe) + " does not exist."
574
575
578 if pipe == None:
579 self.text = "The sequence data already exists."
580 else:
581 self.text = "The sequence data for the data pipe " + repr(pipe) + " already exists."
582
583
586 self.text = "The sequences for the data pipes " + repr(pipe1) + " and " + repr(pipe2) + " are not the same."
587
588
591 self.text = "The number of molecules do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
592
593
596 self.text = "The number of residues do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
597
598
601 self.text = "The number of spins do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
602
603
606 if id == '':
607 self.text = "The empty molecule ID corresponds to more than a single molecule in the current data pipe."
608 else:
609 self.text = "The molecule ID '%s' corresponds to more than a single molecule in the current data pipe." % id
610
611
614 if id == '':
615 self.text = "The empty residue ID corresponds to more than a single residue in the current data pipe."
616 else:
617 self.text = "The residue ID '%s' corresponds to more than a single residue in the current data pipe." % id
618
619
622 if id == '':
623 self.text = "The empty spin ID corresponds to more than a single spin in the current data pipe."
624 else:
625 self.text = "The spin ID '%s' corresponds to more than a single spin in the current data pipe." % id
626
627
630 if name == None:
631 self.text = "The residue '" + repr(number) + "' cannot be found in the sequence."
632 else:
633 self.text = "The residue '" + repr(number) + " " + name + "' cannot be found in the sequence."
634
635
638 self.text = "The spin " + repr(id) + " does not exist."
639
640
642 - def __init__(self, line, problem=None):
643 if problem == None:
644 self.text = "The sequence data in the line %s is invalid." % line
645 else:
646 self.text = "The sequence data in the line %s is invalid, %s." % (line, problem)
647
648
651 self.text = "The spin information for the spin " + repr(spin_id) + " has not yet been loaded, please use the structure.load_spins user function."
652
653
654
655
656
657
658
659
662 self.text = "Spectral data corresponding to the ID string '%s' does not exist." % spectrum_id
663
664
667 self.text = "Spectral data corresponding to the ID string '%s' already exists." % spectrum_id
668
669
670
671
672
673
676 self.text = "Relaxation data corresponding to the ID string '%s' does not exist." % ri_id
677
678
681 self.text = "Relaxation data corresponding to the ID string '%s' already exists." % ri_id
682
683
684
685
686
687
690 self.text = "RDC data corresponding to the identification string " + repr(id) + " does not exist."
691
692
695 self.text = "RDC data corresponding to the identification string " + repr(id) + " already exists."
696
697
700 self.text = "PCS data corresponding to the identification string " + repr(id) + " does not exist."
701
702
705 self.text = "PCS data corresponding to the identification string " + repr(id) + " already exists."
706
707
708
709
710
711
714 self.text = "Model-free data corresponding to the data pipe " + repr(pipe) + " already exists."
715
716
717
718
719
720
723 self.text = "The " + tensor_type + " tensor data already exists."
724
725
727 - def __init__(self, tensor_type, tensor_label=None):
728 if not tensor_label:
729 self.text = "No " + tensor_type + " tensor data exists."
730 else:
731 self.text = "No " + tensor_type + " tensor data exists for the tensor " + repr(tensor_label) + "."
732
733
734
735
736
737
740 if name == None:
741 self.text = "The directory " + repr(dir) + " does not exist."
742 else:
743 self.text = "The " + name + " directory " + repr(dir) + " does not exist."
744
745
747 - def __init__(self, name, file_name=None):
748 if file_name == None:
749 self.text = "The file " + repr(name) + " does not exist."
750 else:
751 self.text = "The " + name + " file " + repr(file_name) + " does not exist."
752
753
756 self.text = "The file contains no data."
757
758
761 self.text = "The file " + repr(file_name) + " already exists. Set the " + flag + " to True to overwrite."
762
763
766 self.text = "The format of the data is invalid."
767
768
769
770
771
772
775 self.text = "The data pipe " + repr(pipe) + " already exists."
776
777
780 if pipe != None:
781 self.text = "The data pipe " + repr(pipe) + " has not been created yet."
782 else:
783 self.text = "No data pipes currently exist. Please use the pipe.create user function first."
784
785
786
787
788
789
792 self.text = "The selection of molecules is not allowed."
793
794
797 self.text = "The selection of residues is not allowed."
798
799
802 self.text = "The selection of spin systems is not allowed."
803
804
807 self.text = "The spin system must be specified."
808
809
810
811
812
813
814
817 self.text = "This function is not available for " + string + "."
818
819
822 if name != None:
823 self.text = "The " + name + " model already exists."
824 else:
825 self.text = "The model already exists."
826
827
828
831 if name != None:
832 self.text = "The specific " + name + " model has not been selected or set up."
833 else:
834 self.text = "The specific model has not been selected or set up."
835
836
837
838
839
840
843 self.text = "The " + name + " argument " + repr(value) + " is not valid regular expression."
844
845
846
847
848
849
851 - def __init__(self, name, param_type=None):
852 if param_type != None:
853 self.text = "The " + name + " parameter, " + repr(param_type) + ", cannot be set."
854 else:
855 self.text = "The " + name + " parameter cannot be set."
856
857
859 - def __init__(self, data_type, pipe=None):
860 if pipe != None:
861 self.text = "The data type " + repr(data_type) + " already exists for the data pipe " + repr(pipe) + "."
862 else:
863 self.text = "The data type " + repr(data_type) + " already exists."
864
865
868 self.text = "The " + repr(name) + " value has not yet been set."
869
870
873 self.text = "The data type " + repr(name) + " is unknown."
874
875
877 - def __init__(self, name, param_type=None):
878 if param_type != None:
879 self.text = "The " + name + " parameter, " + repr(param_type) + ", is unknown."
880 else:
881 self.text = "The " + name + " parameter is unknown."
882
883
886 self.text = "The " + repr(name) + " argument " + repr(data) + " represents an unknown parameter combination."
887
888
889
890
891
892
895 if pipe:
896 self.text = "Simulations for the data pipe " + repr(pipe) + " have not been setup."
897 else:
898 self.text = "Simulations have not been setup."
899
900
901
902
903
904
907 self.text = "The style " + repr(style) + " is unknown."
908
909
910
911
912
913
916 self.text = "The colour " + repr(colour) + " is invalid."
917
918
919
920
921
922
925 self.text = "The invalid " + name + " floating point value of infinity has occurred."
926
927
930 self.text = "The invalid " + name + " floating point value of NaN (Not a Number) has occurred."
931
932
933
934
935
936
939 self.text = "The " + name + " data structure cannot be recreated from the XML elements as the structure is not empty."
940
941
942
943
944
945
946
948 """Function for returning all the RelaxErrors to allow the AllRelaxError object to be created."""
949
950
951 list = None
952
953
954 for name in names:
955
956 object = globals()[name]
957
958
959 if not (isinstance(object, ClassType) or isinstance(object, type(type))) or not match('Relax', name):
960 continue
961
962
963 if list == None:
964 list = object,
965 else:
966 list = list, object
967
968
969 return list
970
971
972 AllRelaxErrors = all_errors(dir())
973