From d6ec6cd08bad76efbd2df78574d0b43f8c1f0204 Mon Sep 17 00:00:00 2001 From: hechth Date: Thu, 14 Nov 2024 14:50:43 +0100 Subject: [PATCH] removed jupyter notebook --- ...tchms_export_skyline_transition_list.ipynb | 112 ------------------ 1 file changed, 112 deletions(-) delete mode 100644 tools/matchms/matchms_export_skyline_transition_list.ipynb diff --git a/tools/matchms/matchms_export_skyline_transition_list.ipynb b/tools/matchms/matchms_export_skyline_transition_list.ipynb deleted file mode 100644 index cc875009..00000000 --- a/tools/matchms/matchms_export_skyline_transition_list.ipynb +++ /dev/null @@ -1,112 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "from matchms.importing import load_from_msp\n", - "from matchms.exporting.metadata_export import get_metadata_as_array\n", - "\n", - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "spectra_file = \"test-data/filtering/reduce_to_top_n_peaks.msp\"\n", - "name_key = 'compound_name'\n", - "cols_to_include = [name_key, 'retention_index', 'mz', 'intensity']" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2024-11-06 14:26:01,189:WARNING:matchms:add_precursor_mz:No precursor_mz found in metadata.\n", - "2024-11-06 14:26:01,190:WARNING:matchms:add_retention:None can't be converted to float.\n", - "2024-11-06 14:26:01,191:WARNING:matchms:add_precursor_mz:No precursor_mz found in metadata.\n", - "2024-11-06 14:26:01,192:WARNING:matchms:add_precursor_mz:No precursor_mz found in metadata.\n", - "2024-11-06 14:26:01,193:WARNING:matchms:add_precursor_mz:No precursor_mz found in metadata.\n", - "2024-11-06 14:26:01,194:WARNING:matchms:add_precursor_mz:No precursor_mz found in metadata.\n" - ] - } - ], - "source": [ - "spectra = list(load_from_msp(spectra_file))\n", - "spectra_dict = {}\n", - "for spectrum in spectra:\n", - " spectra_dict[spectrum.get(name_key)] = spectrum" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": {}, - "outputs": [], - "source": [ - "spectra_metadata, cols = get_metadata_as_array(spectra)\n", - "spectra_metadata_df = pd.DataFrame(spectra_metadata)" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": {}, - "outputs": [], - "source": [ - "spectra_metadata_df['peaks'] = spectra_metadata_df[name_key].transform(lambda x: spectra_dict[x].peaks)\n", - "spectra_metadata_df['mz'] = spectra_metadata_df['peaks'].transform(lambda x: x.mz)\n", - "spectra_metadata_df['intensity'] = spectra_metadata_df['peaks'].transform(lambda x: x.intensities)" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [], - "source": [ - "spectra_metadata_df = spectra_metadata_df.explode(['mz', 'intensity']).reset_index(drop=True)" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": {}, - "outputs": [], - "source": [ - "result = spectra_metadata_df[cols_to_include].rename(columns={'compound_name': 'precursor name', 'retention_index': 'retention index'})" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "matchms", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.12.7" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -}