File: test_molecular_container.py

package info (click to toggle)
propka 3.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,920 kB
  • sloc: python: 7,156; makefile: 39
file content (56 lines) | stat: -rw-r--r-- 2,045 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from propka.input import read_parameter_file, read_molecule_file
from propka.lib import loadOptions
from propka.molecular_container import MolecularContainer
from propka.parameters import Parameters
from pathlib import Path
from pytest import approx

TESTS = Path(__file__).resolve().parent


def load_molecule(code):
    pdb_path = TESTS / f"pdb/{code}.pdb"
    options = [str(pdb_path)]
    args = loadOptions(options)
    parameters = read_parameter_file(args.parameters, Parameters())
    molecule = MolecularContainer(parameters, args)
    molecule = read_molecule_file(str(pdb_path), molecule)
    return molecule


def test_MolecularContainer_get_pi():
    molecule = load_molecule("1HPX")
    molecule.average_of_conformations()
    molecule.calculate_pka()
    pi_folded, pi_unfolded = molecule.get_pi()
    assert pi_folded == approx(9.54, abs=1e-2)
    assert pi_unfolded == approx(8.90, abs=1e-2)


def test_MolecularContainer_top_up_conformations():
    molecule = load_molecule("conf-alt-AB")
    assert len(molecule.conformations) == 2
    assert len(molecule.conformations["1A"]) == 16
    assert len(molecule.conformations["1B"]) == 16

    molecule = load_molecule("conf-alt-BC")
    assert len(molecule.conformations) == 3
    assert len(molecule.conformations["1A"]) == 16
    assert len(molecule.conformations["1B"]) == 16
    assert len(molecule.conformations["1C"]) == 16

    molecule = load_molecule("conf-alt-AB-mutant")
    assert len(molecule.conformations) == 2
    assert len(molecule.conformations["1A"]) == 16
    assert len(molecule.conformations["1B"]) == 17

    molecule = load_molecule("conf-model-mutant")
    assert len(molecule.conformations) == 2
    assert len(molecule.conformations["1A"]) == 16
    assert len(molecule.conformations["2A"]) == 17

    molecule = load_molecule("conf-model-missing-atoms")
    assert len(molecule.conformations) == 3
    assert len(molecule.conformations["1A"]) == 17
    assert len(molecule.conformations["2A"]) == 17
    assert len(molecule.conformations["3A"]) == 17