mailr27716 - in /branches/frame_order_cleanup: ./ lib/structure/internal/ pipe_control/structure/ test_suite/unit_tests/_lib/_se...


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

Header


Content

Posted by edward on February 24, 2015 - 09:35:
Author: bugman
Date: Tue Feb 24 09:35:17 2015
New Revision: 27716

URL: http://svn.gna.org/viewcvs/relax?rev=27716&view=rev
Log:
Merged revisions 27707-27714 via svnmerge from 
svn+ssh://bugman@xxxxxxxxxxx/svn/relax/trunk

........
  r27707 | bugman | 2015-02-20 16:16:02 +0100 (Fri, 20 Feb 2015) | 6 lines
  
  Python 3 fix for the new internal structural object MolContainer._sort() 
method.
  
  The list() builtin function is required to convert the output of the 
range() function into a true
  list in Python 3, so that the list.sort() method can be accessed.
........
  r27708 | bugman | 2015-02-20 16:46:14 +0100 (Fri, 20 Feb 2015) | 7 lines
  
  Python 3 fix for the Test_msa.test_central_star unit test.
  
  This is from the _lib._sequence_alignment.test_msa unit test module.  The 
logic of range() + range()
  does not work in Python 3, so the range function calls are now wrapped in 
list() function calls to
  convert to the correct data structure type.
........
  r27709 | bugman | 2015-02-20 16:51:33 +0100 (Fri, 20 Feb 2015) | 6 lines
  
  Python 3 fix for the internal structural object MolContainer._sort_key() 
method.
  
  This method is used as the key for the sort() function.  However in Python 
3, the key cannot be
  None.  So now if the residue number is None, the value of 0 is returned 
instead.
........
  r27710 | bugman | 2015-02-20 16:54:24 +0100 (Fri, 20 Feb 2015) | 6 lines
  
  Python 3 fix for the 
pipe_control.structure.main.assemble_structural_coordinates() function.
  
  This affects most of the structure user functions.  This was another case 
of requiring the list()
  built in function to create a list object from an iterator.
........
  r27711 | bugman | 2015-02-20 16:56:44 +0100 (Fri, 20 Feb 2015) | 5 lines
  
  Another Python 3 list() fix for the structure user functions.
  
  This time the problem was in the 
pipe_control.structure.main.sequence_alignment() function.
........
  r27712 | bugman | 2015-02-23 10:06:59 +0100 (Mon, 23 Feb 2015) | 9 lines
  
  Large speed up of the structure.web_of_motion user function.
  
  With the introduction of the _sort() internal structural object method and 
it being called by the
  add_atom(), the structure.web_of_motion user function was now painfully 
slow.  As sorting the
  structural data is unnecessary for the backend of this user function, the 
add_atom() boolean
  argument 'sort' has been added to turn the sorting on and off, and the 
structure.web_of_motion
  backend now sets this to False.
........
  r27713 | bugman | 2015-02-23 11:49:05 +0100 (Mon, 23 Feb 2015) | 6 lines
  
  Fix for the internal structural object unit test 
Test_object.test_add_atom_sort.
  
  This test of the _lib._structure._internal.test_object unit test module now 
requires the sort
  argument set to True when calling the add_atom() method.
........
  r27714 | bugman | 2015-02-23 11:50:54 +0100 (Mon, 23 Feb 2015) | 3 lines
  
  Fix for a RelaxError message from the internal structural object when 
validating models.
........

Modified:
    branches/frame_order_cleanup/   (props changed)
    branches/frame_order_cleanup/lib/structure/internal/molecules.py
    branches/frame_order_cleanup/lib/structure/internal/object.py
    branches/frame_order_cleanup/pipe_control/structure/main.py
    
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_sequence_alignment/test_msa.py
    
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/test_object.py

Propchange: branches/frame_order_cleanup/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Feb 24 09:35:17 2015
@@ -1 +1 @@
-/trunk:1-27704
+/trunk:1-27715

Modified: branches/frame_order_cleanup/lib/structure/internal/molecules.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/structure/internal/molecules.py?rev=27716&r1=27715&r2=27716&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/structure/internal/molecules.py    
(original)
+++ branches/frame_order_cleanup/lib/structure/internal/molecules.py    Tue 
Feb 24 09:35:17 2015
@@ -259,7 +259,7 @@
         """Sort all structural data."""
 
         # Create an index list for sorting the structural data.
-        indices = range(len(self.atom_name))
+        indices = list(range(len(self.atom_name)))
         indices.sort(key=self._sort_key)
 
         # Sort all lists.
@@ -284,6 +284,10 @@
 
     def _sort_key(self, i):
         """Return the information for sorting the sequence data."""
