eggnogdb / eggnog-mapper

Fast genome-wide functional annotation through orthology assignment
http://eggnog-mapper.embl.de
GNU Affero General Public License v3.0
556 stars 105 forks source link

Issue: shutil.SameFileError in wrap_up Method #513

Open brchn6 opened 3 months ago

brchn6 commented 3 months ago

I've encountered an issue with the wrap_up method in the emapper.py script, where the script throws a shutil.SameFileError when the source and destination paths for copying a file are the same. This error interrupts the execution of the script, preventing it from completing the annotation process.

Steps to Reproduce:

Run the emapper.py script with input parameters that result in the source and destination paths being the same. Observe the shutil.SameFileError in the traceback.

Error Traceback:

Traceback (most recent call last):
  File "/home/projects/zeevid/barc/.conda/envs/eggnog-mapper/bin/emapper.py", line 708, in <module>
    n, elapsed_time = emapper.run(args, args.input, args.annotate_hits_table, args.cache_file)
  File "/home/projects/zeevid/barc/.conda/envs/eggnog-mapper/lib/python3.9/site-packages/eggnogmapper/emapper.py", line 358, in run
    self.wrap_up(predictor, searcher)
  File "/home/projects/zeevid/barc/.conda/envs/eggnog-mapper/lib/python3.9/site-packages/eggnogmapper/emapper.py", line 318, in wrap_up
    shutil.copy(full_fname, self.output_dir)
  File "/home/projects/zeevid/barc/.conda/envs/eggnog-mapper/lib/python3.9/shutil.py", line 427, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/projects/zeevid/barc/.conda/envs/eggnog-mapper/lib/python3.9/shutil.py", line 244, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/home/projects/zeevid/Analyses/2023-VernalPool/2024-Bar_Cohen_analysis/eggNOG-mapper_with_diamond_and_prodigal/cleaned_contigs_annotation.emapper.genepred.fasta' and '/home/projects/zeevid/Analyses/2023-VernalPool/2024-Bar_Cohen_analysis/eggNOG-mapper_with_diamond_and_prodigal/cleaned_contigs_annotation.emapper.genepred.fasta' are the same file

Environment:

emapper-2.1.12 / Expected eggNOG DB version: 5.0.2 / Installed eggNOG DB version: 5.0.2 / Diamond version found: diamond version 2.0.11 / MMseqs2 version found: 13.45111 / Compatible novel families DB version: 1.0.1
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.9.2009 (Core)
Release:        7.9.2009
Codename:       Core
x86_64 x86_64 GNU/Linux
brchn6 commented 3 months ago

Script Calling:

# Define input and output files
FASTA_DATA_FILE=/home/projects/zeevid/Analyses/2023-VernalPool/2024-Bar_Cohen_analysis/Done_Results/post_Cleannig_Contis_From_low_Q_conting/output_dir_clean_contigs_length_threshold_coverage_threshold/cleaned_contigs.fasta
OUTPUT_DIR=/home/projects/zeevid/Analyses/2023-VernalPool/2024-Bar_Cohen_analysis/eggNOG-mapper_with_diamond_and_prodigal
OUTPUT_DIR_TMP=${OUTPUT_DIR}/tmp
OUTPUT_FILE_PREFIX=${OUTPUT_DIR}/cleaned_contigs_annotation
HITS_FILE=${OUTPUT_FILE_PREFIX}/hits.tsv

# Ensure output directory and file paths are correct
mkdir -p $OUTPUT_DIR_TMP
chmod -R 755 $OUTPUT_DIR_TMP

# Check if the source and destination files are the same
if [ "$FASTA_DATA_FILE" != "$OUTPUT_FILE_PREFIX.fasta" ]; then
    echo "Source and destination files are different. Running emapper.py."
    # Run eggNOG-mapper
    emapper.py \
        -i $FASTA_DATA_FILE \
        --output_dir $OUTPUT_DIR \
        --output $OUTPUT_FILE_PREFIX \
        -m diamond \
        --cpu 4 \
        --itype genome \
        --genepred prodigal \
        --scratch_dir $OUTPUT_DIR_TMP \
        --temp_dir $OUTPUT_DIR_TMP \
        --override
Cantalapiedra commented 2 months ago

Dear @brchn6 ,

Thank you for reporting this. I will label it as a bug, and hopefully we can fix it soon.

Best, Carlos