diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b1b5063..de462c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,6 +56,8 @@ jobs: # Testing with flanking sequences which run off the contig end python extract_genes_abricate.py -a test/input/flanking.tsv -g test/genomes -o test/out_flanking_15bp --flanking --flanking-bp 15 cmp test/correct/correct_flanking_15bp.out test/out_flanking_15bp/flanking_blaCTX-M-15.out + # Test with empty file + python extract_genes_abricate.py -a test/input/test_empty.tsv -g test/genomes -o test/out_empty - name: Tests with combined ABRicate files from multiple genomes run: | # Normal gene extraction should work for files with multiple genomes diff --git a/extract_genes_abricate.py b/extract_genes_abricate.py index 7a730c5..5b19467 100644 --- a/extract_genes_abricate.py +++ b/extract_genes_abricate.py @@ -220,12 +220,15 @@ def main(args): logging.debug(f"Calling function main") check_outdir(args.outdir) df = read_abricatefile(args.abricatefile, args.csv) - if args.genecluster == False: - logging.debug(f"Executing main_genes for extraction of single genes") - main_genes(df, args) + if df.shape[0] > 0: + if args.genecluster == False: + logging.debug(f"Executing main_genes for extraction of single genes") + main_genes(df, args) + else: + logging.debug(f"Executing main_genecluster for extraction of gene clusters") + main_genecluster(df, args) else: - logging.debug(f"Executing main_genecluster for extraction of gene clusters") - main_genecluster(df, args) + logging.warning(f"No hits found in {args.abricatefile}, outputting empty directory {args.outdir}") if __name__ == '__main__': parser = argparse.ArgumentParser(description='Extract genes from genes based on ABRicate output.') diff --git a/test/input/test_empty.tsv b/test/input/test_empty.tsv new file mode 100644 index 0000000..9423b57 --- /dev/null +++ b/test/input/test_empty.tsv @@ -0,0 +1 @@ +#FILE SEQUENCE START END STRAND GENE COVERAGE COVERAGE_MAP GAPS %COVERAGE %IDENTITY DATABASE ACCESSION PRODUCT RESISTANCE