Author: bugman Date: Fri Feb 20 16:01:28 2015 New Revision: 27702 URL: http://svn.gna.org/viewcvs/relax?rev=27702&view=rev Log: Merged revisions 27698-27701 via svnmerge from svn+ssh://bug...@svn.gna.org/svn/relax/trunk
........ r27698 | bugman | 2015-02-20 14:56:11 +0100 (Fri, 20 Feb 2015) | 5 lines Added one more check to the Structure.test_bug_23295_ss_metadata_merge system test. The test would pass if no HELIX or SHEET records were to be written to the PDB file. ........ r27699 | bugman | 2015-02-20 15:41:11 +0100 (Fri, 20 Feb 2015) | 3 lines Fix for the Structure.test_bug_23295_ss_metadata_merge system test and additional printouts. ........ r27700 | bugman | 2015-02-20 15:49:23 +0100 (Fri, 20 Feb 2015) | 9 lines Bug fix for the SHEET PDB records created by the structure.write_pdb user function. The current and previous atom parts of the record were not being correctly formatted. This was simply using the %4s formatting string. However the PDB atom format is rather more complicated. To handle this, the new _handle_atom_name() helper function has been added to the lib.structure.pdb_write module. This is now used in the atom() and sheet() functions for consistently formatting the atom name field. ........ r27701 | bugman | 2015-02-20 15:50:52 +0100 (Fri, 20 Feb 2015) | 6 lines Fix for the Structure.test_pdb_combined_secondary_structure system test. The SHEET PDB record check was incorrect and was checking for the improperly formatted atom name field, which has now been fixed in relax. ........ Modified: branches/nmrglue/ (props changed) branches/nmrglue/lib/structure/internal/object.py branches/nmrglue/lib/structure/pdb_write.py branches/nmrglue/test_suite/system_tests/structure.py Propchange: branches/nmrglue/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Feb 20 16:01:28 2015 @@ -1 +1 @@ -/trunk:1-27695 +/trunk:1-27701 Modified: branches/nmrglue/lib/structure/internal/object.py URL: http://svn.gna.org/viewcvs/relax/branches/nmrglue/lib/structure/internal/object.py?rev=27702&r1=27701&r2=27702&view=diff ============================================================================== --- branches/nmrglue/lib/structure/internal/object.py (original) +++ branches/nmrglue/lib/structure/internal/object.py Fri Feb 20 16:01:28 2015 @@ -3070,15 +3070,8 @@ if mol.pdb_record[i] in [None, 'ATOM']: atom_record = True - # Handle the funky atom name alignment. From the PDB format documents: - # "Alignment of one-letter atom name such as C starts at column 14, while two-letter atom name such as FE starts at column 13." - if len(mol.atom_name[i]) == 1: - atom_name = " %s" % mol.atom_name[i] - else: - atom_name = "%s" % mol.atom_name[i] - # Write out. - pdb_write.atom(file, serial=ser_num, name=atom_name, res_name=mol.res_name[i], chain_id=CHAIN_ID_LIST[index], res_seq=mol.res_num[i], x=mol.x[i], y=mol.y[i], z=mol.z[i], occupancy=1.0, temp_factor=0, element=mol.element[i]) + pdb_write.atom(file, serial=ser_num, name=mol.atom_name[i], res_name=mol.res_name[i], chain_id=CHAIN_ID_LIST[index], res_seq=mol.res_num[i], x=mol.x[i], y=mol.y[i], z=mol.z[i], occupancy=1.0, temp_factor=0, element=mol.element[i]) num_atom += 1 ser_num += 1 Modified: branches/nmrglue/lib/structure/pdb_write.py URL: http://svn.gna.org/viewcvs/relax/branches/nmrglue/lib/structure/pdb_write.py?rev=27702&r1=27701&r2=27702&view=diff ============================================================================== --- branches/nmrglue/lib/structure/pdb_write.py (original) +++ branches/nmrglue/lib/structure/pdb_write.py Fri Feb 20 16:01:28 2015 @@ -30,6 +30,40 @@ # relax module imports. from lib.errors import RelaxError + + +def _handle_atom_name(name): + """Handle the funky PDB atom name alignment. + + From the PDB format documents: + + "Alignment of one-letter atom name such as C starts at column 14, while two-letter atom name such as FE starts at column 13." + + + @param name: The atom name. + @type name: str or None + @return: The whitespace padded and PDB formatted atom name. This will be exactly 4 characters. + @rtype: str + """ + + # Handle none. + if name == None: + name = " " + + # Single letter name. + if len(name) == 1: + name = " %s " % name + + # Two letter name. + elif len(name) == 2: + name = "%s " % name + + # Three letter name. + elif len(name) == 3: + name = "%s " % name + + # Return the name. + return name def _handle_none(value): @@ -283,7 +317,7 @@ text = "%-6s%5s %-4s%1s%3s %1s%4s%1s %8.3f%8.3f%8.3f%6.2f%6.2f %2s%2s" % ( 'ATOM', _handle_none(serial), - _handle_none(name), + _handle_atom_name(name), _handle_none(alt_loc), _handle_none(res_name), _handle_none(chain_id), @@ -1725,12 +1759,12 @@ _handle_none(end_seq_num), _handle_none(end_icode), _handle_none(sense), - _handle_none(cur_atom), + _handle_atom_name(cur_atom), _handle_none(cur_res_name), _handle_none(cur_chain_id), _handle_none(cur_res_seq), _handle_none(cur_icode), - _handle_none(prev_atom), + _handle_atom_name(prev_atom), _handle_none(prev_res_name), _handle_none(prev_chain_id), _handle_none(prev_res_seq), Modified: branches/nmrglue/test_suite/system_tests/structure.py URL: http://svn.gna.org/viewcvs/relax/branches/nmrglue/test_suite/system_tests/structure.py?rev=27702&r1=27701&r2=27702&view=diff ============================================================================== --- branches/nmrglue/test_suite/system_tests/structure.py (original) +++ branches/nmrglue/test_suite/system_tests/structure.py Fri Feb 20 16:01:28 2015 @@ -1036,10 +1036,15 @@ continue # Check the line. + print("\nOrig: %s" % repr(contents[index])) + print("New: %s" % repr(line)) self.assertEqual(contents[index], line) # Increment the secondary structure index. index += 1 + + # Check the count to make sure that secondary structure records have at all been created. + self.assertEqual(len(contents), index) def test_bug_sr_2998_broken_conect_records(self): @@ -4155,7 +4160,7 @@ "HELIX 7 3 THR B 117 ASP B 129 1 13 \n", "HELIX 8 4 TYR B 138 THR B 146 1 9 \n", "SHEET 1 A 2 TYR B 99 ILE B 100 0 \n", - "SHEET 2 A 2 VAL B 136 ASN B 137 -1 OVAL B 136 NILE B 100 \n" + "SHEET 2 A 2 VAL B 136 ASN B 137 -1 O VAL B 136 N ILE B 100 \n" ] # Check secondary structure contents of the created PDB file. _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-commits mailing list relax-commits@gna.org To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-commits