Skip to content

Commit

Permalink
Exclude Test Scripts and Data from PyPI Release (#148)
Browse files Browse the repository at this point in the history
* move tests to dir and rewrite paths

* add python 3.7 test run support

* add importlib_resources to appveyor

* format files with 79 line length

* run tests from root dir in workflow

* docs: update changelog

---------

Co-authored-by: Arian Jamasb <[email protected]>
  • Loading branch information
Irlirion and a-r-j authored Jul 22, 2024
1 parent 3e26557 commit 5fa2104
Show file tree
Hide file tree
Showing 77 changed files with 354 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ install:
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- conda create -q -n test-environment --channel=conda-forge mmtf-python numpy scipy pandas pytest looseversion python=%PYTHON_VERSION%
- conda create -q -n test-environment --channel=conda-forge mmtf-python numpy scipy pandas pytest looseversion importlib_resources python=%PYTHON_VERSION%
- activate test-environment

test_script:
Expand Down
44 changes: 22 additions & 22 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,50 @@ name: Publish BioPandas to PyPI / GitHub

on:
pull_request:
branches: [ main ]
branches: [main]

jobs:
test-style:
name: Run style tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: "pip"

- name: Install package dependencies for testing
run: pip install .[test]
- name: Install package dependencies for testing
run: pip install .[test]

- name: Run all the pytest tests
run: flake8 ./biopandas
- name: Run all the pytest tests
run: flake8 ./biopandas

test-pytest:
name: Run pytest tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
cache: "pip"

- name: Install package dependencies for testing
run: pip install .[test]
- name: Install package dependencies for testing
run: pip install .[test]

- name: Run all the pytest tests
run: pytest ./biopandas -sv
- name: Run all the pytest tests
run: pytest -sv

build-n-publish:
needs: [test-pytest] # only runs if tests are passing
if: startsWith(github.ref, 'refs/tags/v') # Check if the tag starts with 'v'
if: startsWith(github.ref, 'refs/tags/v') # Check if the tag starts with 'v'
name: Build and publish to PyPI
runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The CHANGELOG for the current development version is available at

- Feature: added method to `PandasMmcif` that allow to select by model ids. PR #[145](https://github.com/BioPandas/biopandas/pull/145))
- Dev: switched testing framework entirely to pytest. Drops nose dependency due to version conflicts with Python 3.12 (`nose`) and 3.8 (`nose`) PR #[146](https://github.com/BioPandas/biopandas/pull/146))
- Avoid inclusion of test scripts and test data in the PyPI release of the Biopandas library. PR #[148](https://github.com/BioPandas/biopandas/pull/148). Addresses issue [#147](https://github.com/BioPandas/biopandas/issues/147)


### 0.5.0dev1 (31/7/2023)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
# Project Website: http://rasbt.github.io/biopandas/
# Code Repository: https://github.com/rasbt/biopandas

import os
import sys

if sys.version_info >= (3, 9):
import importlib.resources as pkg_resources
else:
import importlib_resources as pkg_resources

import numpy as np

import tests.mmcif.data
from biopandas.mmcif import PandasMmcif

TEST_DATA = pkg_resources.files(tests.mmcif.data)


def test_defaults():
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
p1t48 = PandasMmcif()
p1t48.read_mmcif(TESTDATA_1t48)
expect_res = [
Expand Down Expand Up @@ -309,7 +318,7 @@ def test_defaults():


def test_sameindex():
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
p1t48 = PandasMmcif()
p1t48.read_mmcif(TESTDATA_1t48)
p1t48.df["ATOM"].index = np.zeros(p1t48.df["ATOM"].shape[0], dtype=int)
Expand Down Expand Up @@ -608,9 +617,7 @@ def test_sameindex():


def test_multichain():
TESTDATA_5mtn = os.path.join(
os.path.dirname(__file__), "data", "5mtn_multichain.cif"
)
TESTDATA_5mtn = str(TEST_DATA.joinpath("5mtn_multichain.cif"))
mtn = PandasMmcif()
mtn.read_mmcif(TESTDATA_5mtn)
expect_res_a = [
Expand Down Expand Up @@ -818,7 +825,7 @@ def test_multichain():


def test_pdb_with_insertion_codes():
PDB_2D7T_PATH = os.path.join(os.path.dirname(__file__), "data", "2d7t.cif")
PDB_2D7T_PATH = str(TEST_DATA.joinpath("2d7t.cif"))

ppdb = PandasMmcif().read_mmcif(PDB_2D7T_PATH)
sequence = ppdb.amino3to1()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
# Project Website: http://rasbt.github.io/biopandas/
# Code Repository: https://github.com/rasbt/biopandas

import os
import sys

if sys.version_info >= (3, 9):
import importlib.resources as pkg_resources
else:
import importlib_resources as pkg_resources

import tests.mmcif.data
from biopandas.mmcif import PandasMmcif
from biopandas.testutils import assert_raises
from tests.testutils import assert_raises

TESTDATA_FILENAME = os.path.join(os.path.dirname(__file__), "data", "3eiy.cif")
TEST_DATA = pkg_resources.files(tests.mmcif.data)


def test_overwrite_df():
data_path = os.path.join(os.path.dirname(__file__), "data", "3eiy.cif")
data_path = str(TEST_DATA.joinpath("3eiy.cif"))
pdb = PandasMmcif().read_mmcif(data_path)

def overwrite():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@
# Project Website: http://rasbt.github.io/biopandas/
# Code Repository: https://github.com/rasbt/biopandas

import os
import sys

if sys.version_info >= (3, 9):
import importlib.resources as pkg_resources
else:
import importlib_resources as pkg_resources

import pandas as pd

import tests.mmcif.data
from biopandas.mmcif import PandasMmcif

TEST_DATA = pkg_resources.files(tests.mmcif.data)


def test_equal():
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))

p1t48 = PandasMmcif()
p1t48.read_mmcif(TESTDATA_1t48)
Expand All @@ -25,7 +34,7 @@ def test_equal():


def test_deprecated_str_arg():
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))

p1t48 = PandasMmcif()
p1t48.read_mmcif(TESTDATA_1t48)
Expand All @@ -39,7 +48,7 @@ def test_deprecated_str_arg():


def test_use_external_df():
TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))

p1t48 = PandasMmcif()
p1t48.read_mmcif(TESTDATA_1t48)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,43 @@
# License: BSD 3 clause
# Project Website: http://rasbt.github.io/biopandas/
# Code Repository: https://github.com/rasbt/biopandas
import os
import sys

if sys.version_info >= (3, 9):
import importlib.resources as pkg_resources
else:
import importlib_resources as pkg_resources

import tests.mmcif.data
from biopandas.mmcif import PandasMmcif

TESTDATA_FILENAME = os.path.join(os.path.dirname(__file__), "data", "2jyf.cif.gz")
TEST_DATA = pkg_resources.files(tests.mmcif.data)

TESTDATA_FILENAME = str(TEST_DATA.joinpath("2jyf.cif.gz"))


def test_label_models():
biopandas_structure = PandasMmcif().read_mmcif(TESTDATA_FILENAME)
biopandas_structure.label_models()
assert "model_id" in biopandas_structure.df["ATOM"].columns


def test_get_model():
biopandas_structure = PandasMmcif().read_mmcif(TESTDATA_FILENAME)
MODEL_INDEX = 1
new_biopandas_structure = biopandas_structure.get_model(MODEL_INDEX)
assert new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all() == MODEL_INDEX
assert (
new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all()
== MODEL_INDEX
)


def test_get_models():
biopandas_structure = PandasMmcif().read_mmcif(TESTDATA_FILENAME)
MODEL_INDICES = [1, 3, 5]

new_biopandas_structure = biopandas_structure.get_models(MODEL_INDICES)
assert new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all() in MODEL_INDICES
assert (
new_biopandas_structure.df["ATOM"]["pdbx_PDB_model_num"].all()
in MODEL_INDICES
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,35 @@
# Code Repository: https://github.com/rasbt/biopandas


import os
import sys

if sys.version_info >= (3, 9):
import importlib.resources as pkg_resources
else:
import importlib_resources as pkg_resources
from pathlib import Path
from urllib.error import HTTPError

import pandas as pd
import pytest
from pandas.testing import assert_frame_equal

import tests.mmcif.data
from biopandas.mmcif import PandasMmcif
from biopandas.pdb import PandasPdb
from biopandas.testutils import assert_raises
from pandas.testing import assert_frame_equal
from tests.testutils import assert_raises

TEST_DATA = pkg_resources.files(tests.mmcif.data)

TESTDATA_FILENAME = os.path.join(os.path.dirname(__file__), "data", "3eiy.cif")
TESTDATA_FILENAME = str(TEST_DATA.joinpath("3eiy.cif"))

# Not clear on how ANISOU records are handled in mmCIF files so skipping
# TESTDATA_FILENAME2 = os.path.join(
# os.path.dirname(__file__), "data", "4eiy_anisouchunk.cif"
# )
TESTDATA_FILENAME2 = os.path.join(
os.path.dirname(__file__), "data", "4eiy.cif"
)
TESTDATA_FILENAME_GZ = os.path.join(
os.path.dirname(__file__), "data", "3eiy.cif.gz"
)

TESTDATA_FILENAME_AF2_V4 = os.path.join(
os.path.dirname(__file__), "data", "AF-Q5VSL9-F1-model_v4.cif"
)
TESTDATA_FILENAME_AF2_V3 = os.path.join(
os.path.dirname(__file__), "data", "AF-Q5VSL9-F1-model_v3.cif"
)
# TESTDATA_FILENAME2 = str(TEST_DATA.joinpath("4eiy_anisouchunk.cif"))
TESTDATA_FILENAME2 = str(TEST_DATA.joinpath("4eiy.cif"))
TESTDATA_FILENAME_GZ = str(TEST_DATA.joinpath("3eiy.cif.gz"))

TESTDATA_FILENAME_AF2_V4 = str(TEST_DATA.joinpath("AF-Q5VSL9-F1-model_v4.cif"))
TESTDATA_FILENAME_AF2_V3 = str(TEST_DATA.joinpath("AF-Q5VSL9-F1-model_v3.cif"))

ATOM_DF_COLUMNS = [
"B_iso_or_equiv",
Expand Down
21 changes: 15 additions & 6 deletions biopandas/mmcif/tests/test_rmsd.py → tests/mmcif/test_rmsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@
# Project Website: http://rasbt.github.io/biopandas/
# Code Repository: https://github.com/rasbt/biopandas

import os
import sys

if sys.version_info >= (3, 9):
import importlib.resources as pkg_resources
else:
import importlib_resources as pkg_resources

import pytest

import tests.mmcif.data
from biopandas.mmcif import PandasMmcif

TESTDATA_1t48 = os.path.join(os.path.dirname(__file__), "data", "1t48.cif")
TESTDATA_1t49 = os.path.join(os.path.dirname(__file__), "data", "1t49.cif")
# TESTDATA_lig1 = os.path.join(os.path.dirname(__file__), "data", "lig_conf_1.pdb")
# TESTDATA_lig2 = os.path.join(os.path.dirname(__file__), "data", "lig_conf_2.pdb")
TEST_DATA = pkg_resources.files(tests.mmcif.data)

TESTDATA_1t48 = str(TEST_DATA.joinpath("1t48.cif"))
TESTDATA_1t49 = str(TEST_DATA.joinpath("1t49.cif"))
# TESTDATA_lig1 = str(TEST_DATA.joinpath("lig_conf_1.pdb"))
# TESTDATA_lig2 = str(TEST_DATA.joinpath("lig_conf_2.pdb"))

TESTDATA_rna = os.path.join(os.path.dirname(__file__), "data", "1ehz.cif")
TESTDATA_rna = str(TEST_DATA.joinpath("1ehz.cif"))

p1t48 = PandasMmcif()
p1t48.read_mmcif(TESTDATA_1t48)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 5fa2104

Please sign in to comment.