Skip to content

Commit

Permalink
Fix stripping of _R_ pattern
Browse files Browse the repository at this point in the history
Using lstrip() led to unwanted behavior
  • Loading branch information
edgardomortiz committed Feb 14, 2024
1 parent 2f83164 commit 176c617
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion captus/bioformats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3488,7 +3488,10 @@ def rehead_root_msa(fasta_in: Path, fasta_out: Path, outgroup: list, remove_R_=F
aligned = {}
aligned_w_R_ = fasta_to_dict(fasta_out)
for seq_name in aligned_w_R_:
aligned[seq_name.lstrip("_R_")] = aligned_w_R_[seq_name]
if seq_name.startswith("_R_"):
aligned[seq_name[3:]] = aligned_w_R_[seq_name]
else:
aligned[seq_name] = aligned_w_R_[seq_name]
else:
aligned = fasta_to_dict(fasta_out)

Expand Down
5 changes: 4 additions & 1 deletion captus/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,10 @@ def cleanup_fastas(all_fastas: list):
intermediate_fasta = fasta_to_dict(intermediate_fasta_path)
output_fasta = {}
for seq_name in intermediate_fasta:
new_seq_name = seq_name.lstrip("_R_")
if seq_name.startswith("_R_"):
new_seq_name = seq_name[3:]
else:
new_seq_name = seq_name
output_fasta[new_seq_name] = {
"sequence": intermediate_fasta[seq_name]["sequence"],
"description": input_fasta[new_seq_name]["description"],
Expand Down

0 comments on commit 176c617

Please sign in to comment.