Skip to content

Commit

Permalink
Write simple tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marinegor committed Oct 2, 2024
1 parent 27c10d6 commit 950cfcf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
25 changes: 20 additions & 5 deletions testsuite/MDAnalysisTests/coordinates/test_mmcif.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import glob
import os
from io import StringIO

import MDAnalysis as mda
import numpy as np
Expand Down Expand Up @@ -34,11 +32,28 @@ def test_works_without_explicit_format(mmcif_filename):
[
(f"{MMCIF_FOLDER}/1YJP.cif", 59, 66),
(f"{MMCIF_FOLDER}/1YJP.cif.gz", 59, 66),
(f"{MMCIF_FOLDER}/7ETN.cif", 70, 70),
(f"{MMCIF_FOLDER}/7ETN.cif.gz", 70, 70),
(f"{MMCIF_FOLDER}/7ETN.cif", 150, 150),
(f"{MMCIF_FOLDER}/7ETN.cif.gz", 150, 150),
],
)
def test_n_atoms(mmcif_filename, natoms_protein, natoms_total):
u = mda.Universe(mmcif_filename)
assert len(u.atoms) == natoms_total
assert len(u.select("protein").atoms) == natoms_protein
assert len(u.select_atoms("protein").atoms) == natoms_protein


@pytest.mark.parametrize(
"mmcif_filename,cell",
[
(
f"{MMCIF_FOLDER}/1YJP.cif.gz",
np.array([21.937, 4.866, 23.477, 90.00, 107.08, 90.00]),
),
(
f"{MMCIF_FOLDER}/7ETN.cif.gz",
np.array([5.264, 24.967, 20.736, 90.00, 94.85, 90.00]),
),
],
)
def test_cell(mmcif_filename, cell):
assert np.allclose(mda.Universe(mmcif_filename).coord._unitcell, cell)
9 changes: 6 additions & 3 deletions testsuite/MDAnalysisTests/topology/test_mmcif.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ def test_chains(mmcif_filename, n_chains):
@pytest.mark.parametrize(
"mmcif_filename,sequence",
[
(f"{MMCIF_FOLDER}/1YJP.cif", ["GLY", "ASN", "ASN", "GLN", "GLN", "ASN", "TRY"]),
(f"{MMCIF_FOLDER}/1YJP.cif", ["GLY", "ASN", "ASN", "GLN", "GLN", "ASN", "TYR"]),
(
f"{MMCIF_FOLDER}/1YJP.cif.gz",
["GLY", "ASN", "ASN", "GLN", "GLN", "ASN", "TRY"],
["GLY", "ASN", "ASN", "GLN", "GLN", "ASN", "TYR"],
),
(f"{MMCIF_FOLDER}/7ETN.cif", ["PRO", "PHE", "LEU", "ILE"]),
(f"{MMCIF_FOLDER}/7ETN.cif.gz", ["PRO", "PHE", "LEU", "ILE"]),
],
)
def test_sequence(mmcif_filename, sequence):
u = mda.Universe(mmcif_filename)
assert [res.resname for res in u.residues] == sequence
in_structure = [
str(res.resname) for res in u.select_atoms("protein and chainid A").residues
]
assert in_structure == sequence, ":".join(in_structure)

0 comments on commit 950cfcf

Please sign in to comment.