mailr20661 - in /trunk: lib/spectrum/objects.py pipe_control/chemical_shift.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on August 21, 2013 - 14:31:
Author: bugman
Date: Wed Aug 21 14:31:03 2013
New Revision: 20661

URL: http://svn.gna.org/viewcvs/relax?rev=20661&view=rev
Log:
Modified the peak list object.

The peak list dimensionality variable is no longer private, and many values 
of None are now
converted to lists of None so that the peak list data is easier to handle.


Modified:
    trunk/lib/spectrum/objects.py
    trunk/pipe_control/chemical_shift.py

Modified: trunk/lib/spectrum/objects.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/spectrum/objects.py?rev=20661&r1=20660&r2=20661&view=diff
==============================================================================
--- trunk/lib/spectrum/objects.py (original)
+++ trunk/lib/spectrum/objects.py Wed Aug 21 14:31:03 2013
@@ -45,7 +45,7 @@
         """
 
         # Store the dimensionality.
-        self._dim = dim
+        self.dimensionality = dim
 
 
     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):
@@ -71,18 +71,18 @@
         """
 
         # Check the arguments.
-        if mol_names != None and len(mol_names) != self._dim:
-            raise RelaxError("The molecule names %s must be a list of %s 
dimensions." % (mol_names, self._dim))
-        if res_nums != None and len(res_nums) != self._dim:
-            raise RelaxError("The residue numbers %s must be a list of %s 
dimensions." % (res_nums, self._dim))
-        if res_names != None and len(res_names) != self._dim:
-            raise RelaxError("The residue names %s must be a list of %s 
dimensions." % (res_names, self._dim))
-        if spin_nums != None and len(spin_nums) != self._dim:
-            raise RelaxError("The spin numbers %s must be a list of %s 
dimensions." % (spin_nums, self._dim))
-        if spin_names != None and len(spin_names) != self._dim:
-            raise RelaxError("The spin names %s must be a list of %s 
dimensions." % (spin_names, self._dim))
-        if shifts != None and len(shifts) != self._dim:
-            raise RelaxError("The chemical shifts %s must be a list of %s 
dimensions." % (shifts, self._dim))
+        if mol_names != None and len(mol_names) != self.dimensionality:
+            raise RelaxError("The molecule names %s must be a list of %s 
dimensions." % (mol_names, self.dimensionality))
+        if res_nums != None and len(res_nums) != self.dimensionality:
+            raise RelaxError("The residue numbers %s must be a list of %s 
dimensions." % (res_nums, self.dimensionality))
+        if res_names != None and len(res_names) != self.dimensionality:
+            raise RelaxError("The residue names %s must be a list of %s 
dimensions." % (res_names, self.dimensionality))
+        if spin_nums != None and len(spin_nums) != self.dimensionality:
+            raise RelaxError("The spin numbers %s must be a list of %s 
dimensions." % (spin_nums, self.dimensionality))
+        if spin_names != None and len(spin_names) != self.dimensionality:
+            raise RelaxError("The spin names %s must be a list of %s 
dimensions." % (spin_names, self.dimensionality))
+        if shifts != None and len(shifts) != self.dimensionality:
+            raise RelaxError("The chemical shifts %s must be a list of %s 
dimensions." % (shifts, self.dimensionality))
 
         # Add a new element.
         self.append(Assignment())
@@ -97,3 +97,10 @@
         assign.shifts = shifts
         assign.intensity = intensity
         assign.intensity_name = intensity_name
+
+        # Convert certain None values to lists of None.
+        names = ['mol_names', 'res_names', 'res_nums', 'spin_names', 
'spin_nums', 'shifts']
+        for name in names:
+            obj = getattr(assign, name)
+            if obj == None:
+                setattr(assign, name, [None]*self.dimensionality)

Modified: trunk/pipe_control/chemical_shift.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/pipe_control/chemical_shift.py?rev=20661&r1=20660&r2=20661&view=diff
==============================================================================
--- trunk/pipe_control/chemical_shift.py (original)
+++ trunk/pipe_control/chemical_shift.py Wed Aug 21 14:31:03 2013
@@ -78,10 +78,9 @@
     # Loop over the assignments.
     data = []
     data_flag = False
-    dim = peak_list._dim
     for assign in peak_list:
         # Loop over the dimensions of the peak list.
-        for i in range(dim):
+        for i in range(peak_list.dimensionality):
             # Generate the spin_id.
             spin_id = generate_spin_id_unique(res_num=assign.res_nums[i], 
spin_name=assign.spin_names[i])
 




Related Messages


Powered by MHonArc, Updated Wed Aug 21 14:40:02 2013