Skip to content

Commit

Permalink
No longer modify input contig file when fixing headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Ferreira committed Feb 20, 2024
1 parent 109c7e4 commit 2621706
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/fixContigHeaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
5 changes: 3 additions & 2 deletions src/mitohifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/modify_circularity_in_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 2621706

Please sign in to comment.