mailr22510 - in /branches/double_rotor: ./ lib/structure/internal/ test_suite/shared_data/structures/ test_suite/system_tests/


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

Header


Content

Posted by edward on March 19, 2014 - 08:54:
Author: bugman
Date: Wed Mar 19 08:54:24 2014
New Revision: 22510

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

........
  r22508 | bugman | 2014-03-19 08:37:35 +0100 (Wed, 19 Mar 2014) | 7 lines
  
  Created the Structure.test_bug_21814_pdb_no_80_space_padding system test.
  
  This is for catching bug #21814 (https://gna.org/bugs/?21814), the PDB 
reading failure when the PDB
  records are not padded to 80 spaces.  The PDB file used for the test is the 
same file as attached to
  the bug report.
........
  r22509 | bugman | 2014-03-19 08:53:20 +0100 (Wed, 19 Mar 2014) | 9 lines
  
  Fix for bug #21814 (https://gna.org/bugs/?21814).
  
  This is the PDB reading failure when the PDB records are not padded to 80 
spaces.  The fix is
  simple, all PDB records are pre-validated.  This includes removing all 
newline characters and
  padding each PDB record to 80 spaces when needed.  This will however add an 
overhead cost -- the
  internal PDB reader will now be slower.  However corrupted PDB files, 
produced by MODELLER for
  example, not padded to 80 spaces will now be better supported.
........

Added:
    
branches/double_rotor/test_suite/shared_data/structures/SpUreE_dimer_H_new.pdb.bz2
      - copied unchanged from r22509, 
trunk/test_suite/shared_data/structures/SpUreE_dimer_H_new.pdb.bz2
Modified:
    branches/double_rotor/   (props changed)
    branches/double_rotor/lib/structure/internal/object.py
    branches/double_rotor/test_suite/system_tests/structure.py

Propchange: branches/double_rotor/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar 19 08:54:24 2014
@@ -1 +1 @@
-/trunk:1-22506
+/trunk:1-22509

Modified: branches/double_rotor/lib/structure/internal/object.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/lib/structure/internal/object.py?rev=22510&r1=22509&r2=22510&view=diff
==============================================================================
--- branches/double_rotor/lib/structure/internal/object.py      (original)
+++ branches/double_rotor/lib/structure/internal/object.py      Wed Mar 19 
08:54:24 2014
@@ -760,6 +760,31 @@
         # Check the other lengths.
         if len(struct.bonded) != num and len(struct.chain_id) != num and 
len(struct.element) != num and len(struct.pdb_record) != num and 
len(struct.res_name) != num and len(struct.res_num) != num and 
len(struct.seg_id) != num and len(struct.x) != num and len(struct.y) != num 
and len(struct.z) != num:
             raise RelaxError("The structural data is invalid.")
+
+
+    def _validate_records(self, lines):
+        """Make sure all PDB records are 80 char in length, padding with 
whitespace when needed.
+
+        All newline characters are stripped from the records as well.
+
+
+        @param lines:       All lines of the PDB file.
+        @type lines:        list of str
+        @return:            The padded PDB lines.
+        @rtype:             list of str
+        """
+
+        # Loop over the lines.
+        for i in range(len(lines)):
+            # Strip the newline character.
+            lines[i] = lines[i].rstrip('\r\n')
+
+            # Pad if needed.
+            if len(lines[i]) != 80:
+                lines[i] = "%-80s" % lines[i]
+
+        # Return the fixed lines.
+        return lines
 
 
     def _mol_type(self, mol):
@@ -1806,6 +1831,9 @@
         if pdb_lines == []:
             raise RelaxError("The PDB file is empty.")
 
+        # Pre-process the lines, fixing PDB violations.
+        pdb_lines = self._validate_records(pdb_lines)
+
         # Process the different sections.
         pdb_lines = self._parse_pdb_title(pdb_lines)
         pdb_lines = self._parse_pdb_prim_struct(pdb_lines)

Modified: branches/double_rotor/test_suite/system_tests/structure.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/double_rotor/test_suite/system_tests/structure.py?rev=22510&r1=22509&r2=22510&view=diff
==============================================================================
--- branches/double_rotor/test_suite/system_tests/structure.py  (original)
+++ branches/double_rotor/test_suite/system_tests/structure.py  Wed Mar 19 
08:54:24 2014
@@ -132,6 +132,16 @@
         lines = file.readlines()
         for i in range(len(lines)):
             self.assertEqual(contents[i], lines[i])
+
+
+    def test_bug_21814_pdb_no_80_space_padding(self):
+        """Catch U{bug #21814<https://gna.org/bugs/?21814>}, the PDB reading 
failure when not padded to 80 spaces."""
+
+        # Path of the structure file.
+        path = status.install_path + 
sep+'test_suite'+sep+'shared_data'+sep+'structures'
+
+        # Load the file.
+        self.interpreter.structure.read_pdb('SpUreE_dimer_H_new', dir=path)
 
 
     def test_delete_empty(self):




Related Messages


Powered by MHonArc, Updated Wed Mar 19 11:00:02 2014