Skip to content

Commit

Permalink
add write tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Nov 3, 2023
1 parent cf4c9f3 commit eb230a2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
10 changes: 10 additions & 0 deletions prody/tests/datafiles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,16 @@
'anisousA': array([[1.3327, 0.8826, 0.7048, 0.0444, 0.3365, 0.1618]]),
'anisousB': array([[1.3306, 0.8825, 0.7058, 0.0438, 0.338 , 0.1608]])
},
'6flr_sel': {
'pdb': '6flr',
'file': 'pdb6flr_B234.pdb',
'atoms': 1,
'ca_atoms': 1,
'models': 2,
'biomols': 1,
'anisousA': array([[1.3327, 0.8826, 0.7048, 0.0444, 0.3365, 0.1618]]),
'anisousB': array([[1.3306, 0.8825, 0.7058, 0.0438, 0.338 , 0.1608]])
},
'gromacs': {
'pdb': '6fpj',
'file': 'pdb6fpj_Bb_fixed_solv_ions.pdb',
Expand Down
11 changes: 11 additions & 0 deletions prody/tests/datafiles/pdb6flr_B234.pdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
REMARK Selection 'resname HIS and...234 and name CA'
HELIX 21 AC3 HIS B 234 HIS B 234 1 1
MODEL 1
ATOM 1 CA AHIS B 234 14.092 -10.803 78.631 0.50 76.86 C
ANISOU 1 CA AHIS B 234 13327 8826 7048 444 3365 1618 C
ENDMDL
MODEL 2
ATOM 1 CA HIS B 234 13.993 -10.729 78.621 0.50 76.86 C
ANISOU 1 CA HIS B 234 13306 8825 7058 438 3380 1608 C
ENDMDL
END
29 changes: 28 additions & 1 deletion prody/tests/proteins/test_pdbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ def setUp(self):
self.hex_ter = parsePDB(DATA_FILES['hex_ter']['path'])
self.h36_ter = parsePDB(DATA_FILES['h36_ter']['path'])

self.altlocs = DATA_FILES['6flr']
self.altloc_full = parsePDB(self.altlocs, altloc=None)
self.altloc_sel = parsePDB(DATA_FILES['6flr_sel'])

msg = 'user does not have write access to temp dir {0:s}'.format(TEMPDIR)

@dec.slow
Expand Down Expand Up @@ -421,7 +425,30 @@ def testWritingHybrid36Ter(self):

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')

def testWritingHexTer(self):
"""Test if output from writing hexadecimal with TER lines is as expected."""

hisB234 = self.altloc_full.select('resname HIS and chain B and resnum 234 and name CA')
out = writePDB(self.tmp, hisB234)

fi = open(out, 'r')
lines1 = fi.readlines()
fi.close()

fi = open(self.altloc_sel, 'r')
lines2 = fi.readlines()
fi.close()

self.assertEqual(len(lines1), len(lines2),
'writePDB failed to write enough lines for 6flr selection with altloc None (11)')

self.assertEqual(lines1[4], lines2[4],
'writePDB failed to write correct ANISOU line 4 for 6flr selection with altloc None')

self.assertEqual(lines1[8], lines2[8],
'writePDB failed to write correct ANISOU line 8 for 6flr selection with altloc None')

@dec.slow
def tearDown(self):
Expand Down

0 comments on commit eb230a2

Please sign in to comment.