Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ Chronological list of authors
- Sai Udayagiri
- Apoorva Verma
- Aryaman Chaudhri
- Virvi Huta

External code
-------------
Expand Down
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The rules for this file:
spyke7, talagayev, tanii1125, BradyAJohnston, hejamu, jeremyleung521,
harshitgajjela-droid, kunjsinha, aygarwal, jauy123, Dreamstick9,
ollyfutur, Amarendra22, charity-g, ParthUppal523, apoorva-01, RMeli,
raulloiscuns, Aryaman-Chaudhri
raulloiscuns, Aryaman-Chaudhri, virvihuta

* 2.11.0

Expand Down Expand Up @@ -101,6 +101,8 @@ Enhancements
Changes
* The msd.py inside analysis is changed, and ProgressBar is implemented inside
_conclude_simple and _conclude_fft functions instead of tqdm (Issue #5144, PR #5153)
* Ported `test_pqr.py` to use the new `BaseReaderTest`/`BaseWriterTest`
classes (Issue #516).

Deprecations

Expand Down
60 changes: 56 additions & 4 deletions testsuite/MDAnalysisTests/coordinates/test_pqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
#
import MDAnalysis as mda
import os
from MDAnalysis.coordinates.PQR import PQRReader, PQRWriter
from MDAnalysisTests.coordinates.base import (
BaseReference,
BaseWriterTest,
BaseReaderTest,
)
import pytest

from numpy.testing import (
Expand All @@ -31,11 +36,11 @@

from MDAnalysisTests.coordinates.reference import RefAdKSmall
from MDAnalysisTests.coordinates.base import _SingleFrameReader
from MDAnalysisTests.datafiles import PQR
from MDAnalysisTests.datafiles import PQR, COORDINATES_PQR
from MDAnalysisTests import make_Universe


class TestPQRReader(_SingleFrameReader):
class TestPQRReaderOld(_SingleFrameReader):
__test__ = True

def setUp(self):
Expand Down Expand Up @@ -85,7 +90,7 @@ def test_dimensions(self):
assert self.universe.dimensions is None


class TestPQRWriter(RefAdKSmall):
class TestPQRWriterOld(RefAdKSmall):
@staticmethod
@pytest.fixture
def universe():
Expand Down Expand Up @@ -188,6 +193,53 @@ def test_total_charge(self, universe, tmpdir):
)


class PQRReference(BaseReference):
def __init__(self):
super(PQRReference, self).__init__()
self.trajectory = COORDINATES_PQR
self.topology = COORDINATES_PQR
self.reader = PQRReader
self.writer = PQRWriter
self.ext = "pqr"
self.n_frames = 1
self.prec = 3
self.totaltime = 0
self.container_format = False
self.dimensions = None
self.volume = 0


class TestPQRReader(BaseReaderTest):
@staticmethod
@pytest.fixture(scope="class")
def ref():
return PQRReference()

def test_get_writer_1(self, ref, reader, tmpdir):
with tmpdir.as_cwd():
outfile = "test_writer." + ref.ext
with reader.Writer(outfile) as W:
assert_equal(isinstance(W, ref.writer), True)

def test_get_writer_2(self, ref, reader, tmpdir):
with tmpdir.as_cwd():
outfile = "test_writer." + ref.ext
with reader.Writer(outfile, n_atoms=100) as W:
assert_equal(isinstance(W, ref.writer), True)


class TestPQRWriter(BaseWriterTest):
@staticmethod
@pytest.fixture(scope="class")
def ref():
return PQRReference()

def test_no_container(self, ref, tmpdir):
with tmpdir.as_cwd():
# PQRWriter doesnt require n_atoms at construction time
ref.writer("foo")


class TestPQRWriterMissingAttrs(object):
# pqr requires names, resids, resnames, segids, radii, charges
@staticmethod
Expand Down
6 changes: 6 additions & 0 deletions testsuite/MDAnalysisTests/data/coordinates/test.pqr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
REMARK 1 Test case for MDAnalysis
ATOM 1 CA MET 1 0.000 1.000 2.000 0.0000 1.0000
ATOM 2 CA ARG 2 3.000 4.000 5.000 0.0000 1.0000
ATOM 3 CA ILE 3 6.000 7.000 8.000 0.0000 1.0000
ATOM 4 CA LYS 4 9.000 10.000 11.000 0.0000 1.0000
ATOM 5 CA LEU 5 12.000 13.000 14.000 0.0000 1.0000
2 changes: 2 additions & 0 deletions testsuite/MDAnalysisTests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
"COORDINATES_XYZ",
"COORDINATES_XYZ_BZ2",
"COORDINATES_GRO",
"COORDINATES_PQR",
"COORDINATES_GRO_INCOMPLETE_VELOCITY",
"Martini_membrane_gro", # for testing the leaflet finder
"COORDINATES_XTC",
Expand Down Expand Up @@ -431,6 +432,7 @@
GRO_huge_box = (_data_ref / "huge_box.gro").as_posix()

COORDINATES_GRO = (_data_ref / "coordinates/test.gro").as_posix()
COORDINATES_PQR = (_data_ref / "coordinates/test.pqr").as_posix()
COORDINATES_GRO_INCOMPLETE_VELOCITY = (
_data_ref / "coordinates/test_incomplete_vel.gro"
).as_posix()
Expand Down
Loading