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 objects used to handle peak list data.
24
25 These objects are only temporary. In the future, they may be made permanent by shifting them into the relax data storage object.
26 """
27
28
29 from lib.errors import RelaxError
30
31
33 """A special container for a single assignment in a peak list."""
34
35
36
38 """The object used to represent a peak list."""
39
41 """Set up the object.
42
43 @keyword dim: The dimensionality of the peak list.
44 @type dim: int
45 """
46
47
48 self.dimensionality = dim
49
50
51 - def add(self, mol_names=None, res_nums=None, res_names=None, spin_nums=None, spin_names=None, shifts=None, intensity=None, intensity_name=None):
52 """Add a peak list element.
53
54
55 @keyword mol_names: The list of molecule names for each dimension of the assignment.
56 @type mol_names: list of str or None
57 @keyword res_nums: The list of residue numbers for each dimension of the assignment.
58 @type res_nums: list of int or None
59 @keyword res_names: The list of residue names for each dimension of the assignment.
60 @type res_names: list of str or None
61 @keyword spin_nums: The list of spin numbers for each dimension of the assignment.
62 @type spin_nums: list of int or None
63 @keyword spin_names: The list of spin names for each dimension of the assignment.
64 @type spin_names: list of str or None
65 @keyword shifts: The chemical shifts for each dimension of the assignment in ppm.
66 @type shifts: list of float or None
67 @keyword intensity: The optional intensity value for the peak. This can have multiple values as some peak lists cover multiple spectra.
68 @type intensity: list of float or None
69 @keyword intensity_name: The optional name of the intensity column. This can be used for automated spectrum ID generation.
70 @type intensity_name: list of str or None
71 """
72
73
74 if mol_names != None and len(mol_names) != self.dimensionality:
75 raise RelaxError("The molecule names %s must be a list of %s dimensions." % (mol_names, self.dimensionality))
76 if res_nums != None and len(res_nums) != self.dimensionality:
77 raise RelaxError("The residue numbers %s must be a list of %s dimensions." % (res_nums, self.dimensionality))
78 if res_names != None and len(res_names) != self.dimensionality:
79 raise RelaxError("The residue names %s must be a list of %s dimensions." % (res_names, self.dimensionality))
80 if spin_nums != None and len(spin_nums) != self.dimensionality:
81 raise RelaxError("The spin numbers %s must be a list of %s dimensions." % (spin_nums, self.dimensionality))
82 if spin_names != None and len(spin_names) != self.dimensionality:
83 raise RelaxError("The spin names %s must be a list of %s dimensions." % (spin_names, self.dimensionality))
84 if shifts != None and len(shifts) != self.dimensionality:
85 raise RelaxError("The chemical shifts %s must be a list of %s dimensions." % (shifts, self.dimensionality))
86
87
88 self.append(Assignment())
89
90
91 assign = self[-1]
92 assign.mol_names = mol_names
93 assign.res_nums = res_nums
94 assign.res_names = res_names
95 assign.spin_nums = spin_nums
96 assign.spin_names = spin_names
97 assign.shifts = shifts
98 assign.intensity = intensity
99 assign.intensity_name = intensity_name
100
101
102 names = ['mol_names', 'res_names', 'res_nums', 'spin_names', 'spin_nums', 'shifts']
103 for name in names:
104 obj = getattr(assign, name)
105 if obj == None:
106 setattr(assign, name, [None]*self.dimensionality)
107