Skip to content

Commit

Permalink
inclusion of simple test case to check resolution of issue MDAnalysis…
Browse files Browse the repository at this point in the history
  • Loading branch information
M. Driver committed Sep 24, 2021
1 parent 8b1de8e commit cadc658
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
60 changes: 60 additions & 0 deletions testsuite/MDAnalysisTests/data/atomtypes_charge.itp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 2 no 1.0 1.0



[ atomtypes ]
;name at.num mass charge ptype c6 c12
NP NP 100.000000 -1.000000 A 1.00E-02 8.707129E-04
NR NR 100.000000 0.000000 A 1.00E-02 8.707129E-04
NA NA 100.000000 0.000000 A 1.00E-02 8.707129E-04



[ moleculetype ]
; Name nrexcl
testmol 2

[ atoms ]
; nr type resnr residue atom cgnr
1 NP 1 A NP 1
2 NR 1 A NR 2
3 NA 1 A NA 3
4 NP 2 A NP 4
5 NR 2 A NR 5
6 NA 2 A NA 6
7 NP 3 A NP 7
8 NR 3 A NR 8
9 NA 3 A NA 9

[ bonds ]
; i j funct c0 c1
1 2 1 0.390 300000.000
2 3 1 0.586 300000.000
2 4 1 0.390 300000.000
4 5 1 0.390 300000.000
5 6 1 0.586 300000.000
5 7 1 0.390 300000.000
7 8 1 0.390 300000.000
8 9 1 0.586 300000.000

[ angles ]
; ai aj ak funct table_number k(kJ/mol)
1 2 3 1 91.100 1000.000
1 2 4 1 113.100 1000.000
2 4 5 1 95.200 1000.000
3 2 4 1 100.800 1000.000
4 5 6 1 91.100 1000.000
4 5 7 1 113.100 1000.000
5 7 8 1 95.200 1000.000
6 5 7 1 100.800 1000.000
7 8 9 1 91.100 1000.000

[ system ]
; Name
test

[ molecules ]
; Compound #mols
testmol 1
1 change: 1 addition & 0 deletions testsuite/MDAnalysisTests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@
ITP = resource_filename(__name__, 'data/gromacs_ala10.itp')
ITP_nomass = resource_filename(__name__, 'data/itp_nomass.itp')
ITP_atomtypes = resource_filename(__name__, 'data/atomtypes.itp')
ITP_charges = resource_filename(__name__, 'data/atomtypes_charge.itp')
ITP_edited = resource_filename(__name__, 'data/edited_itp.itp')
ITP_tip5p = resource_filename(__name__, "data/tip5p.itp")
ITP_spce = resource_filename(__name__, 'data/spce.itp')
Expand Down
29 changes: 29 additions & 0 deletions testsuite/MDAnalysisTests/topology/test_itp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
ITP, # GROMACS itp
ITP_nomass, # from Automated Topology Builder
ITP_atomtypes,
ITP_charges,
ITP_edited,
ITP_tip5p,
ITP_spce,
Expand Down Expand Up @@ -188,6 +189,34 @@ def test_mass_parse_or_guess(self, universe):
assert_almost_equal(universe.atoms[2].mass, 20.989)
assert_almost_equal(universe.atoms[3].mass, 1.008)

class TestITPAtomtypes(ParserBase):
parser = mda.topology.ITPParser.ITPParser
ref_filename = ITP_charges
expected_attrs = ['ids', 'names', 'types', 'masses',
'charges', 'chargegroups',
'resids', 'resnames',
'segids', 'moltypes', 'molnums',
'bonds', 'angles', 'dihedrals', 'impropers']
guessed_attrs = []
expected_n_atoms = 9
expected_n_residues = 3
expected_n_segments = 1

@pytest.fixture
def universe(self, filename):
return mda.Universe(filename)

def test_charge_parse(self, universe):
assert_almost_equal(universe.atoms[0].charge, -1.0)
assert_almost_equal(universe.atoms[1].charge, 0)
assert_almost_equal(universe.atoms[2].charge, 0)
assert_almost_equal(universe.atoms[3].charge, -1.)

def test_mass_parse_or_guess(self, universe):
assert_almost_equal(universe.atoms[0].mass, 100.0)
assert_almost_equal(universe.atoms[1].mass, 100.0)
assert_almost_equal(universe.atoms[2].mass, 100.0)
assert_almost_equal(universe.atoms[3].mass, 100.0)

class TestDifferentDirectivesITP(BaseITP):

Expand Down

0 comments on commit cadc658

Please sign in to comment.