Skip to content

Commit

Permalink
one more test
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-24 committed Oct 8, 2023
1 parent d1ef0fe commit 7695b56
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 11 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,10 @@ def structure_fluoroethylene_psf():

with path_from_tests_files(pathlib.Path('tests_files/fluoroethylene.psf')).open() as f:
return Structure.from_psf(f)


@pytest.fixture(scope='module')
def structure_7water_psf():

with path_from_tests_files(pathlib.Path('tests_files/7H2O.psf')).open() as f:
return Structure.from_psf(f)
15 changes: 4 additions & 11 deletions tests/test_geometry_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,10 @@ def test_topology_make_fluoroethylene_ok(geometry_fluoroethylene, structure_fluo
assert bond in auto_topology.residues[0].bonds or reversed(bond) in auto_topology.residues[0].bonds


def test_structure_make_7waters_ok(geometry_7waters):
def test_structure_make_7waters_ok(geometry_7waters, structure_7water_psf):
maker = GeometryAnalyzer(geometry_7waters)
auto_structure = maker.structure()

assert auto_structure.resi_ids == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]
assert numpy.all(auto_structure.angles == [
(1, 0, 2),
(4, 3, 5),
(7, 6, 8),
(10, 9, 11),
(13, 12, 14),
(16, 15, 17),
(19, 18, 20)
])
assert auto_structure.resi_ids == structure_7water_psf.resi_ids
assert numpy.allclose(auto_structure.bonds, structure_7water_psf.bonds)
assert numpy.allclose(auto_structure.angles, structure_7water_psf.angles)
24 changes: 24 additions & 0 deletions tests/tests_files/7H2O.pdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
COMPND 7H2O
AUTHOR Generated from 7H2O.xyz
HETATM 1 O HOH 1 -1.365 0.569 1.378 1.00 0.00 O
HETATM 2 H HOH 1 -1.697 1.316 0.836 1.00 0.00 H
HETATM 3 H HOH 1 -1.843 -0.180 0.962 1.00 0.00 H
HETATM 4 O HOH 2 -2.091 2.243 -0.787 1.00 0.00 O
HETATM 5 H HOH 2 -2.708 2.983 -0.940 1.00 0.00 H
HETATM 6 H HOH 2 -2.578 1.522 -1.267 1.00 0.00 H
HETATM 7 O HOH 3 0.517 1.478 -1.291 1.00 0.00 O
HETATM 8 H HOH 3 1.056 2.285 -1.185 1.00 0.00 H
HETATM 9 H HOH 3 -0.372 1.826 -1.029 1.00 0.00 H
HETATM 10 O HOH 4 0.871 -0.742 0.486 1.00 0.00 O
HETATM 11 H HOH 4 0.994 -0.016 -0.161 1.00 0.00 H
HETATM 12 H HOH 4 0.324 -0.268 1.153 1.00 0.00 H
HETATM 13 O HOH 5 -3.122 0.099 -2.005 1.00 0.00 O
HETATM 14 H HOH 5 -3.165 -0.683 -1.412 1.00 0.00 H
HETATM 15 H HOH 5 -2.392 -0.197 -2.597 1.00 0.00 H
HETATM 16 O HOH 6 -1.599 -1.700 -0.411 1.00 0.00 O
HETATM 17 H HOH 6 -1.173 -1.520 -1.281 1.00 0.00 H
HETATM 18 H HOH 6 -0.780 -1.865 0.109 1.00 0.00 H
HETATM 19 O HOH 7 -0.519 -0.631 -2.744 1.00 0.00 O
HETATM 20 H HOH 7 -0.043 0.125 -2.319 1.00 0.00 H
HETATM 21 H HOH 7 0.157 -0.935 -3.377 1.00 0.00 H
END
62 changes: 62 additions & 0 deletions tests/tests_files/7H2O.psf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
PSF

3 !NTITLE
REMARKS original generated structure x-plor psf file
REMARKS topology H2O.rtf
REMARKS segment SYS { first NONE; last NONE; auto angles dihedrals }

21 !NATOM
1 SYS 1 MOL1 O1 O 0.000000 15.9990 0
2 SYS 1 MOL1 H2 H 0.000000 1.0080 0
3 SYS 1 MOL1 H3 H 0.000000 1.0080 0
4 SYS 2 MOL1 O1 O 0.000000 15.9990 0
5 SYS 2 MOL1 H2 H 0.000000 1.0080 0
6 SYS 2 MOL1 H3 H 0.000000 1.0080 0
7 SYS 3 MOL1 O1 O 0.000000 15.9990 0
8 SYS 3 MOL1 H2 H 0.000000 1.0080 0
9 SYS 3 MOL1 H3 H 0.000000 1.0080 0
10 SYS 4 MOL1 O1 O 0.000000 15.9990 0
11 SYS 4 MOL1 H2 H 0.000000 1.0080 0
12 SYS 4 MOL1 H3 H 0.000000 1.0080 0
13 SYS 5 MOL1 O1 O 0.000000 15.9990 0
14 SYS 5 MOL1 H2 H 0.000000 1.0080 0
15 SYS 5 MOL1 H3 H 0.000000 1.0080 0
16 SYS 6 MOL1 O1 O 0.000000 15.9990 0
17 SYS 6 MOL1 H2 H 0.000000 1.0080 0
18 SYS 6 MOL1 H3 H 0.000000 1.0080 0
19 SYS 7 MOL1 O1 O 0.000000 15.9990 0
20 SYS 7 MOL1 H2 H 0.000000 1.0080 0
21 SYS 7 MOL1 H3 H 0.000000 1.0080 0

14 !NBOND: bonds
1 2 1 3 4 5 4 6
7 8 7 9 10 11 10 12
13 14 13 15 16 17 16 18
19 20 19 21

7 !NTHETA: angles
2 1 3 5 4 6 8 7 9
11 10 12 14 13 15 17 16 18
20 19 21

0 !NPHI: dihedrals


0 !NIMPHI: impropers


0 !NDON: donors


0 !NACC: acceptors


0 !NNB

0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0

1 0 !NGRP
0 0 0

19 changes: 19 additions & 0 deletions tests/tests_files/H2O.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
* Topology generated by `just_psf.residue_topology.ResidueTopologies.as_rtop()`
*
19 1

MASS -1 H 1.008
MASS -1 O 15.999

DEFA LAST NONE FIRST NONE
AUTO ANGLE DIHE

RESI MOL1 0.00
GROUP
ATOM O1 O 0.00
ATOM H2 H 0.00
ATOM H3 H 0.00
!
BOND O1 H2 O1 H3

END
10 changes: 10 additions & 0 deletions tests/tests_files/script.vmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# script to generate 7H2O.psf
# run `vmd -eofexit < script.vmd`
topology H2O.rtf

pdbalias residue HOH MOL1
segment SYS {
pdb 7H2O.pdb
}

writepsf 7H2O.psf

0 comments on commit 7695b56

Please sign in to comment.