Documentation for Common.py
DummyFormula
A dummy wrapper to store an mz as a vimms.Common.Formula. This is convenient as it allows us to treat an m/z value like an (unknown) formula.
Source code in vimms/Common.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
__init__(mz)
Create a DummyFormula object Args: mz: the m/z value to wrap
Source code in vimms/Common.py
272 273 274 275 276 277 278 | |
Formula
A class to represent a chemical formula
Source code in vimms/Common.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
__init__(formula_string)
Creates a Formula object. Formulae can be sampled to generate vimms.Chemicals.Chemical objects.
| Parameters: |
|
|---|
Source code in vimms/Common.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
compute_exact_mass()
Computes the exact mass of this formula Returns: the exact mass
Source code in vimms/Common.py
247 248 249 250 251 252 253 254 255 256 257 | |
Precursor
A class to store precursor peak information when writing an MS2 scan.
Source code in vimms/Common.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | |
__init__(precursor_mz, precursor_intensity, precursor_charge, precursor_scan_id)
Create a Precursor object. Args: precursor_mz: the m/z value of this precursor peak. precursor_intensity: the intensity value of this precursor peak. precursor_charge: the charge of this precursor peak precursor_scan_id: the assocated MS1 scan ID that contains this precursor peak
Source code in vimms/Common.py
400 401 402 403 404 405 406 407 408 409 410 411 412 | |
ScanParameters
A class to store parameters used to instruct the mass spec how to generate a scan. This object is usually created by the controller. It is used by the controller to instruct the mass spec what actions (scans) to perform next.
Source code in vimms/Common.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 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 | |
__init__()
Create a scan parameter object
Source code in vimms/Common.py
331 332 333 334 335 | |
compute_isolation_windows()
Gets the full-width (DDA) isolation window around a precursor m/z
Source code in vimms/Common.py
370 371 372 373 374 375 376 377 | |
get(key)
Gets scan parameter value
| Parameters: |
|
|---|
Returns: the corresponding value in this ScanParameter
Source code in vimms/Common.py
349 350 351 352 353 354 355 356 357 358 359 360 361 | |
get_all()
Get all scan parameters Returns: all the scan parameters
Source code in vimms/Common.py
363 364 365 366 367 368 | |
set(key, value)
Set scan parameter value
| Parameters: |
|
|---|
Returns: None
Source code in vimms/Common.py
337 338 339 340 341 342 343 344 345 346 347 | |
add_log_file(log_path, level)
Add path to log file Args: log_path: filename to output the logging to level: the log level
Returns: None
Source code in vimms/Common.py
604 605 606 607 608 609 610 611 612 613 614 | |
chromatogramDensityNormalisation(rts, intensities)
Definition to standardise the area under a chromatogram to 1.
| Parameters: |
|
|---|
Returns: updated intensities that have been standardised so the area is 1.
Source code in vimms/Common.py
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 | |
create_if_not_exist(out_dir)
Creates a directory if it doesn't already exist Args: out_dir: the directory to create, if it doesn't exist
Returns: None.
Source code in vimms/Common.py
428 429 430 431 432 433 434 435 436 437 438 439 | |
download_file(url, out_file=None)
Download a file from the given URL Args: url: URL to download out_file: filename of output file to save to
Returns: filename of the out_file
Source code in vimms/Common.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | |
extract_zip_file(in_file, delete=True)
Extract a zip file Args: in_file: the input zip file delete: whether to delete the input zip file after extracting
Returns: None
Source code in vimms/Common.py
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 | |
find_nearest_index_in_array(array, value)
Finds index in array where the value is the nearest
| Parameters: |
|
|---|
Returns: index in array where the value is the nearest
Source code in vimms/Common.py
633 634 635 636 637 638 639 640 641 642 643 644 645 | |
get_dda_scan_param(mz, intensity, precursor_scan_id, isolation_width, mz_tol, rt_tol, agc_target=DEFAULT_MS2_AGC_TARGET, max_it=DEFAULT_MS2_MAXIT, collision_energy=DEFAULT_MS2_COLLISION_ENERGY, source_cid_energy=DEFAULT_SOURCE_CID_ENERGY, orbitrap_resolution=DEFAULT_MS2_ORBITRAP_RESOLUTION, mass_analyser=DEFAULT_MS2_MASS_ANALYSER, activation_type=DEFAULT_MS1_ACTIVATION_TYPE, isolation_mode=DEFAULT_MS2_ISOLATION_MODE, polarity=POSITIVE, metadata=None, scan_id=None)
Generate the default MS2 scan parameters.
| Parameters: |
|
|---|
Returns: the parameters of the MS2 scan to create
Source code in vimms/Common.py
768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | |
get_default_scan_params(polarity=POSITIVE, agc_target=DEFAULT_MS1_AGC_TARGET, max_it=DEFAULT_MS1_MAXIT, collision_energy=DEFAULT_MS1_COLLISION_ENERGY, source_cid_energy=DEFAULT_SOURCE_CID_ENERGY, orbitrap_resolution=DEFAULT_MS1_ORBITRAP_RESOLUTION, default_ms1_scan_window=DEFAULT_MS1_SCAN_WINDOW, mass_analyser=DEFAULT_MS1_MASS_ANALYSER, activation_type=DEFAULT_MS1_ACTIVATION_TYPE, isolation_mode=DEFAULT_MS1_ISOLATION_MODE, metadata=None, scan_id=None)
Generate the default MS1 scan parameters.
| Parameters: |
|
|---|
Returns: the parameters of the MS1 scan to create
Source code in vimms/Common.py
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 | |
get_rt(spectrum)
Extracts RT value from a pymzml spectrum object
| Parameters: |
|
|---|
Returns: the retention time (in seconds)
Source code in vimms/Common.py
617 618 619 620 621 622 623 624 625 626 627 628 629 630 | |
load_obj(filename)
Load saved object from file
| Parameters: |
|
|---|
Returns: the loaded object
Source code in vimms/Common.py
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | |
save_obj(obj, filename)
Save object to file. This is useful for storing simulation results and other objects.
If the directory containing the specified filename doesn't exist, it will be created first. The object will be saved using gzip + pickle (highest protocol).
| Parameters: |
|
|---|
Returns: None
Source code in vimms/Common.py
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 | |
set_log_level(level, remove_id=None)
Set the logging level of the default logger Args: level: the new level to set remove_id: ID of previous log handler to be removed
Returns: the new log handler after setting the log level
Source code in vimms/Common.py
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 | |
set_log_level_debug(remove_id=None)
Set log level to DEBUG Args: remove_id: ID of previous log handler to be removed
Returns: None
Source code in vimms/Common.py
592 593 594 595 596 597 598 599 600 601 | |
set_log_level_info(remove_id=None)
Set log level to INFO Args: remove_id: ID of previous log handler to be removed
Returns: None
Source code in vimms/Common.py
580 581 582 583 584 585 586 587 588 589 | |
set_log_level_warning(remove_id=None)
Set log level to WARNING Args: remove_id: ID of previous log handler to be removed
Returns: None
Source code in vimms/Common.py
568 569 570 571 572 573 574 575 576 577 | |
uniform_list(N, min_val, max_val)
Generates a list of N uniformly random values from min_val to max_val Args: N: the number of items to generate min_val: the minimum range max_val: the maximum range
Returns: a list of N values
Source code in vimms/Common.py
700 701 702 703 704 705 706 707 708 709 710 711 | |