KwanLab / Autometa

Autometa: Automated Extraction of Genomes from Shotgun Metagenomes
https://autometa.readthedocs.io
Other
40 stars 15 forks source link

unclustered recruitment fails if there are no unclustered bins #168

Closed chasemc closed 3 years ago

chasemc commented 3 years ago

If there are no unclustered bins to start then the Nextflow pipeline fails because of a raise error in the Python script:

https://github.com/KwanLab/Autometa/blob/9b8f00e952094e98cd83027371938730a2933ca4/autometa/binning/unclustered_recruitment.py#L573-L575

chasemc commented 3 years ago

Additional context: I currently have a local branch that pulls isolate genome scaffolds and inputs them for clustering so they should cluster very easily. I'm assuming that these produce no unclustered contigs after the first binning

chasemc commented 3 years ago

Proposed fix (I can do this if it looks ok @WiscEvan @Sidduppal @jason-c-kwan ): Change

 if not prev_num_unclustered:
        raise BinningError("No unclustered contigs are available to recruit!")

to

    if not prev_num_unclustered:
        print("No unclustered contigs are available to recruit!")
        return 

And change the Nextflow outputs to

output.... optional: true  
evanroyrees commented 3 years ago

The return does not necessarily exit the program. We have logging enabled throughout the library so this should be used instead of print.

import sys

if not prev_num_unclustered:
    logger.warning("No unclustered contigs are available to recruit!")
    sys.exit(status=0)

Otherwise, I'm fine with changing this.

chasemc commented 3 years ago

Yeah but sys.exit() also raises an exception so I think that also won't work. The return should just exit main() and be sufficient.

chasemc commented 3 years ago

Oh, status=0, my bad

chasemc commented 3 years ago

Just putting here for posterity:

sys.exit(status=0) gives TypeError: exit() takes no keyword arguments

Changed to: sys.exit(0)

chasemc commented 3 years ago

Tested and

import sys

if not prev_num_unclustered:
    logger.warning("No unclustered contigs are available to recruit!")
    sys.exit(status=0)

works. Adding to next commit

chasemc commented 3 years ago

Fixed by https://github.com/KwanLab/Autometa/pull/157