From 4af8dc86f68eb94f023d8b6ece901c2f8368be11 Mon Sep 17 00:00:00 2001 From: mschwoerer <82171591+mschwoer@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:43:13 +0100 Subject: [PATCH 1/2] fix typo in config --- alphadia/constants/default.yaml | 2 +- alphadia/planning.py | 6 +++--- tests/unit_tests/test_planning.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/alphadia/constants/default.yaml b/alphadia/constants/default.yaml index 3a174b5a..f2edafd1 100644 --- a/alphadia/constants/default.yaml +++ b/alphadia/constants/default.yaml @@ -53,7 +53,7 @@ library_prediction: # define custom alphabase modifications not part of unimod or alphabase # also used for decoy channels -custom_modififcations: +custom_modifications: # Dimethyl @K channel decoy Dimethyl:d12@K: composition: H(-2)2H(8)13C(2) diff --git a/alphadia/planning.py b/alphadia/planning.py index c8dc429f..50a544d2 100644 --- a/alphadia/planning.py +++ b/alphadia/planning.py @@ -170,11 +170,11 @@ def init_alphabase(self): """Init alphabase by registering custom modifications.""" # register custom modifications - if "custom_modififcations" in self.config: - n_modifications = len(self.config["custom_modififcations"]) + if "custom_modifications" in self.config: + n_modifications = len(self.config["custom_modifications"]) logging.info(f"Registering {n_modifications} custom modifications") - modification.add_new_modifications(self.config["custom_modififcations"]) + modification.add_new_modifications(self.config["custom_modifications"]) def load_library(self): """ diff --git a/tests/unit_tests/test_planning.py b/tests/unit_tests/test_planning.py index f46b92dc..1955436a 100644 --- a/tests/unit_tests/test_planning.py +++ b/tests/unit_tests/test_planning.py @@ -79,7 +79,7 @@ def test_custom_modifications(): temp_directory = tempfile.gettempdir() config = { - "custom_modififcations": { + "custom_modifications": { "ThisModDoesNotExists@K": { "composition": "H(10)", }, From 832ae928b1bacfb366eb57f1ebf9a0d3222b38ef Mon Sep 17 00:00:00 2001 From: mschwoerer <82171591+mschwoer@users.noreply.github.com> Date: Wed, 27 Nov 2024 18:48:41 +0100 Subject: [PATCH 2/2] substitute alphatims.utils.njit -> nb.njit --- alphadia/quadrupole.py | 15 ++++----------- alphadia/utils.py | 29 +++++++++++------------------ 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/alphadia/quadrupole.py b/alphadia/quadrupole.py index 8917ecdc..82c332de 100644 --- a/alphadia/quadrupole.py +++ b/alphadia/quadrupole.py @@ -1,10 +1,3 @@ -# native imports - -# alphadia imports -# alpha family imports -import alphatims.utils - -# third party imports import numba as nb import numpy as np from numba.experimental import jitclass @@ -13,7 +6,7 @@ from alphadia import utils -@alphatims.utils.njit +@nb.njit def logistic(x: np.array, mu: float, sigma: float): """Numba implementation of the logistic function @@ -41,13 +34,13 @@ def logistic(x: np.array, mu: float, sigma: float): return y -@alphatims.utils.njit +@nb.njit def logistic_rectangle(mu1, mu2, sigma1, sigma2, x): y = logistic(x, mu1, sigma1) - logistic(x, mu2, sigma2) return y -@alphatims.utils.njit +@nb.njit def linear(x, m, b): return m * x + b @@ -267,7 +260,7 @@ def get_calibrated_cycle(self, treshold=0.01): return new_cycle -@alphatims.utils.njit +@nb.njit def quadrupole_transfer_function_single( quadrupole_calibration_jit, observation_indices, scan_indices, isotope_mz ): diff --git a/alphadia/utils.py b/alphadia/utils.py index 7281f4d9..8054d4d0 100644 --- a/alphadia/utils.py +++ b/alphadia/utils.py @@ -1,18 +1,11 @@ -# native imports import logging import math import platform import re from ctypes import Structure, c_double -# alphadia imports -# alpha family imports -import alphatims.bruker -import alphatims.utils import numba as nb import numpy as np - -# third party imports import pandas as pd import torch from matplotlib import patches @@ -203,7 +196,7 @@ def plt_limits(mobility_limits, dia_cycle_limits): return rect -@alphatims.utils.njit() +@nb.njit() def find_peaks_1d(a, top_n=3): """accepts a dense representation and returns the top three peaks""" @@ -234,7 +227,7 @@ def find_peaks_1d(a, top_n=3): return scan, dia_cycle, intensity -@alphatims.utils.njit() +@nb.njit() def find_peaks_2d(a, top_n=3): """accepts a dense representation and returns the top three peaks""" scan = [] @@ -268,7 +261,7 @@ def find_peaks_2d(a, top_n=3): return scan, dia_cycle, intensity -@alphatims.utils.njit() +@nb.njit() def amean1(array): out = np.zeros(array.shape[0]) for i in range(len(out)): @@ -276,7 +269,7 @@ def amean1(array): return out -@alphatims.utils.njit() +@nb.njit() def amean0(array): out = np.zeros(array.shape[1]) for i in range(len(out)): @@ -284,7 +277,7 @@ def amean0(array): return out -@alphatims.utils.njit() +@nb.njit() def astd0(array): out = np.zeros(array.shape[1]) for i in range(len(out)): @@ -292,7 +285,7 @@ def astd0(array): return out -@alphatims.utils.njit() +@nb.njit() def astd1(array): out = np.zeros(array.shape[0]) for i in range(len(out)): @@ -323,7 +316,7 @@ def get_isotope_column_names(colnames): return [f"i_{i}" for i in get_isotope_columns(colnames)] -@alphatims.utils.njit() +@nb.njit() def mass_range(mz_list, ppm_tolerance): out_mz = np.zeros((len(mz_list), 2), dtype=mz_list.dtype) out_mz[:, 0] = mz_list - ppm_tolerance * mz_list / (10**6) @@ -348,12 +341,12 @@ class Point(Structure): _fields_ = [("x", c_double), ("y", c_double)] -@alphatims.utils.njit() +@nb.njit() def tile(a, n): return np.repeat(a, n).reshape(-1, n).T.flatten() -@alphatims.utils.njit +@nb.njit def make_slice_1d(start_stop): """Numba helper function to create a 1D slice object from a start and stop value. @@ -373,7 +366,7 @@ def make_slice_1d(start_stop): return np.array([[start_stop[0], start_stop[1], 1]], dtype=start_stop.dtype) -@alphatims.utils.njit +@nb.njit def make_slice_2d(start_stop): """Numba helper function to create a 2D slice object from multiple start and stop value. @@ -397,7 +390,7 @@ def make_slice_2d(start_stop): return out -@alphatims.utils.njit +@nb.njit def fourier_filter(dense_stack, kernel): """Numba helper function to apply a gaussian filter to a dense stack. The filter is applied as convolution wrapping around the edges, calculated in fourier space.