From 05f7211aab016aae1c47427d94b3ae4c1d8ccb2d Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 11 Aug 2023 16:36:53 +0200 Subject: [PATCH 1/3] fix secstr writing --- prody/proteins/pdbfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prody/proteins/pdbfile.py b/prody/proteins/pdbfile.py index 92fb333cf..8bf966de8 100644 --- a/prody/proteins/pdbfile.py +++ b/prody/proteins/pdbfile.py @@ -1057,13 +1057,13 @@ def _evalAltlocs(atomgroup, altloc, chainids, resnums, resnames, atomnames): # ' %5d\n') HELIXLINE = ('HELIX {serNum:3d} {helixID:>3s} ' - '{initResName:<3s}{initChainID:2s} {initSeqNum:4d}{initICode:1s} ' - '{endResName:<3s}{endChainID:2s} {endSeqNum:4d}{endICode:1s}' - '{helixClass:2d} {length:5d}\n') + '{initResName:<3s}{initChainID:>2s} {initSeqNum:4d}{initICode:1s} ' + '{endResName:<3s}{endChainID:>2s} {endSeqNum:4d}{endICode:1s}' + '{helixClass:2d} {length:5d} \n') SHEETLINE = ('SHEET {strand:3d} {sheetID:>3s}{numStrands:2d} ' - '{initResName:3s}{initChainID:2s}{initSeqNum:4d}{initICode:1s} ' - '{endResName:3s}{endChainID:2s}{endSeqNum:4d}{endICode:1s}{sense:2d} \n') + '{initResName:3s}{initChainID:>2s}{initSeqNum:4d}{initICode:1s} ' + '{endResName:3s}{endChainID:>2s}{endSeqNum:4d}{endICode:1s}{sense:2d} \n') PDBLINE_LT100K = ('%-6s%5d %-4s%1s%-3s%2s%4d%1s ' '%8.3f%8.3f%8.3f%6.2f%6.2f ' From 87c49a189b50d0145caa732471f4c9505a148bbf Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 11 Aug 2023 16:53:33 +0200 Subject: [PATCH 2/3] add secstr write test --- prody/tests/proteins/test_pdbfile.py | 29 +++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/prody/tests/proteins/test_pdbfile.py b/prody/tests/proteins/test_pdbfile.py index d47902f49..7efa2a585 100644 --- a/prody/tests/proteins/test_pdbfile.py +++ b/prody/tests/proteins/test_pdbfile.py @@ -209,6 +209,8 @@ def setUp(self): self.ag = parsePDB(self.pdb['path']) self.tmp = os.path.join(TEMPDIR, 'test.pdb') + self.ubi = parsePDB(DATA_FILES['1ubi']['path']) + self.hex = parsePDB(DATA_FILES['hex']['path']) self.h36 = parsePDB(DATA_FILES['h36']['path']) @@ -279,11 +281,20 @@ def testWritingHybrid36(self): serial_99999_line = lines[99999] self.assertEqual(serial_99999_line[6:11], '99999', - 'writePDB failed to write correct pre-h36 serial') + 'writePDB failed to write correct pre-h36 serial') serial_A0000_line = lines[100000] self.assertEqual(serial_A0000_line[6:11], 'A0000', - 'writePDB failed to write correct h36 serial') + 'writePDB failed to write correct h36 serial') + + @dec.slow + @unittest.skipUnless(os.access(TEMPDIR, os.W_OK), msg) + def testWritingSecstrs(self): + """Test if output from writing secstrs is as expected.""" + + out = writePDB(self.tmp, self.ubi) + ubi_new = parsePDB(out) + self.assertListEqual(list(self.ubi.getSecstrs()), list(ubi_new.getSecstrs())) @dec.slow @unittest.skipUnless(os.access(TEMPDIR, os.W_OK), msg) @@ -299,13 +310,6 @@ def testModelArgument(self): assert_equal(out.getCoords(), self.ag.getCoordsets(i), 'failed to write model {0} coordinates correctly'.format(i+1)) - @dec.slow - def tearDown(self): - """Remove test file.""" - - if os.path.isfile(self.tmp): - os.remove(self.tmp) - @dec.slow @unittest.skipUnless(os.access(TEMPDIR, os.W_OK), msg) def testWritingHexTer(self): @@ -366,6 +370,13 @@ def testWritingHybrid36Ter(self): self.assertEqual(serial_A0000_line[6:11], 'A0000', 'writePDB failed to write correct h36 serial') + @dec.slow + def tearDown(self): + """Remove test file.""" + + if os.path.isfile(self.tmp): + os.remove(self.tmp) + class TestParsePDBHeaderAndAllModels(unittest.TestCase): From d51db04b7946ec4e8ad85484d637c1c55264c836 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 11 Aug 2023 17:06:24 +0200 Subject: [PATCH 3/3] secstr write test with secondary true --- prody/tests/proteins/test_pdbfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prody/tests/proteins/test_pdbfile.py b/prody/tests/proteins/test_pdbfile.py index 7efa2a585..3f34f453a 100644 --- a/prody/tests/proteins/test_pdbfile.py +++ b/prody/tests/proteins/test_pdbfile.py @@ -209,7 +209,7 @@ def setUp(self): self.ag = parsePDB(self.pdb['path']) self.tmp = os.path.join(TEMPDIR, 'test.pdb') - self.ubi = parsePDB(DATA_FILES['1ubi']['path']) + self.ubi = parsePDB(DATA_FILES['1ubi']['path'], secondary=True) self.hex = parsePDB(DATA_FILES['hex']['path']) self.h36 = parsePDB(DATA_FILES['h36']['path']) @@ -293,7 +293,7 @@ def testWritingSecstrs(self): """Test if output from writing secstrs is as expected.""" out = writePDB(self.tmp, self.ubi) - ubi_new = parsePDB(out) + ubi_new = parsePDB(out, secondary=True) self.assertListEqual(list(self.ubi.getSecstrs()), list(ubi_new.getSecstrs())) @dec.slow