Created
June 4, 2023 13:41
-
-
Save jamessdixon/e61f773890ba4ae391b6fddc270629c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write_merged_hybrids_to_disk(merged_hybrids): | |
file_name = 'merged_hybrids_A.csv' | |
with open(file_name, 'w') as t: | |
header = 'total_score'+ '\t'+ 'pid'+ '\t'+ 'start'+ '\t'+ 'end'+ '\t'+ 'score'+ '\t'+ 'mz'+ '\t' + 'charge'+ '\t'+ 'extensions'+ '\t' + 'seq'+ '\n' | |
t.write(header) | |
for merged_hybrid in merged_hybrids: | |
total_score,b,y= merged_hybrid | |
b_pid,b_start,b_end,b_score,b_mz,b_charge,b_extensions,b_seq = b | |
item = str(total_score)+ '\t' + str(b_pid)+ '\t' + str(b_start)+ '\t' + str(b_end)+ '\t' + str(b_score) + '\t' + str(b_mz) + '\t' + str(b_charge) + '\t' + str(b_extensions) + '\t' + str(b_seq) + '\n' | |
with open(file_name, 'a') as t: | |
t.write(item) | |
y_pid,y_start,y_end,y_score,y_mz,y_charge,y_extensions,y_seq = y | |
item = str(total_score)+ '\t' + str(y_pid)+ '\t' + str(y_start)+ '\t' + str(y_end)+ '\t' + str(y_score)+ '\t' + str(y_mz) + '\t' + str(y_charge) + '\t' + str(y_extensions) + '\t' + str(y_seq) + '\n' | |
with open(file_name, 'a') as t: | |
t.write(item) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment