forked from prody/ProDy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request prody#1860 from jamesmkrieger/pqr_fix
split pqr coords by line positions when needed
- Loading branch information
Showing
8 changed files
with
213 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ATOM 1 C STP 1 -26.417 62.269-123.283 0.00 3.30 | ||
ATOM 2 O STP 1 -30.495 65.669-122.669 0.00 3.08 | ||
ATOM 3 O STP 1 -25.792 61.516-124.085 0.00 3.32 | ||
ATOM 4 O STP 1 -25.262 61.506-124.230 0.00 3.05 | ||
ATOM 5 O STP 1 -30.521 65.070-122.439 0.00 3.05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ATOM 1 N VAL 1 16.783 48.812 26.447 0.0577 1.550 | ||
ATOM 2 H1 VAL 1 15.848 48.422 26.463 0.2272 1.200 | ||
ATOM 3 H2 VAL 1 16.734 49.803 26.251 0.2272 1.200 | ||
ATOM 4 H3 VAL 1 17.195 48.663 27.359 0.2272 1.200 | ||
ATOM 5 CA VAL 1 17.591 48.101 25.416 -0.0054 1.700 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ATOM 1 C STP 1 -26.417 62.269-123.283 0.00 3.30 | ||
ATOM 2 O STP 1 -30.495 65.669-122.669 0.00 3.08 | ||
ATOM 3 O STP 1 -25.792 61.516-124.085 0.00 3.32 | ||
ATOM 4 O STP 1 -25.262 61.506-124.230 0.00 3.05 | ||
ATOM 5 O STP 1 -30.521 65.070-122.439 0.00 3.05 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ATOM 29 P G 11 -17.189 -6.642 -23.827 0.00000000 0.000 | ||
ATOM 30 C5' G 11 -15.744 -5.986 -25.911 0.00000000 0.000 | ||
ATOM 31 O5' G 11 -16.783 -5.642 -25.005 0.00000000 0.000 | ||
ATOM 32 C4' G 11 -15.722 -5.012 -27.074 0.00000000 0.000 | ||
ATOM 33 O4' G 11 -16.947 -5.133 -27.838 0.00000000 0.000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
"""This module contains unit tests for :mod:`~prody.proteins`.""" | ||
|
||
import os | ||
|
||
import numpy as np | ||
from numpy.testing import * | ||
|
||
from prody.utilities import importDec | ||
dec = importDec() | ||
|
||
from prody import * | ||
from prody import LOGGER | ||
from prody.utilities import which | ||
from prody.tests import TEMPDIR, unittest | ||
from prody.tests.datafiles import * | ||
|
||
LOGGER.verbosity = 'none' | ||
|
||
class TestParsePRQ(unittest.TestCase): | ||
|
||
def setUp(self): | ||
"""Set PQR file data.""" | ||
|
||
self.pqr1 = DATA_FILES['pqrUnknown'] | ||
self.pqr2 = DATA_FILES['pqrTranscomp'] | ||
self.pqr3 = DATA_FILES['pqrFpocket'] | ||
self.pqr4 = DATA_FILES['pqrPymol'] | ||
|
||
def testExamplePQR(self): | ||
"""Test the outcome of a simple parsing scenario with example 1 (unnamed).""" | ||
|
||
path = pathDatafile(self.pqr1['file']) | ||
ag = parsePQR(path) | ||
|
||
self.assertIsInstance(ag, prody.AtomGroup, | ||
'parsePQR failed to return an AtomGroup instance') | ||
|
||
self.assertEqual(ag.numAtoms(), self.pqr1['atoms'], | ||
'parsePQR failed to parse correct number of atoms') | ||
|
||
self.assertEqual(ag.numCoordsets(), self.pqr1['models'], | ||
'parsePQR failed to parse correct number of coordinate sets ' | ||
'(models)') | ||
|
||
self.assertEqual(ag.getTitle(), | ||
os.path.splitext(self.pqr1['file'])[0], | ||
'failed to set AtomGroup title based on filename') | ||
|
||
def testTranscompPQR(self): | ||
"""Test the outcome of a simple parsing scenario with transcomp example.""" | ||
|
||
path = pathDatafile(self.pqr2['file']) | ||
ag = parsePQR(path) | ||
|
||
self.assertIsInstance(ag, prody.AtomGroup, | ||
'parsePQR failed to return an AtomGroup instance') | ||
|
||
self.assertEqual(ag.numAtoms(), self.pqr2['atoms'], | ||
'parsePQR failed to parse correct number of atoms') | ||
|
||
self.assertEqual(ag.numCoordsets(), self.pqr2['models'], | ||
'parsePQR failed to parse correct number of coordinate sets ' | ||
'(models)') | ||
|
||
self.assertEqual(ag.getTitle(), | ||
os.path.splitext(self.pqr2['file'])[0], | ||
'failed to set AtomGroup title based on filename') | ||
|
||
def testFpocketPQR(self): | ||
"""Test the outcome of a simple parsing scenario with example 1 (unnamed).""" | ||
|
||
path = pathDatafile(self.pqr3['file']) | ||
ag = parsePQR(path) | ||
|
||
self.assertIsInstance(ag, prody.AtomGroup, | ||
'parsePQR failed to return an AtomGroup instance') | ||
|
||
self.assertEqual(ag.numAtoms(), self.pqr3['atoms'], | ||
'parsePQR failed to parse correct number of atoms') | ||
|
||
self.assertEqual(ag.numCoordsets(), self.pqr3['models'], | ||
'parsePQR failed to parse correct number of coordinate sets ' | ||
'(models)') | ||
|
||
self.assertEqual(ag.getTitle(), | ||
os.path.splitext(self.pqr3['file'])[0], | ||
'failed to set AtomGroup title based on filename') | ||
|
||
def testPymolPQR(self): | ||
"""Test the outcome of a simple parsing scenario with example 1 (unnamed).""" | ||
|
||
path = pathDatafile(self.pqr4['file']) | ||
ag = parsePQR(path) | ||
|
||
self.assertIsInstance(ag, prody.AtomGroup, | ||
'parsePQR failed to return an AtomGroup instance') | ||
|
||
self.assertEqual(ag.numAtoms(), self.pqr4['atoms'], | ||
'parsePQR failed to parse correct number of atoms') | ||
|
||
self.assertEqual(ag.numCoordsets(), self.pqr4['models'], | ||
'parsePQR failed to parse correct number of coordinate sets ' | ||
'(models)') | ||
|
||
self.assertEqual(ag.getTitle(), | ||
os.path.splitext(self.pqr4['file'])[0], | ||
'failed to set AtomGroup title based on filename') | ||
|
||
def testTitleArgument(self): | ||
"""Test outcome of *title* argument.""" | ||
|
||
path = pathDatafile(self.pqr1['file']) | ||
title = 'small protein' | ||
self.assertEqual(parsePQR(path, title=title).getTitle(), | ||
title, 'parsePQR failed to set user given title') | ||
|
||
def testSubsetArgument(self): | ||
"""Test outcome of valid and invalid *subset* arguments.""" | ||
|
||
path = pathDatafile(self.pqr2['file']) | ||
self.assertRaises(TypeError, parsePQR, path, subset=['A']) | ||
self.assertEqual(parsePQR(path, subset='ca').numAtoms(), 1, | ||
'failed to parse correct number of "ca" atoms') | ||
self.assertEqual(parsePQR(path, subset='bb').numAtoms(), 2, | ||
'failed to parse correct number of "bb" atoms') | ||
|
||
def testAgArgument(self): | ||
"""Test outcome of 2 invalid and 2 valid *ag* arguments.""" | ||
|
||
path = pathDatafile(self.pqr1['file']) | ||
self.assertRaises(TypeError, parsePQR, path, ag='AtomGroup') | ||
|
||
ag = prody.AtomGroup('One atom') | ||
ag.setCoords(np.array([[0., 0., 0.]])) | ||
self.assertRaises(ValueError, parsePQR, path, ag=ag) | ||
|
||
ag = prody.AtomGroup('Test') | ||
self.assertEqual(parsePQR(path, ag=ag).numAtoms(), | ||
self.pqr1['atoms'], | ||
'parsePQR failed to parse correct number of atoms') | ||
|
||
ag = prody.AtomGroup('Test') | ||
ag.setCoords(np.array([[0., 0., 0.]]*5)) | ||
self.assertEqual(parsePQR(path, ag=ag).numAtoms(), | ||
self.pqr1['atoms'], | ||
'parsePQR failed to parse correct number of atoms') |