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

Prevent ZeroDivisionError errors in log output #68

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions vatools/ref_transcript_mismatch_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,18 +202,22 @@ def main(args_input = sys.argv[1:]):
if args.filter is not None:
vcf_writer.close()

processable_variant_percentage = "N/A" if processable_variant_count == 0 else round(float(filtered_variant_count)/float(processable_variant_count)*100, 2)
variant_percentage = "N/A" if variant_count == 0 else round(float(filtered_variant_count)/float(variant_count)*100, 2)
processable_transcript_percentage = "N/A" if processable_transcript_count == 0 else round(float(filtered_transcript_count)/float(processable_transcript_count)*100, 2)
transcript_percentage = "N/A" if transcript_count == 0 else round(float(filtered_transcript_count)/float(transcript_count)*100, 2)
logging.info(
"\nTotal number of variants: {}\n".format(variant_count) +
"Total number of processable variants (at least one missense, inframe indels, or frameshift transcript): {}\n".format(processable_variant_count) +
"Total number of variants with mismatched annotations: {}\n".format(filtered_variant_count) +
"Percentage of processable variants with mismatched annotations: {}%\n".format(round(float(filtered_variant_count)/float(processable_variant_count)*100, 2)) +
"Percentage of variants with mismatched annotations: {}%\n".format(round(float(filtered_variant_count)/float(variant_count)*100, 2)) +
"Percentage of processable variants with mismatched annotations: {}%\n".format(processable_variant_percentage) +
"Percentage of variants with mismatched annotations: {}%\n".format(variant_percentage) +
"\n" +
"Total number of transcripts: {}\n".format(transcript_count) +
"Total number of processable transcripts (missense, inframe indels, frameshifts): {}\n".format(processable_transcript_count) +
"Total number of transcripts with mismatched annotations: {}\n".format(filtered_transcript_count) +
"Percentage of processable transcripts with mismatched annotations: {}%\n".format(round(float(filtered_transcript_count)/float(processable_transcript_count)*100, 2)) +
"Percentage of all transcripts with mismatched annotations: {}%\n".format(round(float(filtered_transcript_count)/float(transcript_count)*100, 2))
"Percentage of processable transcripts with mismatched annotations: {}%\n".format(processable_transcript_percentage) +
"Percentage of all transcripts with mismatched annotations: {}%\n".format(transcript_percentage)
)

if __name__ == '__main__':
Expand Down
Loading