diff --git a/.github/workflows/cgatapps_python.yml b/.github/workflows/cgatapps_python.yml index 2b5eaf3a..c8f0646f 100644 --- a/.github/workflows/cgatapps_python.yml +++ b/.github/workflows/cgatapps_python.yml @@ -21,30 +21,58 @@ jobs: - uses: actions/checkout@v3 - name: Cache conda - uses: actions/cache@v3 # Updated to the latest cache action version + uses: actions/cache@v3 env: - # Increase this value to reset cache if conda/environments/cgat-core.yml has not changed CACHE_NUMBER: 0 with: path: ~/conda_pkgs_dir key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('conda/environments/cgat-apps.yml') }} - - name: Set up Conda - uses: conda-incubator/setup-miniconda@v2 + - name: Set installer URL and environment file + id: set-installer-and-env + run: | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + echo "installer-url=https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" >> $GITHUB_ENV + echo "env-file=conda/environments/cgat-apps.yml" >> $GITHUB_ENV + elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then + echo "installer-url=https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh" >> $GITHUB_ENV + echo "env-file=conda/environments/cgat-apps-macos.yml" >> $GITHUB_ENV + fi + + - uses: conda-incubator/setup-miniconda@v2 with: - mamba-version: "*" # Optional: if you prefer using mamba + installer-url: ${{ env.installer-url }} python-version: ${{ matrix.python-version }} - miniforge-version: "latest" # Added to ensure Miniforge is installed channels: conda-forge, bioconda, defaults channel-priority: true activate-environment: cgat-a - environment-file: conda/environments/cgat-apps.yml + environment-file: ${{ env.env-file }} + + - name: Configure Conda Paths + run: echo "/usr/share/miniconda3/condabin" >> $GITHUB_PATH - name: Show conda run: | conda info conda list - + + - name: Debug Python Environment + run: | + python --version + pip list + openssl version + + - name: Apply macOS-specific patches + if: matrix.os == 'macos-latest' + run: | + # Check if the patch needs to be applied + if grep -q "Skip BigWig tests on macOS" tests/test_scripts.py; then + echo "Patch already applied, skipping" + else + # Apply patch to skip BigWig tests on macOS + patch -p1 < tests/skip_bigwig_tests_macos.patch + fi + - name: Test run: | pip install -e . diff --git a/cgat/GTF.py b/cgat/GTF.py index c80908c0..4e02aded 100644 --- a/cgat/GTF.py +++ b/cgat/GTF.py @@ -106,7 +106,7 @@ def transcript_iterator(gff_iterator, strict=True): return a list of entries with the same transcript id. - Any features without a transcript_id will be ignored. + Any features without a transcript_id or gene_id will be ignored. The entries for the same transcript have to be consecutive in the file. If *strict* is set an AssertionError will be diff --git a/conda/environments/cgat-apps-macos.yml b/conda/environments/cgat-apps-macos.yml new file mode 100644 index 00000000..c985a7f6 --- /dev/null +++ b/conda/environments/cgat-apps-macos.yml @@ -0,0 +1,40 @@ +# Modified environment file for macOS arm64 architecture +# Based on cgat-apps.yml but without the unavailable packages + +name: cgat-a + +channels: +- conda-forge +- bioconda +- defaults + +dependencies: +# python dependencies +- python +- alignlib-lite +- biopython +- cython +- cgatcore +- matplotlib +- pytest +- numpy +- pandas +- pep8 +- pybedtools +- pybigwig +- pysam +- pyyaml +- quicksect +- rdflib +- scikit-learn +- scipy +- setuptools +- sortedcontainers +- bedtools +- grep +- htslib +- samtools +- tar +# Removed ucsc-bedgraphtobigwig and ucsc-wigtobigwig as they're not available for arm64 +- wget +- zlib diff --git a/tests/skip_bigwig_tests_macos.patch b/tests/skip_bigwig_tests_macos.patch new file mode 100644 index 00000000..741b631d --- /dev/null +++ b/tests/skip_bigwig_tests_macos.patch @@ -0,0 +1,25 @@ +diff --git a/tests/test_scripts.py b/tests/test_scripts.py +index xxxxxxx..xxxxxxx 100644 +--- a/tests/test_scripts.py ++++ b/tests/test_scripts.py +@@ -322,9 +322,20 @@ TEST_CASES = collect_test_cases() + + + @pytest.mark.parametrize("test_case", TEST_CASES, ids=[tc["description"] for tc in TEST_CASES]) +-def test_scripts(test_case): ++def test_scripts(test_case, request): + '''Run parametrized script tests.''' ++ ++ # Skip BigWig tests on macOS as the required tools are not available ++ import platform ++ import pytest ++ ++ description = test_case["description"] ++ if platform.system() == "Darwin" and ("bigwig" in description.lower() or ++ "bedgraphtobigwig" in description.lower() or ++ "wigtobigwig" in description.lower()): ++ pytest.skip(f"Skipping {description} on macOS as UCSC tools are not available") ++ + func = test_case["func"] # Directly retrieve the function object + args = test_case["args"] + func(*args) diff --git a/tests/test_scripts.py b/tests/test_scripts.py index ef0588cd..c222fd44 100644 --- a/tests/test_scripts.py +++ b/tests/test_scripts.py @@ -318,8 +318,19 @@ def collect_test_cases(): @pytest.mark.parametrize("test_case", TEST_CASES, ids=[tc["description"] for tc in TEST_CASES]) -def test_scripts(test_case): +def test_scripts(test_case, request): '''Run parametrized script tests.''' + + # Skip BigWig tests on macOS as the required tools are not available + import platform + import pytest + + description = test_case["description"] + if platform.system() == "Darwin" and ("bigwig" in description.lower() or + "bedgraphtobigwig" in description.lower() or + "wigtobigwig" in description.lower()): + pytest.skip(f"Skipping {description} on macOS as UCSC tools are not available") + func = test_case["func"] # Directly retrieve the function object args = test_case["args"] func(*args)