Documentation for Chemicals.py
Provides implementation of Chemicals objects that are used as input to the simulation.
Adducts
A class to represent an adduct of a chemical
Source code in vimms/Chemicals.py
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 185 186 187 188 189 190 191 192 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 | |
__init__(formula, adduct_proportion_cutoff=0.05, adduct_prior_dict=None)
Create an Adduct class
| Parameters: |
|
|---|
Source code in vimms/Chemicals.py
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 | |
get_adducts()
Get the adducts Returns: adducts in the correct proportion
Source code in vimms/Chemicals.py
186 187 188 189 190 191 192 193 194 195 196 197 198 | |
BaseChemical
The base class for Chemical objects across all MS levels. Chemicals at MS level = 1 is special and should be instantiated as either Known or Unknown chemicals. For other MS levels, please use the MSN class.
Source code in vimms/Chemicals.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
__init__(ms_level, children)
Defines a base chemical object Args: ms_level: the MS level of this chemical children: any children of this chemical
Source code in vimms/Chemicals.py
238 239 240 241 242 243 244 245 246 | |
Chemical
Bases: BaseChemical
The class that represents a Chemical object of MS-level 1. Should be realised as either Known or Unknown chemicals.
Source code in vimms/Chemicals.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
__init__(rt, max_intensity, chromatogram, children, base_chemical)
Create a Chemical object Args: rt: the starting RT value of this chemical max_intensity: the maximum intensity of this chemical chromatogram: the chromatogram of this chemical children: any children of this chemical base_chemical: the base chemical from which this chemical is derived
Source code in vimms/Chemicals.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | |
get_apex_rt()
Get the apex (highest point) RT of the chromatogram of this chemical Returns: the apex RT of the chromatogram
Source code in vimms/Chemicals.py
282 283 284 285 286 287 288 289 | |
get_original_parent()
Get the original base chemical in a recursive manner. This is necessary if the parent chemical also has another parent. Returns: the original base chemical
Source code in vimms/Chemicals.py
297 298 299 300 301 302 303 304 | |
ChemicalMixtureCreator
A class to create a list of known chemical objects using simplified, cleaned methods.
Source code in vimms/Chemicals.py
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 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 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
__init__(formula_sampler, rt_and_intensity_sampler=UniformRTAndIntensitySampler(), chromatogram_sampler=GaussianChromatogramSampler(), ms2_sampler=UniformMS2Sampler(), adduct_proportion_cutoff=0.05, adduct_prior_dict=None)
Create a mixture of vimms.Chemicals.KnownChemical objects. Args: formula_sampler: an instance of vimms.ChemicalSamplers.FormulaSampler to sample chemical formulae. rt_and_intensity_sampler: an instance of vimms.ChemicalSamplers.RTAndIntensitySampler to sample RT and intensity values. chromatogram_sampler: an instance of vimms.ChemicalSamplers.ChromatogramSampler to sample chromatograms. ms2_sampler: an instance of vimms.ChemicalSamplers.MS2Sampler to sample MS2 fragmentation spectra. adduct_proportion_cutoff: proportion of adduct cut-off adduct_prior_dict: custom adduct dictionary
Source code in vimms/Chemicals.py
620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
sample(n_chemicals, ms_levels, include_adducts_isotopes=True)
Samples chemicals.
| Parameters: |
|
|---|
Returns: a list of vimms.Chemicals.KnownChemical objects.
Source code in vimms/Chemicals.py
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 | |
ChemicalMixtureFromMZML
A class to create a list of known chemical objects from an mzML file using simplified, cleaned methods.
Source code in vimms/Chemicals.py
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 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
__init__(mzml_file_name, ms2_sampler=UniformMS2Sampler(), roi_params=None)
Create a ChemicalMixtureFromMZML class. Args: mzml_file_name: the mzML filename to extract vimms.Chemicals.UnknownChemical objects from. ms2_sampler: the MS2 sampler to use. Should be an instance of vimms.ChemicalSamplers.MS2Sampler. roi_params: parameters for ROI building, as defined in vimms.Roi.RoiBuilderParams.
Source code in vimms/Chemicals.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 | |
sample(n_chemicals, ms_levels, source_polarity=POSITIVE)
Generate a dataset of Chemicals from the mzml file Args: n_chemicals: the number of Chemical objects. Set to None to get all the ROIs. ms_levels: the maximum MS level source_polarity: either POSITIVE or NEGATIVE
Returns: the list of Chemicals from the mzML file.
Source code in vimms/Chemicals.py
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | |
DatabaseCompound
A class to represent a compound stored in a database, e.g. HMDB
Source code in vimms/Chemicals.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
__init__(name, chemical_formula, monisotopic_molecular_weight, smiles, inchi, inchikey)
Creates a DatabaseCompound object Args: name: the compound name chemical_formula: the formula of that compound monisotopic_molecular_weight: the monoisotopic weight of the compound smiles: SMILES of the compound inchi: InCHI of the compound inchikey: InCHI key of the compound
Source code in vimms/Chemicals.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
Isotopes
A class to represent an isotope of a chemical
Source code in vimms/Chemicals.py
68 69 70 71 72 73 74 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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
__init__(formula)
Create an Isotope object Args: formula: the formula for the given isotope
Source code in vimms/Chemicals.py
73 74 75 76 77 78 79 | |
get_isotopes(total_proportion)
Gets the isotope total proportion
| Parameters: |
|
|---|
Returns: the computed isotope total proportion
TODO: Add functionality for elements other than Carbon
Source code in vimms/Chemicals.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
KnownChemical
Bases: Chemical
A Chemical representation from a known chemical formula. Known chemicals have formula which are defined during creation.
Source code in vimms/Chemicals.py
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 | |
__init__(formula, isotopes, adducts, rt, max_intensity, chromatogram, children=None, include_adducts_isotopes=True, total_proportion=0.99, database_accession=None, base_chemical=None)
Initialises a Known chemical object
| Parameters: |
|
|---|
Source code in vimms/Chemicals.py
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 | |
MSN
Bases: BaseChemical
A chemical that represents an MS2+ fragment.
Source code in vimms/Chemicals.py
585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
__init__(mz, ms_level, prop_ms2_mass, parent_mass_prop, children=None, parent=None)
Initialises an MSN object
| Parameters: |
|
|---|
Source code in vimms/Chemicals.py
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 | |
MultipleMixtureCreator
A class to create a list of known chemical objects in multiple samples (mixtures)
Source code in vimms/Chemicals.py
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 766 767 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 | |
__init__(master_chemical_list, group_list, group_dict, intensity_noise=GaussianPeakNoise(sigma=0.001, log_space=True), overall_missing_probability=0.0)
Create a chemical mixture creator. example
| Parameters: |
|
|---|
Source code in vimms/Chemicals.py
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 766 767 768 769 770 771 772 773 | |
generate_chemical_lists()
Generates list of chemicals across mixtures (samples)
Returns: the list of chemicals across mixtures (samples)
Source code in vimms/Chemicals.py
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 | |
UnknownChemical
Bases: Chemical
A Chemical representation from an unknown chemical formula. Unknown chemicals are typically created by extracting Regions-of-Interest from an existing mzML file.
Source code in vimms/Chemicals.py
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 | |
__init__(mz, rt, max_intensity, chromatogram, children=None, base_chemical=None)
Initialises an UnknownChemical object.
| Parameters: |
|
|---|
Source code in vimms/Chemicals.py
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
get_pooled_sample(dataset_list)
Takes a list of datasets and creates a pooled dataset from them
| Parameters: |
|
|---|
Returns: combined list where the datasets have been pooled
Source code in vimms/Chemicals.py
918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 | |