Skip to content

Commit

Permalink
First test
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoelfe committed Sep 7, 2024
1 parent 28e6385 commit 02a1daa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
python -m pip install .[test] ${{ github.event_name == 'schedule' && '--pre' || '' }}
- name: 🧪 Run Tests
run: pytest --color=yes --cov --cov-report=xml --cov-report=term-missing
run: pytest --color=yes -rP --cov --cov-report=xml --cov-report=term-missing

# If something goes wrong with --pre tests, we can open an issue in the repo
- name: 📝 Report --pre Failures
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies = [
"torch-fourier-shell-correlation",
"ttmask",
"matplotlib",
"numpy<2.0",
"mrcfile",
"plotille",
"rich",
Expand All @@ -51,7 +52,7 @@ dependencies = [
# "extras" (e.g. for `pip install .[test]`)
[project.optional-dependencies]
# add dependencies used for testing here
test = ["pytest", "pytest-cov"]
test = ["pytest", "pytest-cov", "pooch"]
# add anything else you like to have in your dev environment here
dev = [
"ipython",
Expand Down
3 changes: 2 additions & 1 deletion src/ttfsc/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def ttfsc_cli(
rprint(f"Estimated resolution using {fsc_threshold} criterion in unmasked map: {estimated_resolution_angstrom:.2f} Å")

fsc_values_masked = None
fsc_values_corrected = None
if mask != Masking.none:
from ._masking import calculate_masked_fsc

Expand Down Expand Up @@ -138,7 +139,7 @@ def ttfsc_cli(
rlnSpectralIndex=i,
rlnResolution=r,
rlnAngstromResolution=r,
rlnFourierShellCorrelationCorrected=fsc_values_corrected[i] if correct_for_masking else nan,
rlnFourierShellCorrelationCorrected=fsc_values_corrected[i] if fsc_values_corrected is not None else nan,
rlnFourierShellCorrelationUnmaskedMaps=f,
rlnFourierShellCorrelationMaskedMaps=fsc_values_masked[i] if fsc_values_masked is not None else nan,
rlnCorrectedFourierShellCorrelationPhaseRandomizedMaskedMaps=fsc_values_randomized[i]
Expand Down
35 changes: 33 additions & 2 deletions tests/test_ttfsc.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,33 @@
def test_something():
pass
import pooch
import pytest
from typer.testing import CliRunner

from ttfsc._cli import cli


@pytest.fixture(scope="module")
def halfmap1():
fname = pooch.retrieve(
"https://ftp.ebi.ac.uk/pub/databases/emdb/structures/EMD-37579/other/emd_37579_half_map_1.map.gz",
known_hash="e1c62f4eb3615d2c29c5cae6de3c10951e5aa828dac2f6aa04b0838dc2b96b6f",
)
return fname


@pytest.fixture(scope="module")
def halfmap2():
fname = pooch.retrieve(
"https://ftp.ebi.ac.uk/pub/databases/emdb/structures/EMD-37579/other/emd_37579_half_map_2.map.gz",
known_hash="c076ee990a91715900e081a92a0747078ed5ec4796d35614f0b41025e5c24212",
)
return fname


runner = CliRunner()


def test_app(halfmap1, halfmap2):
result = runner.invoke(cli, [halfmap1, halfmap2])
print(result.output)
assert result.exit_code == 0
assert "Estimated resolution using 0.143 criterion in unmasked map: 3.63 Å" in result.output

0 comments on commit 02a1daa

Please sign in to comment.