1
"""
2
Tests the dummy atoms utilities.
3
"""
4

5 2
import os
6

7 2
import parmed as pmd
8 2
import pytest
9

10 2
import paprika.dummy as dummy
11 2
from paprika.align import zalign
12

13

14 2
def test_extract_dummy():
15 2
    cb6 = pmd.load_file(
16
        os.path.join(os.path.dirname(__file__), "../data/cb6-but/vac.pdb")
17
    )
18 2
    aligned_cb6 = zalign(cb6, ":CB6", ":BUT")
19 2
    aligned_cb6 = dummy.add_dummy(aligned_cb6, residue_name="DM1", z=-6.0)
20 2
    aligned_cb6 = dummy.add_dummy(aligned_cb6, residue_name="DM2", z=-9.0)
21 2
    aligned_cb6 = dummy.add_dummy(aligned_cb6, residue_name="DM3", z=-11.2, y=2.2)
22

23 2
    dm_index = []
24 2
    for atom in aligned_cb6.topology.atoms():
25 2
        if atom.residue.name in ["DM1", "DM2", "DM3"]:
26 2
            dm_index.append(atom.index)
27

28 2
    assert len(dm_index) != 0
29

30 2
    dummy_dict = dummy.extract_dummy_atoms(aligned_cb6, serial=False)
31

32 2
    assert all(dummy_dict["DM1"]["pos"] == [0.0, 0.0, -6.0])
33 2
    assert all(dummy_dict["DM2"]["pos"] == [0.0, 0.0, -9.0])
34 2
    assert all(dummy_dict["DM3"]["pos"] == [0.0, 2.2, -11.2])
35

36 2
    assert dummy_dict["DM1"]["mass"] == 208.0
37 2
    assert dummy_dict["DM2"]["mass"] == 208.0
38 2
    assert dummy_dict["DM3"]["mass"] == 208.0
39

40 2
    assert dummy_dict["DM1"]["idx"] == dm_index[0]
41 2
    assert dummy_dict["DM2"]["idx"] == dm_index[1]
42 2
    assert dummy_dict["DM3"]["idx"] == dm_index[2]

Read our documentation on viewing source code .

Loading