Author: tlinnet
Date: Thu Dec 12 11:02:00 2013
New Revision: 21949
URL: http://svn.gna.org/viewcvs/relax?rev=21949view=rev
Log:
Implemented to read spins from a SPARKY list, when no intensity column is
present.
Addition to Support Request #3044, (https://gna.org/support/index.php?3044) -
Load spins from SPARKY list.
Modified:
trunk/lib/spectrum/sparky.py
trunk/test_suite/system_tests/peak_lists.py
Modified: trunk/lib/spectrum/sparky.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/lib/spectrum/sparky.py?rev=21949r1=21948r2=21949view=diff
==
--- trunk/lib/spectrum/sparky.py (original)
+++ trunk/lib/spectrum/sparky.py Thu Dec 12 11:02:00 2013
@@ -204,15 +204,29 @@
except ValueError:
raise RelaxError(The peak intensity value from the line %s is
invalid. % line)
-# Add the assignment to the peak list object.
-if dim == 1:
-peak_list.add(res_nums=[res_num1], res_names=[res_name1],
spin_names=[name1], shifts=[w1], intensity=intensity)
-elif dim == 2:
-peak_list.add(res_nums=[res_num1, res_num2], res_names=[res_name1,
res_name2], spin_names=[name1, name2], shifts=[w1, w2], intensity=intensity)
-elif dim == 3:
-peak_list.add(res_nums=[res_num1, res_num2, res_num1],
res_names=[res_name1, res_name2, res_name1], spin_names=[name1, name2, name3],
shifts=[w1, w2, w3], intensity=intensity)
-elif dim == 4:
-peak_list.add(res_nums=[res_num1, res_num2, res_num1, res_num1],
res_names=[res_name1, res_name2, res_name1, res_name1], spin_names=[name1,
name2, name3, name4], shifts=[w1, w2, w3, w4], intensity=intensity)
+# Add the assignment to the peak list object.
+if dim == 1:
+peak_list.add(res_nums=[res_num1], res_names=[res_name1],
spin_names=[name1], shifts=[w1], intensity=intensity)
+elif dim == 2:
+peak_list.add(res_nums=[res_num1, res_num2],
res_names=[res_name1, res_name2], spin_names=[name1, name2], shifts=[w1, w2],
intensity=intensity)
+elif dim == 3:
+peak_list.add(res_nums=[res_num1, res_num2, res_num1],
res_names=[res_name1, res_name2, res_name1], spin_names=[name1, name2, name3],
shifts=[w1, w2, w3], intensity=intensity)
+elif dim == 4:
+peak_list.add(res_nums=[res_num1, res_num2, res_num1,
res_num1], res_names=[res_name1, res_name2, res_name1, res_name1],
spin_names=[name1, name2, name3, name4], shifts=[w1, w2, w3, w4],
intensity=intensity)
+
+# If no intensity column, for example when reading spins from a
spectrum list.
+elif int_col == None:
+warn(RelaxWarning((The peak intensity value from the line %s is
invalid. The return value will be without intensity. % line)))
+
+# Add the assignment to the peak list object.
+if dim == 1:
+peak_list.add(res_nums=[res_num1], res_names=[res_name1],
spin_names=[name1], shifts=[w1])
+elif dim == 2:
+peak_list.add(res_nums=[res_num1, res_num2],
res_names=[res_name1, res_name2], spin_names=[name1, name2], shifts=[w1, w2])
+elif dim == 3:
+peak_list.add(res_nums=[res_num1, res_num2, res_num1],
res_names=[res_name1, res_name2, res_name1], spin_names=[name1, name2, name3],
shifts=[w1, w2, w3])
+elif dim == 4:
+peak_list.add(res_nums=[res_num1, res_num2, res_num1,
res_num1], res_names=[res_name1, res_name2, res_name1, res_name1],
spin_names=[name1, name2, name3, name4], shifts=[w1, w2, w3, w4])
def write_list(file_prefix=None, dir=None, res_names=None, res_nums=None,
atom1_names=None, atom2_names=None, w1=None, w2=None, data_height=None,
force=True):
Modified: trunk/test_suite/system_tests/peak_lists.py
URL:
http://svn.gna.org/viewcvs/relax/trunk/test_suite/system_tests/peak_lists.py?rev=21949r1=21948r2=21949view=diff
==
--- trunk/test_suite/system_tests/peak_lists.py (original)
+++ trunk/test_suite/system_tests/peak_lists.py Thu Dec 12 11:02:00 2013
@@ -456,6 +456,76 @@
# Read the spins from peak list.
self.interpreter.spectrum.read_spins(file=sparky2dim.list,
dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists',
dim=1)
self.interpreter.spectrum.read_spins(file=sparky2dim.list,
dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'peak_lists',
dim=2)
+
+# Test some of the sequence.
+self.assertEqual(len(cdp.mol), 1)
+self.assertEqual(cdp.mol[0].name, None)
+self.assertEqual(len(cdp.mol[0].res), 7)
+
+# 1st residue.
+self.assertEqual(cdp.mol[0].res[0].num, 62)
+self.assertEqual(cdp.mol[0].res[0].name, 'W')
+self.assertEqual(len(cdp.mol[0].res[0].spin), 2)
+