Documentation for MassSpec.py
¶
MassSpec
¶
IndependentMassSpectrometer
¶
IndependentMassSpectrometer(
ionisation_mode,
chemicals,
mz_noise=None,
intensity_noise=None,
spike_noise=None,
isolation_transition_window="rectangular",
isolation_transition_window_params=None,
scan_duration=DEFAULT_SCAN_TIME_DICT,
task_manager=None,
skip_ms2_spectra_generation=False,
)
A class that represents (synchronous) mass spectrometry process. Independent here refers to how the intensity of each peak in a scan is independent of each other i.e. there's no ion supression effect.
Creates a mass spec object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ionisation_mode
|
POSITIVE or NEGATIVE |
required | |
chemicals
|
a list of Chemical objects in the dataset |
required | |
mz_noise
|
noise to apply to m/z values of generated peaks. Should be an instance of vimms.Noise.NoPeakNoise or others that inherit from it. |
None
|
|
intensity_noise
|
noise to apply to intensity values of generated peaks. Should be an instance of vimms.Noise.NoPeakNoise or others that inherit from it. |
None
|
|
spike_noise
|
spike noise in the generated spectra. Should be either None, or set an instance of vimms.Noise.UniformSpikeNoise if needed. |
None
|
|
isolation_transition_window
|
transition window for isolating peaks |
'rectangular'
|
|
isolation_transition_window_params
|
parameters for isolation |
None
|
|
scan_duration
|
a dictionary of scan time for each MS level, or an instance of vimms.ChemicalSamplers.ScanTimeSampler. |
DEFAULT_SCAN_TIME_DICT
|
|
task_manager
|
an instance of [vimms.MassSpec.TaskManager] to manage tasks, or None. |
None
|
Source code in vimms/MassSpec.py
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
|
clear_event
¶
clear_event(event_name)
Clears event handler for a given event name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name
|
the event name |
required |
Returns: None
Source code in vimms/MassSpec.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 |
|
clear_events
¶
clear_events()
Clear event handlers
Returns: None
Source code in vimms/MassSpec.py
549 550 551 552 553 554 555 556 557 |
|
close
¶
close()
Close this mass spec
Returns: None
Source code in vimms/MassSpec.py
574 575 576 577 578 579 580 581 |
|
dispatch_scan
¶
dispatch_scan(scan)
Notify the controller that a new scan has been generated at this point, the MS_SCAN_ARRIVED event handler in the controller is called and the processing queue will be updated with new sets of scan parameters to do.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scan
|
a newly generated scan. |
required |
Returns: None
Source code in vimms/MassSpec.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
|
fire_event
¶
fire_event(event_name, arg=None)
Simulates sending an event
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name
|
the event name |
required | |
arg
|
the event parameter |
None
|
Returns: None
Source code in vimms/MassSpec.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
|
get_params
¶
get_params()
Retrieves a new set of scan parameters from the processing queue
A new set of scan parameters from the queue if available,
Type | Description |
---|---|
otherwise it returns nothing (default scan set in actual MS) |
Source code in vimms/MassSpec.py
484 485 486 487 488 489 490 491 492 493 |
|
register_event
¶
register_event(event_name, handler)
Register event handler
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_name
|
the event name |
required | |
handler
|
the event handler |
required |
Returns: None
Source code in vimms/MassSpec.py
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
|
send_params
¶
send_params(params_list)
Send parameters to the instrument.
In the real IAPI mass spec, we would send these params to the instrument, but here we just store them in the list of pending tasks to be processed later
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params_list
|
the list of scan parameters to send. |
required |
Returns: None
Source code in vimms/MassSpec.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
|
step
¶
step(params=None, call_controller=True)
Performs one step of a mass spectrometry process
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
initial set of tasks from the controller |
None
|
|
call_controller
|
whether to actually call the controller or not |
True
|
Returns: a newly generated scan
Source code in vimms/MassSpec.py
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
Scan
¶
Scan(
scan_id,
mzs,
intensities,
ms_level,
rt,
scan_duration=None,
scan_params=None,
parent=None,
fragevent=None,
)
A class to store scan information
Creates a scan
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scan_id
|
current scan id |
required | |
mzs
|
an array of mz values |
required | |
intensities
|
an array of intensity values |
required | |
ms_level
|
the ms level of this scan |
required | |
rt
|
the starting retention time of this scan |
required | |
scan_duration
|
how long this scan takes, if known. |
None
|
|
scan_params
|
the parameters used to generate this scan, if known |
None
|
|
parent
|
parent precursor peak, if known |
None
|
|
fragevent
|
fragmentation event associated to this scan, if any |
None
|
Source code in vimms/MassSpec.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 |
|
ScanEvent
¶
ScanEvent(
chem,
query_rt,
ms_level,
peaks,
scan_id,
parents_intensity=None,
parent_adduct=None,
parent_isotope=None,
precursor_mz=None,
isolation_window=None,
scan_params=None,
)
A class to store fragmentation events. Mostly used for benchmarking purpose
Creates a fragmentation event
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chem
|
the chemical that were fragmented |
required | |
query_rt
|
the time when fragmentation occurs |
required | |
ms_level
|
MS level of fragmentation |
required | |
peaks
|
the set of peaks produced during the fragmentation event |
required | |
scan_id
|
the scan id linked to this fragmentation event |
required | |
parents_intensity
|
the intensity of the chemical that was fragmented at the time it was fragmented |
None
|
|
parent_adduct
|
the adduct that was fragmented of the chemical |
None
|
|
parent_isotope
|
the isotope that was fragmented of the chemical |
None
|
|
precursor_mz
|
the precursor mz of the scan |
None
|
|
isolation_window
|
the isolation window of the scan |
None
|
|
scan_params
|
the scan parameter settings that were used |
None
|
Source code in vimms/MassSpec.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
ScanEventPeak
¶
ScanEventPeak(mz, rt, intensity, ms_level)
A class to represent an empirical or sampled scan-level peak object
Creates a peak object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mz
|
mass-to-charge value |
required | |
rt
|
retention time value |
required | |
intensity
|
intensity value |
required | |
ms_level
|
MS level |
required |
Source code in vimms/MassSpec.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
TaskManager
¶
TaskManager(buffer_size=5)
A class to track how many new tasks (scan commands) that we can send, given the buffer size of the mass spec.
Initialises the task manager.
At any point, this class will ensure that there is not more than this number of tasks enqueued on the mass spec, see https://github.com/thermofisherlsms/iapi/issues/22.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buffer_size
|
maximum buffer or queue size on the mass spec. |
5
|
Source code in vimms/MassSpec.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
add_current
¶
add_current(tasks)
Add to the list of current tasks (ready to send)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks
|
list of current tasks |
required |
Returns: None
Source code in vimms/MassSpec.py
211 212 213 214 215 216 217 218 219 220 221 |
|
add_pending
¶
add_pending(tasks)
Add to the list of pending tasks (sent but not received)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tasks
|
list of pending tasks |
required |
Returns: None
Source code in vimms/MassSpec.py
223 224 225 226 227 228 229 230 231 232 233 |
|
current_size
¶
current_size()
Get the size of current tasks
Returns: the size of current tasks
Source code in vimms/MassSpec.py
297 298 299 300 301 302 303 304 |
|
peek_current
¶
peek_current()
Get the first current task (ready to send) without removing it
Returns: a current task
Source code in vimms/MassSpec.py
279 280 281 282 283 284 285 286 |
|
peek_pending
¶
peek_pending()
Get the first pending task (sent but not received) without removing it
Returns: a pending task
Source code in vimms/MassSpec.py
288 289 290 291 292 293 294 295 |
|
pending_size
¶
pending_size()
Get the size of pending tasks
Returns: the size of pending tasks
Source code in vimms/MassSpec.py
306 307 308 309 310 311 312 313 |
|
pop_current
¶
pop_current()
Remove the first current task (ready to send)
Returns: a current task
Source code in vimms/MassSpec.py
261 262 263 264 265 266 267 268 |
|
pop_pending
¶
pop_pending()
Remove the first pending task (sent but not received)
Returns: a pending task
Source code in vimms/MassSpec.py
270 271 272 273 274 275 276 277 |
|
remove_pending
¶
remove_pending(completed_task)
Remove a completed task from the list of pending tasks
Parameters:
Name | Type | Description | Default |
---|---|---|---|
completed_task
|
a newly completed task |
required |
Returns: None
Source code in vimms/MassSpec.py
235 236 237 238 239 240 241 242 243 244 245 |
|
to_send
¶
to_send()
Select current tasks that could be sent to the mass spec, ensuring that buffer_size on the mass spec is not exceeded.
Returns: None
Source code in vimms/MassSpec.py
247 248 249 250 251 252 253 254 255 256 257 258 259 |
|