Configuration object
ms2ml.config
Provides a place to define the project's configuration.
Defines the constants that are used in the rest of the project.
Such as the masses of aminoacids, supported modifications, length of the encodings, maximum length supported, labels and order of the encoded ions ...
Attributes
Classes
ms2ml.config.Config
dataclass
General class to set and store the configuration of the project.
Ideally every project will make one AND ONLY ONE of these. The provided defaults are meant to be reasonable for most projects but can be changed as needed.
All annotation and endoding functionality should require one of this objects to work.
PARAMETER | DESCRIPTION |
---|---|
g_tolerances |
A tuple of floats, where each float is the tolerance of that corresponding ms level. For instance (10, 20) means that the tolerance for ms1 is 10, 20 for ms2.
TYPE:
|
g_tolerance_units |
A tuple of strings, that denote what tolerance unit to use for each ms level. For instance ("ppm", "Da") means that the tolerance for ms1 is in ppm, and for ms2 in Da.
TYPE:
|
g_isotopes |
TYPE:
|
peptide_length_range |
A tuple of ints, where the first int is the minimum length of peptides.
TYPE:
|
precursor_charges |
A tuple of ints, where each int is a possible precursor charge.
TYPE:
|
fragment_positions |
A tuple of ints, where each int is a possible fragment position.
TYPE:
|
ion_series |
A string of characters, where each character is a possible ion series. An example,a dn the default is ('by')
TYPE:
|
ion_charges |
A tuple of ints, where each int is a possible ion charge.
TYPE:
|
ion_neutral_losses |
TYPE:
|
ion_encoding_nesting |
TYPE:
|
ion_naming_convention |
TYPE:
|
mod_ambiguity_threshold |
TYPE:
|
mod_fixed_mods |
TYPE:
|
Examples:
>>> config = Config()
>>> config
Config(g_tolerances=(50, 50), ...)
>>> config.fragment_labels
['y1^1', 'y1^2', ... 'b30^2']
Attributes
g_tolerances: tuple[float, ...] = (50, 50)
class-attribute
g_tolerance_units: tuple[MassError, ...] = ('ppm', 'ppm')
class-attribute
g_isotopes: tuple[int, ...] = (0, 0)
class-attribute
peptide_length_range: tuple[int, int] = (5, 30)
class-attribute
peptide_mz_range: tuple[float, float] = (200, 20000)
class-attribute
precursor_charges: tuple[int, ...] = (1, 2, 3, 4, 5, 6)
class-attribute
fragment_positions: tuple[int, ...] = tuple(range(1, 31))
class-attribute
ion_series: str = 'yb'
class-attribute
ion_charges: tuple[int, ...] = (1, 2)
class-attribute
ion_neutral_losses: tuple[str, ...] = ()
class-attribute
ion_encoding_nesting: tuple[str, ...] = ('ion_charges', 'fragment_positions', 'ion_series')
class-attribute
ion_naming_convention: str = '{ion_series}{fragment_positions}^{ion_charges}'
class-attribute
mod_mode: ModModes = 'unimod'
class-attribute
mod_ambiguity_threshold: float = 0.99
class-attribute
mod_fixed_mods: tuple[str] = ('[UNIMOD:4]@C')
class-attribute
mod_variable_mods: dict[str, tuple[str]] = field(default_factory=_default_var_mods)
class-attribute
encoding_aa_order: tuple[str] = tuple(['n_term'] + list(string.ascii_uppercase) + ['c_term', '__missing__'])
class-attribute
encoding_mod_order: tuple[str | None, ...] = field(default_factory=_default_mod_order)
class-attribute
encoding_mod_alias: dict[str, str] = field(default_factory=_default_mod_aliases)
class-attribute
encoding_spec_bin_start: float = field(repr=False, default=0.0)
class-attribute
encoding_spec_bin_end: float = field(repr=False, default=2000.0)
class-attribute
encoding_spec_bin_binsize: float | None = field(repr=False, default=0.1)
class-attribute
encoding_spec_bin_n_bins: int | None = field(repr=False, default=None)
class-attribute
encoding_spec_bin_relative: bool = field(repr=False, default=False)
class-attribute
encoding_spec_bin_offset: float = field(repr=False, default=0.0)
class-attribute
num_fragment_embeddings: int
property
Functions
fragment_labels() -> list[str]
ion_labeller(ion: AnnotatedIon) -> str
aa_masses()
mod_masses()
encoding_mod_order_mapping() -> dict[str | None, int]
encoding_aa_order_mapping() -> dict[str | None, int]
asdict()
Returns a dictionary representation of the config.
to_toml(path: str)
Writes the config to a toml file.
from_toml(path: str)
staticmethod
Loads a config from a toml file.
from_comet(path: str, *args, **kwargs)
Loads a config from a comet params file.
ms2ml.config.ConfigNotSetError
Bases: Exception
Raised when a config is not set but is required.