Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Fix header length
  • Loading branch information
asmmahmoud authored Jan 14, 2025
1 parent 998e359 commit 0eba472
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions nanoinsight/create_consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,19 @@ def rename_header(con_dir, id_seq):
# Remove the '.con' extension from the name
name = name.replace('.con', '')
# Add coordinates of SV to the header line
matching_row = id_seq[id_seq['ID'] == name]
SV_info = matching_row['sv_coo'].values[0]
# matching_row = id_seq[id_seq['ID'] == name]
# SV_info = matching_row['sv_coo'].values[0]
# Open file and read lines
with open(os.path.join(con_dir, con_file), "r") as f:
lines = f.readlines()
# Replace first line with SV ID and coordinates info if or only SV ID if header length > 50
header_info = f"{name}{SV_info}"
if len(header_info) > 50:
new_header = f">{name}\n"
else:
new_header = f">{header_info}\n"
lines[0] = new_header
# Replace first line with SV ID and coordinates info if or only SV ID if header length > 50
#header_info = f"{name}{SV_info}"
# if len(header_info) > 47:
# new_header = f">{name}\n"
# else:
# new_header = f">{header_info}\n"
lines[0] = new_header
# Open file for writing and write updated lines
with open(os.path.join(con_dir, con_file), "w") as f:
f.writelines(lines)
Expand Down

0 comments on commit 0eba472

Please sign in to comment.