Skip to content

Documentation for Agent.py

Agent

AbstractAgent

AbstractAgent()

Bases: ABC

An abstract class to represent an Agent.

Agents has a scope outside the controller, and it can be handy way to enable a controller that has a global state across runs.

Source code in vimms/Agent.py
18
19
def __init__(self):
    self.task_list = []

act abstractmethod

act(scan_to_process)

Acts on a scan

Parameters:

Name Type Description Default
scan_to_process

the scan to process

required
Source code in vimms/Agent.py
51
52
53
54
55
56
57
58
@abstractmethod
def act(self, scan_to_process):
    """Acts on a scan

    Arguments:
        scan_to_process: the scan to process
    """
    pass

next_tasks abstractmethod

next_tasks(scan_to_process, controller, current_task_id)

Schedule the next action

Subclasses should implement this to handle scans in the appropriate way.

Parameters:

Name Type Description Default
scan_to_process Scan

the next scan to process

required
controller Controller

parent controller class for this agent

required
current_task_id int

the current task ID

required

Returns:

Type Description
tuple

a tuple containing:

new_tasks(vimms.Common.ScanParameters): a list of new tasks to run current_task_id (int): the id of the current task next_processed_scan_id (int): the id of the next incoming scan to process

Source code in vimms/Agent.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
@abstractmethod
def next_tasks(self, scan_to_process, controller, current_task_id):
    """Schedule the next action

    Subclasses should implement this to handle scans in the appropriate way.

    Arguments:
        scan_to_process (vimms.MassSpec.Scan): the next scan to process
        controller (vimms.Controller.base.Controller): parent controller class for this agent
        current_task_id (int): the current task ID

    Returns:
        (tuple): a tuple containing:

            new_tasks(vimms.Common.ScanParameters): a list of new tasks to run
            current_task_id (int): the id of the current task
            next_processed_scan_id (int): the id of the next incoming scan to process
    """
    pass

reset abstractmethod

reset()

Reset the internal state of this Agent

Source code in vimms/Agent.py
60
61
62
63
@abstractmethod
def reset(self):
    """Reset the internal state of this Agent"""
    pass

update abstractmethod

update(last_scan, controller)

Updates agent internal state based on the last scan

Parameters:

Name Type Description Default
last_scan

the last scan that has been processed

required
controller

the parent controller class that contains this agent

required
Source code in vimms/Agent.py
41
42
43
44
45
46
47
48
49
@abstractmethod
def update(self, last_scan, controller):
    """Updates agent internal state based on the last scan

    Arguments:
        last_scan: the last scan that has been processed
        controller: the parent controller class that contains this agent
    """
    pass

FullScanAgent

FullScanAgent()

Bases: AbstractAgent

Create a full-scan agent that performs only MS1 scans.

Source code in vimms/Agent.py
67
68
69
def __init__(self):
    """Create a full-scan agent that performs only MS1 scans."""
    super().__init__()

TopNDEWAgent

TopNDEWAgent(
    ionisation_mode,
    N,
    isolation_width,
    mz_tol,
    rt_tol,
    min_ms1_intensity,
    exclude_after_n_times=1,
    exclude_t0=0,
)

Bases: AbstractAgent

Create a Top-N agent that performs the standard Top-N fragmentation typically seen in Data-Dependant Acquisition (DDA) process.

Parameters:

Name Type Description Default
ionisation_mode string

the ionisation mode, either POSITIVE or NEGATIVE.

required
N int

the number of top-N most intense precursors to fragment.

required
isolation_width float

the isolation width, in Dalton.

required
mz_tol float

m/z tolerance for dynamic exclusion

required
rt_tol float

retention time tolerance (in seconds) for dynamic exclusion.

required
min_ms1_intensity float

the minimum intensity of MS1 (precursor) peak to fragment.

required
Source code in vimms/Agent.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
def __init__(
    self,
    ionisation_mode,
    N,
    isolation_width,
    mz_tol,
    rt_tol,
    min_ms1_intensity,
    exclude_after_n_times=1,
    exclude_t0=0,
):
    """Create a Top-N agent that performs the standard Top-N fragmentation typically seen
    in Data-Dependant Acquisition (DDA) process.

    Arguments:
        ionisation_mode (string): the ionisation mode, either POSITIVE or NEGATIVE.
        N (int): the number of top-N most intense precursors to fragment.
        isolation_width (float): the isolation width, in Dalton.
        mz_tol (float): m/z tolerance for dynamic exclusion
        rt_tol (float): retention time tolerance (in seconds) for dynamic exclusion.
        min_ms1_intensity (float): the minimum intensity of MS1 (precursor) peak to fragment.
    """
    super().__init__()
    self.ionisation_mode = ionisation_mode
    self.N = N
    self.isolation_width = isolation_width
    self.min_ms1_intensity = min_ms1_intensity
    self.mz_tol = mz_tol
    self.rt_tol = rt_tol
    self.exclude_after_n_times = exclude_after_n_times
    self.exclude_t0 = exclude_t0
    self.exclusion = TopNExclusion(
        self.mz_tol,
        self.rt_tol,
        exclude_after_n_times=self.exclude_after_n_times,
        exclude_t0=self.exclude_t0,
    )
    self.seen_actions = collections.Counter()