Skip to content

Instantly share code, notes, and snippets.

@jamessdixon
Created June 4, 2023 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamessdixon/5d9c2bf108079f98d289174783a65097 to your computer and use it in GitHub Desktop.
Save jamessdixon/5d9c2bf108079f98d289174783a65097 to your computer and use it in GitHub Desktop.
file_name = 'alignments_' + flavor + '.csv'
with open(file_name, 'w') as t:
header = 'b_mz'+ '\t'+ 'b_start'+ '\t'+ 'b_end'+ '\t'+ 'b_ion'+ '\t'+ 'b_charge'+ '\t'+ 'b_pid'+ 'b_score'+ '\t'+ 'y_mz'+ '\t'+ 'y_start'+ '\t'+ 'y_end'+ '\t'+ 'y_ion'+ '\t'+ 'y_charge'+ '\t'+ 'y_pid'+ '\t'+ 'y_score'+ '\n'
t.write(header)
for alignment in alignments:
b,y= alignment
b_mass, b_start, b_end, b_ion, b_charge, b_pid, b_score = b
y_mass, y_start, y_end, y_ion, y_charge, y_pid, y_score = y
item = str(b_mass)+ '\t' + str(b_start)+ '\t' + str(b_end)+ '\t' + str(b_ion)+ '\t' + str(b_charge) + '\t' + str(b_pid) + '\t' + str(b_score) + str(y_mass)+ '\t' + str(y_start)+ '\t' + str(y_end)+ '\t' + str(y_ion)+ '\t' + str(y_charge) + '\t' + str(y_pid) + '\t' + str(y_score) + '\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