From 9ca141c80fcf88ca66ac4260b2a91fa9484e70ca Mon Sep 17 00:00:00 2001 From: clintval Date: Thu, 19 Sep 2024 19:07:55 -0700 Subject: [PATCH] fix: change bwa to bwa-aln-interactive --- .github/workflows/tests.yml | 34 ++++++++------------------ prymer.yml | 1 - prymer/offtarget/bwa.py | 19 ++++++++++---- prymer/offtarget/offtarget_detector.py | 4 +-- 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9437b81..eeff0d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,10 +32,19 @@ jobs: with: python-version: ${{ matrix.PYTHON_VERSION }} + - name: Install poetry + run: | + python -m pip install --upgrade pip + python -m pip install poetry==${{env.POETRY_VERSION}} + + - name: Configure poetry + shell: bash + run: poetry config virtualenvs.in-project true + - name: Set up miniconda uses: conda-incubator/setup-miniconda@v3 with: - miniforge-variant: Mambaforge + miniforge-variant: Miniforge miniforge-version: latest channels: conda-forge,bioconda activate-environment: prymer @@ -45,29 +54,6 @@ jobs: auto-activate-base: false python-version: ${{ matrix.PYTHON_VERSION }} - - name: Install fulcrumgenomics/bwa - shell: bash -l {0} - run: | - conda activate prymer - pushd bwa - make -j $(nproc) - cp bwa ${CONDA_PREFIX}/bin - popd - - - name: Configure poetry and check lock file - shell: bash -l {0} - run: | - conda activate prymer - poetry config virtualenvs.in-project false - poetry check --lock - - - name: Poetry install - shell: bash -l {0} - run: | - conda activate prymer - poetry lock --no-update - poetry install --with dev - - name: Unit tests (with doctest and coverage) shell: bash -l {0} run: | diff --git a/prymer.yml b/prymer.yml index d4cebb1..817a458 100644 --- a/prymer.yml +++ b/prymer.yml @@ -2,7 +2,6 @@ name: prymer channels: - bioconda - conda-forge - - defaults dependencies: - bioconda::bwa-aln-interactive=0.7.18 - bioconda::primer3=2.6.1 diff --git a/prymer/offtarget/bwa.py b/prymer/offtarget/bwa.py index 7c4bd47..5b15bc9 100644 --- a/prymer/offtarget/bwa.py +++ b/prymer/offtarget/bwa.py @@ -15,7 +15,13 @@ hits in the "XA" tag than the total number hits reported in the "HN". This occurs when BWA finds more hits than `max_hits` (see `bwt aln -X`). - ## Example +Use of this module requires installation of a custom version of BWA named `bwa-aln-interactive`. +See: + + - https://github.com/fulcrumgenomics/bwa/tree/interactive_aln + - https://bioconda.github.io/recipes/bwa-aln-interactive/README.html + +## Example ```python >>> from pathlib import Path @@ -193,7 +199,10 @@ class BwaAlnInteractive(ExecutableRunner): the process running and be able to send it chunks of reads periodically and get alignments back without waiting for a full batch of reads to be sent. - See: https://github.com/fulcrumgenomics/bwa/tree/interactive_aln + See: + - https://bioconda.github.io/recipes/bwa-aln-interactive/README.html + - https://github.com/fulcrumgenomics/bwa/tree/interactive_aln + Attributes: max_hits: the maximum number of hits to report - if more than this number of seed hits @@ -207,7 +216,7 @@ def __init__( self, ref: Path, max_hits: int, - executable: str | Path = "bwa", + executable: str | Path = "bwa-aln-interactive", max_mismatches: int = 3, max_mismatches_in_seed: int = 3, max_gap_opens: int = 0, @@ -222,7 +231,7 @@ def __init__( ref: the path to the reference FASTA, which must be indexed with bwa. max_hits: the maximum number of hits to report - if more than this number of seed hits are found, report only the count and not each hit. - executable: string or Path representation of the `bwa` executable path + executable: string or Path representation of the `bwa-aln-interactive` executable path max_mismatches: the maximum number of mismatches allowed in the full query sequence max_mismatches_in_seed: the maximum number of mismatches allowed in the seed region max_gap_opens: the maximum number of gap opens allowed in the full query sequence @@ -252,7 +261,7 @@ def __init__( else: message = "BWA index file does not exist:\n\t" message += "\t\n".join(f"{p}" for p in missing_aux_paths) - raise FileNotFoundError(f"{message}\nPlease index with: `bwa index {ref}`") + raise FileNotFoundError(f"{message}\nPlease index with: `{executable_path} index {ref}`") # -N = non-iterative mode: search for all n-difference hits (slooow) # -S = output SAM (run samse) diff --git a/prymer/offtarget/offtarget_detector.py b/prymer/offtarget/offtarget_detector.py index 1773042..1876ee0 100644 --- a/prymer/offtarget/offtarget_detector.py +++ b/prymer/offtarget/offtarget_detector.py @@ -123,7 +123,7 @@ class OffTargetResult: class OffTargetDetector: """A class for detecting off-target mappings of primers and primer pairs that uses a custom - version of "bwa aln". + version of "bwa aln" named "bwa-aln-interactive". The off-target detection is faster and more sensitive than traditional isPCR and in addition can correctly detect primers that are repetitive and contain many thousands or millions of mappings @@ -146,7 +146,7 @@ def __init__( threads: Optional[int] = None, keep_spans: bool = True, keep_primer_spans: bool = True, - executable: str | Path = "bwa", + executable: str | Path = "bwa-aln-interactive", ) -> None: """ Args: