Skip to content

datasets summary genome taxon should have exitcode of 0 when there are no genomes for a valid taxon #482

Open
@zachary-foster

Description

@zachary-foster

When looking up genomes for a taxon that exists but has no genomes on NCBI, the following error is given:

root@b9976d6ef296:/data# datasets summary genome taxon 97225
Error: The taxonomy ID '97225' is valid for 'Gomphonemataceae', but no genome data is currently available for this taxon.

Use datasets summary genome taxon <command> --help for detailed help about a command.

root@b9976d6ef296:/data# echo $?
1

The text of this is helpful, but it returns a "failure" exit code of 1. It seems to me that this is not actually a failed API call. It understood the request and returned what was asked, which in this case is nothing. I Think the exit code should be 0 in this case. This is important in automated pipelines because the exit code is used to check if a process failed or not. In the case of our Nextflow pipeline, I had to do this bash gymnastics in order to bypass this behavior:

# NOTE: This command errors when a taxon is found but has no data rather than just outputing an empty file,
#   so the below code forces it to not fail and then fails if any other error occur
datasets summary genome taxon ${args} ${taxon.toLowerCase()} 1> ${output_path} 2> >(tee error.txt >&2) || true
if [ -s error.txt ] && ! grep -q 'no genome data is currently available for this taxon.' error.txt; then
    exit 1
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions