Skip to content

Commit

Permalink
style: improve logging output for multi-reference primer search
Browse files Browse the repository at this point in the history
style: improve final stats log print
  • Loading branch information
florianzwagemaker committed Jul 27, 2023
1 parent cd4f413 commit 49d0506
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion AmpliGone/AmpliGone.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ def main():
removed_coordinates = tuple(chain(*ProcessedReads["Removed_coordinates"]))

log.info(
f"\tRemoved a total of [bold cyan]{len(removed_coordinates)}[/bold cyan] nucleotides. This is [bold cyan]{round((len(removed_coordinates)/total_nuc_preprocessing)*100, 2)}%[/bold cyan] of the total amount of nucleotides present in the original reads."
f"\tRemoved a total of [bold cyan]{len(removed_coordinates)}[/bold cyan] nucleotides."
)
log.info(
f"\tThis is [bold cyan]{round((len(removed_coordinates)/total_nuc_preprocessing)*100, 2)}%[/bold cyan] of the total amount of nucleotides present in the original reads."
)
log.info(
f"\tThese nucleotides were removed from [bold cyan]{len(set(removed_coordinates))}[/bold cyan] unique nucleotide-coordinates."
Expand Down
9 changes: 5 additions & 4 deletions AmpliGone/fasta2bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def CoordListGen(primerfile, referencefile, err_rate=0.1):
# cpu or time intensive process anyway.
# Might come back to this when there's more time to create a better solution.
for ref_seq, ref_id in zip(ref_seq, ref_id):
log.info(f"Searching for primers in reference-id: [yellow]{ref_id}[/yellow]")
for primer in primers:
seq = str(primer.seq)
revcomp = Seq.reverse_complement(seq)
Expand All @@ -108,20 +109,20 @@ def CoordListGen(primerfile, referencefile, err_rate=0.1):
rev_coords = get_coords(revcomp, ref_seq, err_rate)
if coords and rev_coords:
log.warning(
f"Primer [yellow underline]{primer.id}[/yellow underline] found on both forward and reverse strand of '[yellow]{ref_id}[/yellow]'.\n[yellow bold]Check to see if this is intended.[/yellow bold]"
f"\tPrimer [yellow underline]{primer.id}[/yellow underline] found on both forward and reverse strand of [yellow]{ref_id}[/yellow].\n\t[yellow bold]Check to see if this is intended.[/yellow bold]"
)
if not coords and not rev_coords:
log.warning(
f"Skipping [yellow underline]{primer.id}[/yellow underline] as it is found on neither forward or reverse strand of [yellow underline]{ref_id}[/yellow underline].\n[yellow bold]Check to see if this is intended.[/yellow bold]"
f"\tSkipping [yellow underline]{primer.id}[/yellow underline] as it is found on neither forward or reverse strand of [yellow underline]{ref_id}[/yellow underline].\n\t[yellow bold]Check to see if this is intended.[/yellow bold]"
)
continue
if coords and len(coords) > 1:
log.warning(
f"Primer [yellow underline]{primer.id}[/yellow underline] found on multiple locations on [underline]forward strand[/underline]: \n\t[yellow]{coords}\n[bold]Check to see if this is intended.[/yellow][/bold]"
f"\tPrimer [yellow underline]{primer.id}[/yellow underline] found on multiple locations on [underline]forward strand[/underline] of [yellow underline]{ref_id}[/yellow underline]: \n\t[yellow]{coords}\n\t[bold]Check to see if this is intended.[/yellow][/bold]"
)
if rev_coords and len(rev_coords) > 1:
log.warning(
f"Primer [yellow underline]{primer.id}[/yellow underline] found on multiple locations on [underline]reverse strand[/underline]: {rev_coords}.\nCheck to see if this is intended."
f"\tPrimer [yellow underline]{primer.id}[/yellow underline] found on multiple locations on [underline]reverse strand[/underline] of [yellow underline]{ref_id}[/yellow underline]: \n\t[yellow]{rev_coords}\n\t[bold]Check to see if this is intended.[/yellow][/bold]"
)
for start, end in coords.union(rev_coords):
if any(o in primer.id for o in keyl):
Expand Down

0 comments on commit 49d0506

Please sign in to comment.