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

angelolab / mibi-bin-tools / 5525465609

11 Jul 2023 10:25PM UTC coverage: 99.686% (-0.001%) from 99.687%
5525465609

Pull #56

github

web-flow
Merge 354f66aa8 into a8cbc1fd9
Pull Request #56: Truncate the mass range to time-of-flight conversion to ensure consistent range extraction

170 of 171 branches covered (99.42%)

Branch coverage included in aggregate %.

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

147 of 147 relevant lines covered (100.0%)

6.0 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
6✔
2
import pandas as pd
6✔
3

4
from alpineer import misc_utils
6✔
5

6

7
def make_panel(mass: Union[float, List[float]],
6✔
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)
6✔
29
    if target_name is not None:
6✔
30
        target_name = misc_utils.make_iterable(target_name)
6✔
31
        if len(mass) != len(target_name):
6✔
32
            raise ValueError(
6✔
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))]
6✔
38

39
    # check for range lists
40
    for r in (low_range, high_range):
6✔
41
        if misc_utils.make_iterable(r) == r:
6✔
42
            if len(r) != len(mass):
6✔
43
                raise ValueError(
6✔
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)
6✔
50
    high_range = misc_utils.make_iterable(high_range)
6✔
51

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

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

66
    return pd.DataFrame(rows)
6✔
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