Skip to main content

Compare PDB files with a reasonable tolerance

Project description

biotest

Ruff Actions status
Ruff Actions status
pytest doctest Actions status
uv Actions status
Built with Material for MkDocs Actions status

A Python package for testing bioinformatics data. Mainly, it provides a set of functions to compare normal text/binary files, npy files, pdb files, and directories.

🛠️ Installation

pip install biotest

🚀 Usage

Mainly, use the API with pytest.

from biotest.compare_files import (
    assert_two_files_equal_sha,
    assert_two_npys_within_tolerance,
    assert_two_pdbqt_files_within_tolerance,
    assert_two_pdb_files_within_tolerance,
    assert_two_dirs_within_tolerance,
)

def assert_two_files_sha(file1: str | PathLike | IOBase, file2: str | PathLike | IOBase):
    """
    Assert that two files are exactly the same.
    """
    ...

def assert_two_npys_within_tolerance(
    npy1: str | PathLike | np.ndarray, npy2: str | PathLike | np.ndarray, *, tolerance=1e-6
):
    """
    Assert that two npy files are almost the same within a tolerance.
    """
    ...


def assert_two_pdbqt_files_within_tolerance(
    file1: str | PathLike | IOBase, file2: str | PathLike | IOBase, *, tolerance=1e-3
):
    """
    Assert that two pdbqt files are equal under following conditions.

    - ignore the trailing whitespace.
    - 0.001 default tolerance for Orthogonal coordinates for X,Y,Z in Angstroms.
    """
    ...


def assert_two_pdb_files_within_tolerance(
    file1: str | PathLike | IOBase, file2: str | PathLike | IOBase, *, tolerance=1e-3
):
    """
    Assert that two pdb files are equal under following conditions.

    - ignore the trailing whitespace.
    - 0.001 default tolerance for Orthogonal coordinates for X,Y,Z in Angstroms.
    """
    ...


def assert_two_dirs_within_tolerance(
    dir1: str | PathLike,
    dir2: str | PathLike,
    *,
    tolerance: float = 1e-3,
    filenames_exclude: Sequence[str] | None = None,
):
    """
    Assert that two directories have the same files with almost the same content within tolerance.
    """
    ...

Also, you can use the CLI to quickly test the functionality. These merely call the functions above, so they will print the traceback if the assertion fails.

biotest assert-two-files-equal-sha file1 file2
biotest assert-two-npys-within-tolerance file1.npy file2.npy
biotest assert-two-pdbqt-files-within-tolerance file1.pdbqt file2.pdbqt
biotest assert-two-pdb-files-within-tolerance file1.pdb file2.pdb
biotest assert-two-dirs-within-tolerance dir1 dir2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biotest-0.0.3.tar.gz (17.1 kB view details)

Uploaded Source

File details

Details for the file biotest-0.0.3.tar.gz.

File metadata

  • Download URL: biotest-0.0.3.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for biotest-0.0.3.tar.gz
Algorithm Hash digest
SHA256 bc2bf8ed51c56be86c3954f7969494a53e652fc6b8f1d18ee88ca25324cd64e2
MD5 4549a0d16f84dca4ca505bcbe9af1fd3
BLAKE2b-256 eacfeab07a68caaf9d94b763d8b045be2e3ed70c7fdbe221567515a3edc07df8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page