+
+        # Python 3 - return 0 instead of None.
+        if self.res_num[i] == None:
+            return 0
 
         # Sort based on residue number.
         return self.res_num[i]

Modified: branches/frame_order_cleanup/lib/structure/internal/object.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/structure/internal/object.py?rev=27716&r1=27715&r2=27716&view=diff
==============================================================================
--- branches/frame_order_cleanup/lib/structure/internal/object.py       
(original)
+++ branches/frame_order_cleanup/lib/structure/internal/object.py       Tue 
Feb 24 09:35:17 2015
@@ -1095,7 +1095,7 @@
         return sheet
 
 
-    def add_atom(self, mol_name=None, atom_name=None, res_name=None, 
res_num=None, pos=[None, None, None], element=None, atom_num=None, 
chain_id=None, segment_id=None, pdb_record=None):
+    def add_atom(self, mol_name=None, atom_name=None, res_name=None, 
res_num=None, pos=[None, None, None], element=None, atom_num=None, 
chain_id=None, segment_id=None, pdb_record=None, sort=False):
         """Add a new atom to the structural data object.
 
         @keyword mol_name:      The name of the molecule.
@@ -1118,6 +1118,8 @@
         @type segment_id:       str or None
         @keyword pdb_record:    The optional PDB record name, e.g. 'ATOM' or 
'HETATM'.
         @type pdb_record:       str or None
+        @keyword sort:          A flag which if True will cause the 
structural data to be sorted after adding the atom.
+        @type sort:             bool
         """
 
         # Add a model if not present.
@@ -1155,7 +1157,8 @@
             mol.atom_add(atom_name=atom_name, res_name=res_name, 
res_num=res_num, pos=model_pos, element=element, atom_num=atom_num, 
chain_id=chain_id, segment_id=segment_id, pdb_record=pdb_record)
 
             # Sort.
