Skip to content

Commit

Permalink
Fix for newer pybedtools versions (#98)
Browse files Browse the repository at this point in the history
* Add test to catch pybedtools 0.9.1+ error

* Use mamba, add test with downgrading pybedtools

* Remove --name from mamba commands

* Add check for pybedtools version

* If 0.9.1+, use the newly introduced parameter, which is required for the run to complete successfully

* Typo fix

* Check pybedtools versions in CI
  • Loading branch information
lcoombe authored Sep 7, 2023
1 parent 83fd4b8 commit 40c697e
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 8 deletions.
30 changes: 24 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ jobs:
displayName: Install clang-format and clang-tidy
- script: |
source activate ntjoin_CI
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda python=3.9 pylint samtools=1.14
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda --file requirements.txt
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda python=3.9 mamba
mamba install --yes --quiet -c conda-forge -c bioconda pylint samtools
mamba install --yes --quiet -c conda-forge -c bioconda --file requirements.txt
displayName: Install Anaconda packages
- script: |
source activate ntjoin_CI
Expand All @@ -32,10 +33,18 @@ jobs:
displayName: Run pylint
- script: |
source activate ntjoin_CI
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda pytest bedtools samtools
mamba install --yes --quiet -c conda-forge -c bioconda pytest
cd tests
pytest -vs ntjoin_test.py
displayName: Run pytests
- script: |
source activate ntjoin_CI
python3 -c 'import pybedtools; print(pybedtools.__version__)'
mamba install --yes --quiet -c conda-forge -c bioconda pybedtools=0.9.0
python3 -c 'import pybedtools; print(pybedtools.__version__)'
cd tests
pytest -vs ntjoin_test.py
displayName: Run pytests with lower pybedtools version
- job: macOS_default_clang
pool:
Expand All @@ -49,12 +58,21 @@ jobs:

- script: |
source activate ntjoin_CI
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda python=3.9 pylint samtools=1.14
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda --file requirements.txt
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda python=3.9 mamba
mamba install --yes --quiet -c conda-forge -c bioconda pylint samtools
mamba install --yes --quiet -c conda-forge -c bioconda --file requirements.txt
displayName: Install Anaconda packages
- script: |
source activate ntjoin_CI
conda install --yes --quiet --name ntjoin_CI -c conda-forge -c bioconda pytest bedtools samtools
mamba install --yes --quiet -c conda-forge -c bioconda pytest
cd tests
pytest -vs ntjoin_test.py
displayName: Run pytests
- script: |
source activate ntjoin_CI
python3 -c 'import pybedtools; print(pybedtools.__version__)'
mamba install --yes --quiet -c conda-forge -c bioconda pybedtools=0.9.0
python3 -c 'import pybedtools; print(pybedtools.__version__)'
cd tests
pytest -vs ntjoin_test.py
displayName: Run pytests with lower pybedtools version
9 changes: 7 additions & 2 deletions bin/ntjoin_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,14 @@ def print_unassigned(self, assembly, assembly_fa, incorporated_segments, params,
"Also print out the sequences that were NOT scaffolded"
incorporated_segments_str = "\n".join([f"{chrom}\t{s}\t{e}"
for chrom, s, e in incorporated_segments])
incorporated_segments_bed = pybedtools.BedTool(incorporated_segments_str,
from_string=True).sort()
genome_bed, genome_dict = self.format_bedtools_genome(Ntjoin.scaffolds)
# Needed to deal with failure in complement step seen with pybedtools 0.9.1+
if pybedtools.__version__ < "0.9.1":
incorporated_segments_bed = pybedtools.BedTool(incorporated_segments_str,
from_string=True).sort()
else:
incorporated_segments_bed = pybedtools.BedTool(incorporated_segments_str,
from_string=True).sort(genome=genome_dict)
missing_bed = genome_bed.complement(i=incorporated_segments_bed, g=genome_dict)
missing_bed.saveas(self.args.p + "." + assembly + ".unassigned.bed")

Expand Down
5 changes: 5 additions & 0 deletions tests/ntjoin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,8 @@ def test_mx_r_r_overlap():
"Testing ntJoin with assembly + reference, rev-rev orientation, overlap code on"
paths = run_ntjoin_overlap("ref.fa", "scaf.r-r.overlapping.fa", "f-r_test_overlap")
assert paths.pop() == "ntJoin0\t1-:66-2099 20N 2-:0-2297"

def test_more_sequences():
"Testing ntJoin with more sequences - to catch pybedtools error seen with 0.9.1+"
paths = run_ntjoin_overlap("ref.longer.fa", "scaf.more_seqs.fa", "more_seqs_test")
assert len(paths) == 1
2 changes: 2 additions & 0 deletions tests/ref.longer.fa

Large diffs are not rendered by default.

Loading

0 comments on commit 40c697e

Please sign in to comment.