From 26217066fcf5a224be8dc269c57373e4eea2e14d Mon Sep 17 00:00:00 2001 From: Joao Ferreira Date: Tue, 20 Feb 2024 17:11:45 +0000 Subject: [PATCH] No longer modify input contig file when fixing headers --- src/fixContigHeaders.py | 4 ++-- src/mitohifi.py | 5 +++-- src/modify_circularity_in_header.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fixContigHeaders.py b/src/fixContigHeaders.py index 4702e79..e4c62b9 100644 --- a/src/fixContigHeaders.py +++ b/src/fixContigHeaders.py @@ -19,9 +19,9 @@ def fix_headers(fasta_in, fasta_out): f2.write(f">{fixed_id}\n") print(f'Header substitution: {original_id} replaced by {fixed_id}') else: - f2.write(line) + f2.write(line.strip() + "\n") else: - f2.write(line) + f2.write(line.strip() + "\n") if __name__ == "__main__": fix_headers(sys.argv[1], sys.argv[2]) diff --git a/src/mitohifi.py b/src/mitohifi.py index fa6e091..6c0efa1 100644 --- a/src/mitohifi.py +++ b/src/mitohifi.py @@ -182,8 +182,9 @@ def main(): original_contigs = args.c fixContigHeaders.fix_headers(original_contigs, "fixed_header_contigs.fasta") - os.remove(original_contigs) # remove original contig file - shutil.move("fixed_header_contigs.fasta", original_contigs) # replace original contigs file by the version that has the headers fixed + original_contigs = "fixed_header_contigs.fasta" + #os.remove(original_contigs) # remove original contig file + #shutil.move("fixed_header_contigs.fasta", original_contigs) # replace original contigs file by the version that has the headers fixed # if contigs contain canu description of circularization, include that into the identifier modify_circularity_in_header(original_contigs, "include_circ_to_contigs_IDs.contigs.fasta") diff --git a/src/modify_circularity_in_header.py b/src/modify_circularity_in_header.py index 7a17ef0..eb00aba 100644 --- a/src/modify_circularity_in_header.py +++ b/src/modify_circularity_in_header.py @@ -14,4 +14,4 @@ def modify_circularity_in_header(input_file, output_file): new_header = f">{header}" output_fasta.write(new_header + "\n") else: - output_fasta.write(line + "\n") + output_fasta.write(line.strip() + "\n")