-            mol._sort()
+            if sort:
+                mol._sort()
 
 
     def add_coordinates(self, coord=None, mol_names=None, res_names=None, 
res_nums=None, atom_names=None, elements=None, set_mol_name=None, 
set_model_num=None):
@@ -2852,7 +2855,7 @@
                     if not same:
                         print("%-6s%5s %4s%1s%3s %1s%4s%1s   
%8s%8s%8s%6.2f%6.2f      %4s%2s%2s" % ('ATOM', mol.atom_num[k], 
self._translate(mol.atom_name[k]), '', self._translate(mol.res_name[k]), 
self._translate(mol.chain_id[k]), self._translate(mol.res_num[k]), '', '#', 
'#', '#', 1.0, 0, self._translate(mol.seg_id[k]), 
self._translate(mol.element[k]), ''))
                         print("%-6s%5s %4s%1s%3s %1s%4s%1s   
%8s%8s%8s%6.2f%6.2f      %4s%2s%2s" % ('ATOM', mol_ref.atom_num[k], 
self._translate(mol_ref.atom_name[k]), '', 
self._translate(mol_ref.res_name[k]), self._translate(mol_ref.chain_id[k]), 
self._translate(mol_ref.res_num[k]), '', '#', '#', '#', 1.0, 0, 
self._translate(mol_ref.seg_id[k]), self._translate(mol_ref.element[k]), ''))
-                        raise RelaxError("The atoms of model %i do not match 
the first model." % self.structural_data[i].num)
+                        raise RelaxError("The atoms of model %s do not match 
the first model." % self.structural_data[i].num)
 
         # Final printout.
         if verbosity:

Modified: branches/frame_order_cleanup/pipe_control/structure/main.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/pipe_control/structure/main.py?rev=27716&r1=27715&r2=27716&view=diff
==============================================================================
--- branches/frame_order_cleanup/pipe_control/structure/main.py (original)
+++ branches/frame_order_cleanup/pipe_control/structure/main.py Tue Feb 24 
09:35:17 2015
@@ -89,7 +89,7 @@
         cdp.structure = Internal()
 
     # Add the atoms.
-    cdp.structure.add_atom(mol_name=mol_name, atom_name=atom_name, 
res_name=res_name, res_num=res_num, pos=pos, element=element, 
atom_num=atom_num, chain_id=chain_id, segment_id=segment_id, 
pdb_record=pdb_record)
+    cdp.structure.add_atom(mol_name=mol_name, atom_name=atom_name, 
res_name=res_name, res_num=res_num, pos=pos, element=element, 
atom_num=atom_num, chain_id=chain_id, segment_id=segment_id, 
pdb_record=pdb_record, sort=True)
 
 
 def add_model(model_num=None):
@@ -181,7 +181,7 @@
         for mol_index in range(num_mols):
             res_num_list.append([])
             for i in range(len(one_letter_codes[mol_index])):
-                key = res_nums[mol_index][i].keys()[0]
+                key = list(res_nums[mol_index][i].keys())[0]
                 res_num_list[mol_index].append(res_nums[mol_index][i][key])
 
         # Sequence alignment.
@@ -1275,7 +1275,7 @@
     for mol_index in range(num_mols):
         res_num_list.append([])
         for i in range(len(one_letter_codes[mol_index])):
-            key = res_nums[mol_index][i].keys()[0]
+            key = list(res_nums[mol_index][i].keys())[0]
             res_num_list[mol_index].append(res_nums[mol_index][i][key])
 
     # MSA.
@@ -1655,7 +1655,7 @@
         # Loop over the structures.
         for struct_index in range(len(ids)):
             # Add the atom.
-            web.add_atom(mol_name=mol_names[atom_index], 
atom_name=atom_names[atom_index], res_name=res_names[atom_index], 
res_num=res_nums[atom_index], pos=coord[struct_index, atom_index], 
element=elements[atom_index])
+            web.add_atom(mol_name=mol_names[atom_index], 
atom_name=atom_names[atom_index], res_name=res_names[atom_index], 
res_num=res_nums[atom_index], pos=coord[struct_index, atom_index], 
element=elements[atom_index], sort=False)
 
         # Loop over the structures again, this time twice.
         for k in range(len(ids)):

Modified: 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_sequence_alignment/test_msa.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/unit_tests/_lib/_sequence_alignment/test_msa.py?rev=27716&r1=27715&r2=27716&view=diff
==============================================================================
--- 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_sequence_alignment/test_msa.py
     (original)
+++ 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_sequence_alignment/test_msa.py
     Tue Feb 24 09:35:17 2015
@@ -90,11 +90,11 @@
 
         # The gap matrix.
         real_gaps = zeros((3, 34), int16)
-        for i in (range(4) + range(8, 12) + [17] + range(20, 34)):
+        for i in (list(range(4)) + list(range(8, 12)) + [17] + 
list(range(20, 34))):
             real_gaps[0, i] = 1
         for i in range(8, 12):
             real_gaps[1, i] = 1
-        for i in (range(3) + [15, 32, 33]):
+        for i in (list(range(3)) + [15, 32, 33]):
             real_gaps[2, i] = 1
         for i in range(3):
             for j in range(34):

Modified: 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/test_object.py?rev=27716&r1=27715&r2=27716&view=diff
==============================================================================
--- 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
 (original)
+++ 
branches/frame_order_cleanup/test_suite/unit_tests/_lib/_structure/_internal/test_object.py
 Tue Feb 24 09:35:17 2015
@@ -34,18 +34,18 @@
         struct = object.Internal()
 
         # Create three molecules 'X', 'Y', and 'Z' with some connected atoms.
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=1, 
mol_name='X', pos=[1., 0., -1.], element='S')
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=1, 
mol_name='Y', pos=[0., 0., 0.], element='S')
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=1, 
mol_name='Z', pos=[-1., 0., 1.], element='S')
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=3, 
mol_name='X', pos=[1., 2., -1.], element='S')
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=3, 
mol_name='Y', pos=[0., 2., 0.], element='S')
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=3, 
mol_name='Z', pos=[-1., 2., 1.], element='S')
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=1, 
mol_name='X', pos=[1., 0., -1.], element='S', sort=True)
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=1, 
mol_name='Y', pos=[0., 0., 0.], element='S', sort=True)
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=1, 
mol_name='Z', pos=[-1., 0., 1.], element='S', sort=True)
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=3, 
mol_name='X', pos=[1., 2., -1.], element='S', sort=True)
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=3, 
mol_name='Y', pos=[0., 2., 0.], element='S', sort=True)
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=3, 
mol_name='Z', pos=[-1., 2., 1.], element='S', sort=True)
         struct.connect_atom(mol_name='X', index1=0, index2=1)
         struct.connect_atom(mol_name='Y', index1=0, index2=1)
         struct.connect_atom(mol_name='Z', index1=0, index2=1)
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=2, 
mol_name='X', pos=[1., 20., -1.], element='S')
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=2, 
mol_name='Y', pos=[0., 20., 0.], element='S')
-        struct.add_atom(atom_name='A', res_name='UNK', res_num=2, 
mol_name='Z', pos=[-1., 20., 1.], element='S')
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=2, 
mol_name='X', pos=[1., 20., -1.], element='S', sort=True)
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=2, 
mol_name='Y', pos=[0., 20., 0.], element='S', sort=True)
+        struct.add_atom(atom_name='A', res_name='UNK', res_num=2, 
mol_name='Z', pos=[-1., 20., 1.], element='S', sort=True)
 
         # The sorted data.
         data = [[




Related Messages


Powered by MHonArc, Updated Tue Feb 24 12:20:02 2015