Skip to content

Commit

Permalink
Add exact numbers to guardrails printouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Snicker7 committed Mar 19, 2024
1 parent 3007142 commit ab0c61a
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions CRISPResso2/CRISPRessoShared.py
Original file line number Diff line number Diff line change
Expand Up @@ -2167,7 +2167,7 @@ def __init__(self, messageHandler, minimum):
"""
self.messageHandler = messageHandler
self.minimum = minimum
self.message = " Low number of total reads: <{}".format(minimum)
self.message = " Low number of total reads: <{}.".format(minimum)

def safety(self, total_reads):
"""Safety check, if total is below minimum send warnings
Expand All @@ -2178,6 +2178,7 @@ def safety(self, total_reads):
The total reads, unaligned and aligned
"""
if total_reads < self.minimum:
self.message = self.message + " Total reads: {}".format(total_reads)
self.messageHandler.display_warning(self.message)
self.messageHandler.report_warning(self.message)

Expand All @@ -2195,7 +2196,7 @@ def __init__(self, messageHandler, cutoff):
The float representation of percentage of minimum reads to be aligned
"""
self.messageHandler = messageHandler
self.message = " <={val}% of reads were aligned".format(val=(cutoff * 100))
self.message = " <={val}% of reads were aligned.".format(val=(cutoff * 100))
self.cutoff = cutoff

def safety(self, total_reads, n_read_aligned):
Expand All @@ -2211,6 +2212,7 @@ def safety(self, total_reads, n_read_aligned):
if total_reads == 0:
return
if (n_read_aligned/total_reads) <= self.cutoff:
self.message = self.message + " Total reads: {}, Aligned reads: {}".format(total_reads, n_read_aligned)
self.messageHandler.display_warning(self.message)
self.messageHandler.report_warning(self.message)

Expand Down Expand Up @@ -2244,7 +2246,7 @@ def safety(self, total_reads, reads_aln_amplicon):
expected_per_amplicon = total_reads / len(reads_aln_amplicon.keys())
for amplicon, aligned in reads_aln_amplicon.items():
if aligned <= (expected_per_amplicon * self.cutoff):
amplicon_message = self.message + amplicon
amplicon_message = self.message + amplicon + ", Percent aligned: {}".format((aligned/total_reads) * 100)
self.messageHandler.display_warning(amplicon_message)
self.messageHandler.report_warning(amplicon_message)

Expand Down Expand Up @@ -2278,7 +2280,7 @@ def safety(self, total_reads, reads_aln_amplicon):
expected_per_amplicon = total_reads / len(reads_aln_amplicon.keys())
for amplicon, aligned in reads_aln_amplicon.items():
if aligned >= (expected_per_amplicon * self.cutoff):
amplicon_message = self.message + amplicon
amplicon_message = self.message + amplicon + ", Percent aligned: {}".format((aligned/total_reads) * 100)
self.messageHandler.display_warning(amplicon_message)
self.messageHandler.report_warning(amplicon_message)

Expand All @@ -2296,7 +2298,7 @@ def __init__(self, messageHandler, cutoff):
The float representation of the maximum percentage of modifications outside of the quantification window
"""
self.messageHandler = messageHandler
self.message = " <={}% of modifications were inside of the quantification window ".format(cutoff * 100)
self.message = " <={}% of modifications were inside of the quantification window.".format(cutoff * 100)
self.cutoff = cutoff

def safety(self, mods_in_window, mods_outside_window):
Expand All @@ -2313,6 +2315,7 @@ def safety(self, mods_in_window, mods_outside_window):
if total_mods == 0:
return
if ((mods_in_window / total_mods) <= self.cutoff):
self.message = self.message + " Total modifications: {}, Modifications in window: {}, Modifications outside window: {}".format(total_mods, mods_in_window, mods_outside_window)
self.messageHandler.display_warning(self.message)
self.messageHandler.report_warning(self.message)

Expand All @@ -2330,7 +2333,7 @@ def __init__(self, messageHandler, percentage_start_end):
The float representation of the maximum percentage reads that have modifications on either end
"""
self.messageHandler = messageHandler
self.message = " >={}% of reads have modifications at the start or end. ".format(percentage_start_end * 100)
self.message = " >={}% of reads have modifications at the start or end.".format(percentage_start_end * 100)
self.percent = percentage_start_end

def safety(self, total_reads, irregular_reads):
Expand All @@ -2346,6 +2349,7 @@ def safety(self, total_reads, irregular_reads):
if total_reads == 0:
return
if (irregular_reads / total_reads) >= self.percent:
self.message = self.message + " Total reads: {}, Irregular reads: {}".format(total_reads, irregular_reads)
self.messageHandler.display_warning(self.message)
self.messageHandler.report_warning(self.message)

Expand All @@ -2363,7 +2367,7 @@ def __init__(self, messageHandler, cutoff):
The float representation of how many of the total substitutions can be outside of the quantification window
"""
self.messageHandler = messageHandler
self.message = " >={}% of substitutions were outside of the quantification window. ".format(cutoff * 100)
self.message = " >={}% of substitutions were outside of the quantification window.".format(cutoff * 100)
self.cutoff = cutoff

def safety(self, global_subs, subs_outside_window):
Expand All @@ -2379,6 +2383,7 @@ def safety(self, global_subs, subs_outside_window):
if global_subs == 0:
return
if ((subs_outside_window / global_subs) >= self.cutoff):
self.message = self.message + " Total substitutions: {}, Substitutions outside window: {}".format(global_subs, subs_outside_window)
self.messageHandler.display_warning(self.message)
self.messageHandler.report_warning(self.message)

Expand All @@ -2396,7 +2401,7 @@ def __init__(self, messageHandler, cutoff):
The float representation of how many of the total modifications can be subsitutions
"""
self.messageHandler = messageHandler
self.message = " >={}% of modifications were substitutions. This could potentially indicate poor sequencing quality. ".format(cutoff * 100)
self.message = " >={}% of modifications were substitutions. This could potentially indicate poor sequencing quality.".format(cutoff * 100)
self.cutoff = cutoff

def safety(self, mods_in_window, mods_outside_window, global_subs):
Expand All @@ -2415,6 +2420,7 @@ def safety(self, mods_in_window, mods_outside_window, global_subs):
if total_mods == 0:
return
if ((global_subs / total_mods) >= self.cutoff):
self.message = self.message + " Total modifications: {}, Substitutions: {}".format(total_mods, global_subs)
self.messageHandler.display_warning(self.message)
self.messageHandler.report_warning(self.message)

Expand Down Expand Up @@ -2447,7 +2453,7 @@ def safety(self, sequences):
"""
for name, length in sequences.items():
if length < self.cutoff:
sequence_message = self.message + name
sequence_message = self.message + name + ", Length: {}".format(length)
self.messageHandler.display_warning(sequence_message)
self.messageHandler.report_warning(sequence_message)

Expand Down Expand Up @@ -2481,6 +2487,6 @@ def safety(self, amplicons, read_len):
"""
for name, length in amplicons.items():
if length > (read_len * self.cutoff):
sequence_message = self.message + name
sequence_message = self.message + name + ", Amplicon length: {}, Read length: {}".format(length, read_len)
self.messageHandler.display_warning(sequence_message)
self.messageHandler.report_warning(sequence_message)

0 comments on commit ab0c61a

Please sign in to comment.