Skip to content

Latest commit

 

History

History
116 lines (82 loc) · 3.63 KB

File metadata and controls

116 lines (82 loc) · 3.63 KB

Testing Funannotate2

This document describes the testing setup for Funannotate2 and how to run the tests.

Testing Framework

The Funannotate2 project uses pytest for testing. The tests are organized as follows:

  • tests/unit/: Unit tests for individual functions and modules
    • tests/unit/test_annotate_comprehensive.py: Comprehensive tests for the annotate module
    • tests/unit/test_search_comprehensive.py: Comprehensive tests for the search module
    • tests/unit/test_predict_comprehensive.py: Comprehensive tests for the predict module
    • And many more...
  • tests/integration/: Integration tests for the entire workflow
    • tests/integration/test_funannotate_cli.py: Tests for the command-line interface
    • tests/integration/test_funannotate_workflow.py: Tests for the workflow using the Python API
  • tests/functional/: Functional tests for real-world scenarios
  • tests/data/: Test data files used by the tests

Running Tests

To run the tests, you need to install pytest and the package in development mode:

# Install pytest and coverage tools
pip install pytest pytest-cov

# Install funannotate2 in development mode
pip install -e .

# Run all tests
pytest

# Run with coverage report
pytest --cov=funannotate2

# Generate HTML coverage report
python scripts/run_coverage.py

# Run only unit tests
pytest tests/unit/

# Run only integration tests
pytest tests/integration/

Current Test Coverage

The tests cover a wide range of functionality including:

  1. Core Modules:

    • annotate.py: Annotation pipeline
    • predict.py: Gene prediction
    • search.py: Sequence searching
    • clean.py: Genome cleaning
    • compare.py: Genome comparison
  2. Utility Functions:

    • merge_coordinates: Merging overlapping intervals
    • naming_slug: Generating slugs for species and strain combinations
    • create_tmpdir: Creating temporary directories
    • readBlocks: Reading blocks of text from a source
  3. FASTA Processing Functions:

    • softwrap: Wrapping sequences to a specified length
    • countfasta: Counting sequences in a FASTA file
    • fasta2dict: Converting a FASTA file to a dictionary
    • annotate_fasta: Annotating sequences in a FASTA file
    • mergefasta: Merging and dereplicating FASTA files

Adding New Tests

When adding new tests:

  1. Follow the naming conventions:

    • Test files: test_*.py
    • Test classes: Test*
    • Test methods: test_*
  2. Use fixtures from conftest.py when possible

  3. Add test data to the data/ directory when needed

  4. Run the tests to ensure they pass

  5. Use pytest.mark.skipif to skip tests that require external dependencies that might not be installed

Continuous Integration

The project includes a GitHub Actions workflow that runs the tests on push and pull requests. The workflow:

  1. Runs on multiple Python versions (3.8, 3.9, 3.10, 3.11)
  2. Installs the package and dependencies
  3. Runs the unit tests and generates a coverage report
  4. Runs the integration tests that don't require external dependencies
  5. Uploads the coverage report to Codecov
  6. Runs linting checks with flake8 and black

You can see the status of the tests on the GitHub Actions page and the coverage report on the Codecov page.

Running Tests with Specific Python Versions

To run the tests with a specific Python version, you can use a virtual environment:

# Create a virtual environment with Python 3.9
python3.9 -m venv venv-py39
source venv-py39/bin/activate

# Install dependencies
pip install pytest pytest-cov
pip install -e .

# Run tests
pytest