• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

angelolab / mibi-bin-tools / 6711862799

31 Oct 2023 08:03PM UTC coverage: 98.496% (-1.2%) from 99.725%
6711862799

Pull #35

github

web-flow
Merge 77c2df398 into b8782bf63
Pull Request #35: Adds total spectra extraction

221 of 226 branches covered (0.0%)

Branch coverage included in aggregate %.

19 of 19 new or added lines in 1 file covered. (100.0%)

172 of 173 relevant lines covered (99.42%)

7.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/mibi_bin_tools/panel_utils.py
1
from typing import Union, List
8✔
2
import pandas as pd
8✔
3

4
from alpineer import misc_utils
8✔
5

6

7
def make_panel(mass: Union[float, List[float]],
8✔
8
               target_name: Union[str, List[str], None] = None,
9
               low_range: Union[float, List[float]] = 0.3,
10
               high_range: Union[float, List[float]] = 0.0) -> pd.DataFrame:
11
    """ Creates single mass panel
12

13
    Args:
14
        mass (float | List[float]):
15
            central m/z for signal
16
        target_name (str | List[str] | None):
17
            naming for target. 'Target' if None
18
        low_range (float | List[float]):
19
            units below central mass to start integration
20
        high_range (float | List[float]):
21
            units above central mass to stop integration
22

23
    Returns:
24
        pd.DataFrame:
25
            single mass panel as pandas dataframe
26
    """
27

28
    mass = misc_utils.make_iterable(mass)
8✔
29
    if target_name is not None:
8✔
30
        target_name = misc_utils.make_iterable(target_name)
8✔
31
        if len(mass) != len(target_name):
8✔
32
            raise ValueError(
8✔
33
                '`mass` and `target_name` did not contain the same number of elements.  '
34
                'If target names aren\'t required, then set `target_name=None`.  '
35
            )
36
    else:
37
        target_name = [f'targ{i}' for i in range(len(mass))]
8✔
38

39
    # check for range lists
40
    for r in (low_range, high_range):
8✔
41
        if misc_utils.make_iterable(r) == r:
8✔
42
            if len(r) != len(mass):
8✔
43
                raise ValueError(
8✔
44
                    '`mass` and a range argument did not contain the same number of elements.  '
45
                    'If only one integration range is required, `low_range` and `high_range` can '
46
                    'be set to float values, e.g `low_range=0.3`'
47
                )
48

49
    low_range = misc_utils.make_iterable(low_range)
8✔
50
    high_range = misc_utils.make_iterable(high_range)
8✔
51

52
    if len(low_range) != len(mass):
8✔
53
        low_range = low_range * len(mass)
8✔
54
    if len(high_range) != len(mass):
8✔
55
        high_range = high_range * len(mass)
8✔
56

57
    rows = []
8✔
58
    for m, ch, low, high in zip(mass, target_name, low_range, high_range):
8✔
59
        rows.append({
8✔
60
            'Mass': m,
61
            'Target': ch,
62
            'Start': m - low,
63
            'Stop': m + high,
64
        })
65

66
    return pd.DataFrame(rows)
8✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc