Skip to content
Snippets Groups Projects
Commit 34b217a9 authored by Hottlet Valentin's avatar Hottlet Valentin
Browse files

Json file maker

parent d532fef7
Branches
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import csv
import shutil
import sys
import re
import json
from functools import cmp_to_key, partial
from src import markers as ma
......@@ -189,4 +190,20 @@ def build_peptide_table_from_set_of_markers(set_of_markers, outfile_name, list_o
tsv_file.close()
"""
def json_build_peptide_table_from_set_of_markers(set_of_markers, outfile_name, list_of_headers=None, append_file=""):
JSON_file = open(outfile_name, "w")
if not list_of_headers:
headers={restitute_field(key) for m in set_of_markers for key in m.field}
list_of_headers=(config.sort_headers(headers))
else:
list_of_headers=list(map(utils.standard_upper, list_of_headers))
set_of_codes=[m.code() for m in set_of_markers]
list_of_codes=config.sort_headers(set_of_codes)
list_of_markers=list(set_of_markers)
list_of_markers.sort(key=cmp_to_key(partial(marker_order, list_of_codes=list_of_codes)))
dicts = []
for m in list_of_markers:
dicts.append(dict(zip(list_of_headers, m.field.values())))
json.dump(dicts, JSON_file)
JSON_file.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment