Skip to content

Instantly share code, notes, and snippets.

@jamessdixon
Last active June 7, 2023 18:52
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/aab55dfec351307bc3894d0aaeaf0deb to your computer and use it in GitHub Desktop.
Save jamessdixon/aab55dfec351307bc3894d0aaeaf0deb to your computer and use it in GitHub Desktop.
def write_sorted_clusters_to_disk(sorted_clusters, flavor):
file_name = 'sorted_clusters_' + flavor + '.csv'
with open(file_name, 'w') as t:
header = 'score'+ '\t'+ 'pid'+ '\t'+ 'start'+ '\t'+ 'end'+ '\t'+ 'mz'+ '\t'+ 'charge'+ '\t'+ 'extensions'+ "\t" + 'seq'+ "\n"
t.write(header)
for sorted_cluster in sorted_clusters:
item = str(sorted_cluster.score)+ '\t' + str(sorted_cluster.pid)+ '\t' + str(sorted_cluster.start)+ '\t' + str(sorted_cluster.end)+ '\t' + str(sorted_cluster.mz)+ '\t' + str(sorted_cluster.charge) + '\t' + str(sorted_cluster.extensions) + '\t' + str(sorted_cluster.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