INNER CODE UNIT · Python
process_spectra_json_node
sirius-ms/sirius · affinity_selection_ms/src/main/resources/makeMirrorSpectrumPlot.py:12
def process_spectra_json_node(jsonRoot):
spectra_node = jsonRoot['spectra']
spectra_dict = {}
for d in spectra_node:
processed_dict = {'recall': d['recall'], 'weighted_recall': d['weighted_recall']}
msrd_spectrum = {'annotated_matched': {'mz': [], 'intensity': [], 'atom_indices': []}, 'not_annotated_matched': {'mz': [], 'intensity': []}, 'annotated_not_matched': {'mz': [], 'intensity': [], 'atom_indices': []}, 'not_annotated_not_matched': {'mz': [], 'intensity': []}}
for peak in d['msrd_spectrum']:
if peak['isMatched']:
if len(peak['atom_indices']) > 0:
msrd_spectrum['annotated_matched']['mz'].append(peak['mz'])
msrd_spectrum['annotated_matched']['intensity'].append(peak['intensity'])
msrd_spectrum['annotated_matched']['atom_indices'].append(tuple(peak['atom_indices']))
else:
msrd_spectrum['not_annotated_matched']['mz'].append(peak['mz'])
msrd_spectrum['not_annotated_matched']['intensity'].append(peak['intensity'])
else: