wwood / CoverM

Read coverage calculator for metagenomics
GNU General Public License v3.0
311 stars 31 forks source link

Request -- use https://crates.io/crates/which for external command checking? #207

Closed nickp60 closed 3 weeks ago

nickp60 commented 8 months ago

Hello! This is a bit of a strange request, but I am running into a strange error when running dockerized versions of CoverM. It is related to this somehow, I am not entirely sure why it only fails on a collaborators machine, but CoverM fails when attempting to find the Minimap2 executable using the bash -c 'which minimap2' command, which is here.

When running this manually (not via CoverM), I get the following:

docker run ghcr.io/vdblab/coverm:0.6.1  bash -c "which minimap2"
/opt/conda/bin/minimap2

So far so good. When run on my institute's HPC via singularity, I get

singularity run docker://ghcr.io/vdblab/coverm:0.6.1 bash -c "which minimap2"
INFO:    Using cached SIF image
/opt/conda/bin/minimap2

which is good as well. However, when my collaborator attempts on their cluster, they get

Illegal option --

That results in their CoverM calls failing with the following error:

[2024-03-13T18:11:22Z ERROR bird_tool_utils::external_command_checker] Could not find an available minimap2 executable.
[2024-03-13T18:11:22Z ERROR bird_tool_utils::external_command_checker] The STDERR was: "Illegal option --\n"
[2024-03-13T18:11:22Z ERROR bird_tool_utils::external_command_checker] Cannot continue without minimap2. Testing for presence with `which minimap2` failed
thread 'main' panicked at 'Failed to find installed minimap2: "Cannot continue without minimap2. Testing for presence with `which minimap2` failed"', src/external_command_checker.rs:9:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

We think that somehow Singularity is getting mixed up between system and container versions of which.

Would you be willing to switch to a different method of executable checking? I don't know Rust, but it looks like there is a pretty popular package for this: https://crates.io/crates/which

Thanks in advance!

microjishuai commented 8 months ago

I encountered the same "ERROR bird_tool_utils::external_command_checker] Could not find an available minimap2 executable" when running a coverM.sif container built using apptainer, even though minimap2 was successfully installed in the container.

wwood commented 8 months ago

Hi,

Thanks for the specific solution - probably a better idea anyway. I've pushed a new commit which uses the which crate.

I don't actually make that docker/apptainer - so unsure how to test - maybe you can? Thanks, ben

nickp60 commented 8 months ago

Amazing, thank you so much!! I just pushed an image with these changes, and I'll ask our collaborator if it works on their system now! @microjishuai, would you be willing to try as well?

docker run ghcr.io/vdblab/coverm:0.7.0-dev
# or
singularity run docker://ghcr.io/vdblab/coverm:0.7.0-dev
almita commented 3 months ago

Hi, a bit late to this but I was running into the same issue while trying to build a coverm apptainer image. I tried running your updated image @nickp60 but it doesn't have coverm installed? Maybe I missed something, but I tried both: apptainer build docker://ghcr.io/vdblab/coverm:0.7.0-dev and apptainer run docker://ghcr.io/vdblab/coverm:0.7.0-dev. and I try to run coverm --version inside the image (after apptainer shell coverm:0.7.0-dev.sif) it says bash: coverm: command not found.

nickp60 commented 3 months ago

Hi @almita, Thank you for the heads up, and apologies! I have pushed an update and ensured that it runs: ghcr.io/vdblab/coverm:0.7.0-dev2:

docker run ghcr.io/vdblab/coverm:0.7.0-dev2 coverm --help
Mapping coverage analysis for metagenomics

Usage: coverm <subcommand> ...

Main subcommands:
    contig  Calculate coverage of contigs
    genome  Calculate coverage of genomes

Less used utility subcommands:
    make    Generate BAM files through alignment
    filter  Remove (or only keep) alignments with insufficient identity
    cluster Dereplicate and cluster genomes
    shell-completion
        Generate shell completion scripts

Other options:
    -V, --version   Print version information

Ben J. Woodcroft <benjwoodcroft near gmail.com>

I'm not sure exactly what happened, but I think my test env was configured poorly and I was actually executing the local install rather than the containerized on. Apologies for the confusion!

almita commented 3 months ago

Thanks it works now!

wwood commented 3 weeks ago

Go team. Thanks people.