File: test_parsers.py

package info (click to toggle)
python-prodigy 2.3.0-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,488 kB
  • sloc: python: 820; makefile: 10
file content (76 lines) | stat: -rw-r--r-- 1,923 bytes parent folder | download
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from pathlib import Path

import pytest
from Bio.PDB.MMCIFParser import MMCIFParser
from Bio.PDB.PDBParser import PDBParser
from Bio.PDB.Structure import Structure

from prodigy_prot.modules.parsers import get_parser, parse_structure, validate_structure

from . import TEST_DATA


@pytest.fixture
def input_structure_cif():
    yield Path(TEST_DATA, "2oob.cif")


@pytest.fixture
def input_structure_pdb() -> Path:
    return Path(TEST_DATA, "2oob.pdb")


def test_get_parser_pdb(input_structure_pdb):

    parser = get_parser(input_structure_pdb)
    assert isinstance(parser, PDBParser)


def test_get_parser_cif(input_structure_cif):

    parser = get_parser(input_structure_cif)
    assert isinstance(parser, MMCIFParser)


def test_validate_structure_pdb(input_structure_pdb):

    parser = PDBParser()
    structure = parser.get_structure("test_structure", input_structure_pdb)
    assert isinstance(structure, Structure)

    result = validate_structure(structure)
    assert result == structure


def test_validate_stucture_cif(input_structure_cif):

    parser = MMCIFParser()
    structure = parser.get_structure("test_structure", input_structure_cif)
    assert isinstance(structure, Structure)

    result = validate_structure(structure)
    assert result == structure


def test_parse_structure_pdb(input_structure_pdb):

    parser = PDBParser()
    structure = parser.get_structure(input_structure_pdb.stem, input_structure_pdb)

    result, num_chains, num_res = parse_structure(input_structure_pdb)

    assert result == structure
    assert num_chains == 2
    assert num_res == 116


def test_parse_structure_cif(input_structure_cif):

    parser = MMCIFParser()
    structure = parser.get_structure(input_structure_cif.stem, input_structure_cif)

    result, num_chains, num_res = parse_structure(input_structure_cif)

    assert result == structure
    assert num_chains == 2
    assert num_res == 116