Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combine_kreports.py error #98

Open
sarrahroseml opened this issue Jun 12, 2024 · 0 comments
Open

combine_kreports.py error #98

sarrahroseml opened this issue Jun 12, 2024 · 0 comments

Comments

@sarrahroseml
Copy link

sarrahroseml commented Jun 12, 2024

I created this script to iterate through the kreport files and run the combine_kreports.py file on them to combine. However, I am getting a ZeroDivisionError.

FILES=()
NAMES=()

for DIR in $(find $PARENT_DIR -mindepth 1 -maxdepth 1 -type d); do
    SAMPLE_NAME=$(basename $DIR)
    echo "Checking directory: $DIR"
    KRAKEN_FILE=$(find $DIR -type f -name "*.kraken")
    echo "Found file: $KRAKEN_FILE"

    if [ -n "$KRAKEN_FILE" ]; then
        FILES+=("$KRAKEN_FILE")
        NAMES+=("$SAMPLE_NAME")
    fi
done

# Convert arrays to space-separated strings
FILES_STR="${FILES[@]}"
NAMES_STR=$(IFS="," ; echo "${NAMES[*]}")

# Define the output file name
OUTPUT_FILE="${PARENT_DIR}/combined_kraken_output.txt"

# Print the gathered files and names for debugging
echo "Files: $FILES_STR"
echo "Names: $NAMES_STR"

# Run the combine_bracken_output.py script with the found files and sample names
python3 /global/scratch/projects/fc_wolflab/software/KrakenTools/combine_kreports.py -r ${FILES[@]} -o $OUTPUT_FILE


>>STEP 1: READING REPORTS
        0/16 samples processed^M        1/16 samples processed^M        2/16 samples processed^M        3/16 samples processed^M        4/16 samples processed^M        5/16 samples processed^M        6/16 samples processed^M        7/16 samples processed^M        8/16 samples processed^M        9/16 samples processed^M        10/16 samples processed^M       11/16 samples processed^M       12/16 samples processed^M       13/16 samples processed^M       14/16 samples processed^M       15/16 samples processed^M       16/16 samples processed^M       16/16 samples processed
>>STEP 2: WRITING NEW REPORT HEADERS
>>STEP 3: PRINTING REPORT
Traceback (most recent call last):
  File "/global/scratch/projects/fc_wolflab/software/KrakenTools/combine_kreports.py", line 326, in <module>
    main()
  File "/global/scratch/projects/fc_wolflab/software/KrakenTools/combine_kreports.py", line 286, in main
    o_file.write("%0.4f\t" % (float(u_reads[0])/float(total_reads[0])*100))
ZeroDivisionError: float division by zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant