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 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
65
67 """Save the program state, for debugging purposes."""
68
69
70 try:
71 from data 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 dump(ds, file, 1)
91
92
93 file.close()
94
95
96
97
98
100 """The base class for all RelaxErrors."""
101
115
116
118 """The base class for all the argument related RelaxErrors."""
119
120
121 simple_types = []
122
123
124 list_types = []
125
126
127 - def __init__(self, name, value, size=None):
128 """A default initialisation and error message formatting method."""
129
130
131 self.text = "The %s argument '%s' must be " % (name, value)
132
133
134 if size != None:
135 for i in range(len(self.list_types)):
136 self.list_types[i] = self.list_types[i] + " of size %s" % repr(size)
137
138
139 all_types = self.simple_types + self.list_types
140
141
142 if len(all_types) > 1:
143 self.text = self.text + "either "
144
145
146 for i in range(len(all_types)):
147
148 if i > 0:
149
150 if i == len(all_types)-1:
151 self.text = self.text + ", or "
152
153
154 else:
155 self.text = self.text + ", "
156
157
158 self.text = self.text + all_types[i]
159
160
161 self.text = self.text + "."
162
163
164
165
166
170
171
172
173
174
177 self.text = "The %s module '%s' cannot be found. Please check that it is installed." % (desc, name)
178
179
180
181
182
185 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/."
186
188
189 save_state()
190
191
192 return ("RelaxError: " + self.text + "\n")
193
194
195
196
197
198
201 self.text = "This has not yet been implemented for the current data pipe."
202
203
204
205
206
207
210 self.text = "The program " + repr(name) + " cannot be found."
211
212
213
216 self.text = "The binary executable file " + repr(name) + " does not exist."
217
218
219
222 self.text = "The binary executable file " + repr(name) + " is not executable."
223
224
225
228 self.text = "The binary executable file " + repr(name) + " is not located within the system path."
229
230
231
234 self.text = "Execution of the program " + name + " has failed."
235
236
237
238
239
240
243 if pipe != None:
244 self.text = "PDB data corresponding to the data pipe " + repr(pipe) + " already exists."
245 else:
246 self.text = "PDB data already exists."
247
248
251 if pipe != None:
252 self.text = "No PDB file has been loaded for the data pipe " + repr(pipe) + "."
253 else:
254 self.text = "No PDB file has been loaded."
255
256
259 self.text = "The PDB file " + repr(name) + " could not be loaded properly, no molecular chains could be extracted."
260
261
264 self.text = "The multiple unit XH bond vectors per spin - this is not supported by the current data pipe type."
265
266
269 self.text = "The unit XH bond vectors for the data pipe " + repr(pipe) + " have not been calculated."
270
271
274 self.text = "No peptide or nucleotide chains can be found within the PDB file."
275
276
277
278
279
280
283 self.text = "The type of nucleus has not yet been set."
284
285
288 self.text = "The spin type has not yet been set. Please use the value.set user function to set the heteronucleus type."
289
290
293 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."
294
295
296
297
298
299
300
301
302
303
306 self.text = "The " + name + " argument " + repr(value) + " is invalid."
307
308
311 self.text = "The " + name + " argument " + repr(value) + " is neither "
312 for i in xrange(len(list)-1):
313 self.text = self.text + repr(list[i]) + ', '
314 self.text = self.text + 'nor ' + repr(list[-1]) + "."
315
316
319 self.text = "The " + name + " argument must be of length " + repr(len) + "."
320
321
324 self.text = "The " + name + " argument has not been supplied."
325
326
329 self.text = "The %s argument of '%s' must be None."
330
331
332
333
334
335
338
339
342
343
346
349
350
353
356
357
360
363
364
367
370
371
374
377
378
379
380
381
382
385
388
389
392
395
396
397
398
399
400
401
404
408
409
412
415
416
419
420
423
424
428
429
432
436
437
440
444
445
446
447
448
449
453
454
458
459
463
467
468
472
476
477
481
482
486
490
491
495
499
500
501
502
503
504
507
511
512
515
516
517
518
519
520
524
525
529
533
534
535
536
537
538
541
544
545
546
547
548
549
550
553 if pipe == None:
554 self.text = "The sequence data does not exist."
555 else:
556 self.text = "The sequence data for the data pipe " + repr(pipe) + " does not exist."
557
558
561 if pipe == None:
562 self.text = "The sequence data already exists."
563 else:
564 self.text = "The sequence data for the data pipe " + repr(pipe) + " already exists."
565
566
569 self.text = "The sequences for the data pipes " + repr(pipe1) + " and " + repr(pipe2) + " are not the same."
570
571
574 self.text = "The number of molecules do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
575
576
579 self.text = "The number of residues do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
580
581
584 self.text = "The number of spins do not match between pipes '%s' and '%s'." % (pipe1, pipe2)
585
586
589 if id == '':
590 self.text = "The empty molecule ID corresponds to more than a single molecule in the current data pipe."
591 else:
592 self.text = "The molecule ID '%s' corresponds to more than a single molecule in the current data pipe." % id
593
594
597 if id == '':
598 self.text = "The empty residue ID corresponds to more than a single residue in the current data pipe."
599 else:
600 self.text = "The residue ID '%s' corresponds to more than a single residue in the current data pipe." % id
601
602
605 if id == '':
606 self.text = "The empty spin ID corresponds to more than a single spin in the current data pipe."
607 else:
608 self.text = "The spin ID '%s' corresponds to more than a single spin in the current data pipe." % id
609
610
613 if name == None:
614 self.text = "The residue '" + repr(number) + "' cannot be found in the sequence."
615 else:
616 self.text = "The residue '" + repr(number) + " " + name + "' cannot be found in the sequence."
617
618
621 self.text = "The spin " + repr(id) + " does not exist."
622
623
625 - def __init__(self, line, problem=None):
626 if problem == None:
627 self.text = "The sequence data in the line %s is invalid." % line
628 else:
629 self.text = "The sequence data in the line %s is invalid, %s." % (line, problem)
630
631
634 self.text = "The spin information for the spin " + repr(spin_id) + " has not yet been loaded, please use the structure.load_spins user function."
635
636
637
638
639
640
641
642
645 self.text = "Spectral data corresponding to the ID string '%s' does not exist." % spectrum_id
646
647
650 self.text = "Spectral data corresponding to the ID string '%s' already exists." % spectrum_id
651
652
653
654
655
656
659 self.text = "Relaxation data corresponding to the ID string '%s' does not exist." % ri_id
660
661
664 self.text = "Relaxation data corresponding to the ID string '%s' already exists." % ri_id
665
666
667
668
669
670
673 self.text = "RDC data corresponding to the identification string " + repr(id) + " does not exist."
674
675
678 self.text = "RDC data corresponding to the identification string " + repr(id) + " already exists."
679
680
683 self.text = "PCS data corresponding to the identification string " + repr(id) + " does not exist."
684
685
688 self.text = "PCS data corresponding to the identification string " + repr(id) + " already exists."
689
690
691
692
693
694
697 self.text = "Model-free data corresponding to the data pipe " + repr(pipe) + " already exists."
698
699
700
701
702
703
706 self.text = "The " + tensor_type + " tensor data already exists."
707
708
710 - def __init__(self, tensor_type, tensor_label=None):
711 if not tensor_label:
712 self.text = "No " + tensor_type + " tensor data exists."
713 else:
714 self.text = "No " + tensor_type + " tensor data exists for the tensor " + repr(tensor_label) + "."
715
716
717
718
719
720
723 if name == None:
724 self.text = "The directory " + repr(dir) + " does not exist."
725 else:
726 self.text = "The " + name + " directory " + repr(dir) + " does not exist."
727
728
730 - def __init__(self, name, file_name=None):
731 if file_name == None:
732 self.text = "The file " + repr(name) + " does not exist."
733 else:
734 self.text = "The " + name + " file " + repr(file_name) + " does not exist."
735
736
739 self.text = "The file contains no data."
740
741
744 self.text = "The file " + repr(file_name) + " already exists. Set the " + flag + " to True to overwrite."
745
746
749 self.text = "The format of the data is invalid."
750
751
752
753
754
755
758 self.text = "The data pipe " + repr(pipe) + " already exists."
759
760
763 if pipe != None:
764 self.text = "The data pipe " + repr(pipe) + " has not been created yet."
765 else:
766 self.text = "No data pipes currently exist. Please use the pipe.create user function first."
767
768
769
770
771
772
775 self.text = "The selection of molecules is not allowed."
776
777
780 self.text = "The selection of residues is not allowed."
781
782
785 self.text = "The selection of spin systems is not allowed."
786
787
790 self.text = "The spin system must be specified."
791
792
793
794
795
796
797
800 self.text = "This function is not available for " + string + "."
801
802
805 if name != None:
806 self.text = "The " + name + " model already exists."
807 else:
808 self.text = "The model already exists."
809
810
811
814 if name != None:
815 self.text = "The specific " + name + " model has not been selected or set up."
816 else:
817 self.text = "The specific model has not been selected or set up."
818
819
820
821
822
823
826 self.text = "The " + name + " argument " + repr(value) + " is not valid regular expression."
827
828
829
830
831
832
834 - def __init__(self, name, param_type=None):
835 if param_type != None:
836 self.text = "The " + name + " parameter, " + repr(param_type) + ", cannot be set."
837 else:
838 self.text = "The " + name + " parameter cannot be set."
839
840
842 - def __init__(self, data_type, pipe=None):
843 if pipe != None:
844 self.text = "The data type " + repr(data_type) + " already exists for the data pipe " + repr(pipe) + "."
845 else:
846 self.text = "The data type " + repr(data_type) + " already exists."
847
848
851 self.text = "The " + repr(name) + " value has not yet been set."
852
853
856 self.text = "The data type " + repr(name) + " is unknown."
857
858
860 - def __init__(self, name, param_type=None):
861 if param_type != None:
862 self.text = "The " + name + " parameter, " + repr(param_type) + ", is unknown."
863 else:
864 self.text = "The " + name + " parameter is unknown."
865
866
869 self.text = "The " + repr(name) + " argument " + repr(data) + " represents an unknown parameter combination."
870
871
872
873
874
875
878 if pipe:
879 self.text = "Simulations for the data pipe " + repr(pipe) + " have not been setup."
880 else:
881 self.text = "Simulations have not been setup."
882
883
884
885
886
887
890 self.text = "The style " + repr(style) + " is unknown."
891
892
893
894
895
896
899 self.text = "The colour " + repr(colour) + " is invalid."
900
901
902
903
904
905
908 self.text = "The invalid " + name + " floating point value of infinity has occurred."
909
910
913 self.text = "The invalid " + name + " floating point value of NaN (Not a Number) has occurred."
914
915
916
917
918
919
922 self.text = "The " + name + " data structure cannot be recreated from the XML elements as the structure is not empty."
923
924
925
926
927
928
929
931 """Function for returning all the RelaxErrors to allow the AllRelaxError object to be created."""
932
933
934 list = None
935
936
937 for name in names:
938
939 object = globals()[name]
940
941
942 if not (isinstance(object, ClassType) or isinstance(object, type(type))) or not match('Relax', name):
943 continue
944
945
946 if list == None:
947 list = object,
948 else:
949 list = list, object
950
951
952 return list
953
954
955 AllRelaxErrors = all_errors(dir())
956