Skip to main content

mzdata_meta/
activation.rs

1use std::fmt::Display;
2
3crate::cvmap! {
4    #[flag_type=i32]
5    #[allow(unused)]
6    #[doc = "A method used for dissociation or fragmentation."]
7    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
8    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9    /*[[[cog
10    import cog
11    import subprocess
12    buf = subprocess.check_output(['python', 'cv/extract_activation.py']).decode('utf8')
13    for line in buf.splitlines():
14        cog.outl(line)
15    ]]]*/
16    pub enum DissociationMethodTerm {
17        #[term(cv=MS, accession=1000044, name="dissociation method", flags={0}, parents={[]})]
18        #[doc = "dissociation method - Fragmentation method used for dissociation or fragmentation."]
19        DissociationMethod,
20        #[term(cv=MS, accession=1000133, name="collision-induced dissociation", flags={0}, parents={["MS:1000044"]})]
21        #[doc = "collision-induced dissociation - The dissociation of an ion after collisional excitation. The term collisional-activated dissociation is not recommended."]
22        CollisionInducedDissociation,
23        #[term(cv=MS, accession=1000134, name="plasma desorption", flags={0}, parents={["MS:1000044"]})]
24        #[doc = "plasma desorption - The ionization of material in a solid sample by bombarding it with ionic or neutral atoms formed as a result of the fission of a suitable nuclide, typically 252Cf. Synonymous with fission fragment ionization."]
25        PlasmaDesorption,
26        #[term(cv=MS, accession=1000135, name="post-source decay", flags={0}, parents={["MS:1000044"]})]
27        #[doc = "post-source decay - A technique specific to reflectron time-of-flight mass spectrometers where product ions of metastable transitions or collision-induced dissociations generated in the drift tube prior to entering the reflectron are m/z separated to yield product ion spectra."]
28        PostSourceDecay,
29        #[term(cv=MS, accession=1000136, name="surface-induced dissociation", flags={0}, parents={["MS:1000044"]})]
30        #[doc = "surface-induced dissociation - Fragmentation that results from the collision of an ion with a surface."]
31        SurfaceInducedDissociation,
32        #[term(cv=MS, accession=1000242, name="blackbody infrared radiative dissociation", flags={0}, parents={["MS:1000044"]})]
33        #[doc = "blackbody infrared radiative dissociation - A special case of infrared multiphoton dissociation wherein excitation of the reactant ion is caused by absorption of infrared photons radiating from heated blackbody surroundings, which are usually the walls of a vacuum chamber. See also infrared multiphoton dissociation."]
34        BlackbodyInfraredRadiativeDissociation,
35        #[term(cv=MS, accession=1000250, name="electron capture dissociation", flags={0}, parents={["MS:1000044"]})]
36        #[doc = "electron capture dissociation - A process in which a multiply protonated molecules interacts with a low energy electrons. Capture of the electron leads the liberation of energy and a reduction in charge state of the ion with the production of the (M + nH) (n-1)+ odd electron ion, which readily fragments."]
37        ElectronCaptureDissociation,
38        #[term(cv=MS, accession=1000262, name="infrared multiphoton dissociation", flags={0}, parents={["MS:1000435"]})]
39        #[doc = "infrared multiphoton dissociation - Multiphoton ionization where the reactant ion dissociates as a result of the absorption of multiple infrared photons."]
40        InfraredMultiphotonDissociation,
41        #[term(cv=MS, accession=1000282, name="sustained off-resonance irradiation", flags={0}, parents={["MS:1000044"]})]
42        #[doc = "sustained off-resonance irradiation - A technique associated with Fourier transform ion cyclotron resonance (FT-ICR) mass spectrometry to carry out ion/neutral reactions such as low-energy collision-induced dissociation. A radio-frequency electric field of slightly off-resonance to the cyclotron frequency of the reactant ion cyclically accelerates and decelerates the reactant ion that is confined in the Penning ion trap. The ion's orbit does not exceed the dimensions of ion trap while the ion undergoes an ion/neutral species process that produces a high average translational energy for an extended time."]
43        SustainedOffResonanceIrradiation,
44        #[term(cv=MS, accession=1000422, name="beam-type collision-induced dissociation", flags={0}, parents={["MS:1000133"]})]
45        #[doc = "beam-type collision-induced dissociation - A collision-induced dissociation process that occurs in a beam-type collision cell."]
46        BeamTypeCollisionInducedDissociation,
47        #[term(cv=MS, accession=1000433, name="low-energy collision-induced dissociation", flags={0}, parents={["MS:1000044"]})]
48        #[doc = "low-energy collision-induced dissociation - A collision-induced dissociation process wherein the precursor ion has the translational energy lower than approximately 1000 eV. This process typically requires multiple collisions and the collisional excitation is cumulative."]
49        LowEnergyCollisionInducedDissociation,
50        #[term(cv=MS, accession=1000435, name="photodissociation", flags={0}, parents={["MS:1000044"]})]
51        #[doc = "photodissociation - A process wherein the reactant ion is dissociated as a result of absorption of one or more photons."]
52        Photodissociation,
53        #[term(cv=MS, accession=1000598, name="electron transfer dissociation", flags={0}, parents={["MS:1000044"]})]
54        #[doc = "electron transfer dissociation - A process to fragment ions in a mass spectrometer by inducing fragmentation of cations (e.g. peptides or proteins) by transferring electrons from radical-anions."]
55        ElectronTransferDissociation,
56        #[term(cv=MS, accession=1000599, name="pulsed q dissociation", flags={0}, parents={["MS:1000044"]})]
57        #[doc = "pulsed q dissociation - A process that involves precursor ion activation at high Q, a time delay to allow the precursor to fragment, then a rapid pulse to low Q where all fragment ions are trapped. The product ions can then be scanned out of the ion trap and detected."]
58        PulsedQDissociation,
59        #[term(cv=MS, accession=1001880, name="in-source collision-induced dissociation", flags={0}, parents={["MS:1000044"]})]
60        #[doc = "in-source collision-induced dissociation - The dissociation of an ion as a result of collisional excitation during ion transfer from an atmospheric pressure ion source and the mass spectrometer vacuum."]
61        InSourceCollisionInducedDissociation,
62        #[term(cv=MS, accession=1002000, name="LIFT", flags={0}, parents={["MS:1000044"]})]
63        #[doc = "LIFT - A Bruker's proprietary technique where molecular ions are initially accelerated at lower energy, then collide with inert gas in a collision cell that is then 'lifted' to high potential. The use of inert gas is optional, as it could lift also fragments provided by LID."]
64        LIFT,
65        #[term(cv=MS, accession=1002472, name="trap-type collision-induced dissociation", flags={0}, parents={["MS:1000133"]})]
66        #[doc = "trap-type collision-induced dissociation - A collision-induced dissociation process that occurs in a trap-type collision cell."]
67        TrapTypeCollisionInducedDissociation,
68        #[term(cv=MS, accession=1002481, name="higher energy beam-type collision-induced dissociation", flags={0}, parents={["MS:1000422"]})]
69        #[doc = "higher energy beam-type collision-induced dissociation - A collision-induced dissociation process wherein the projectile ion has the translational energy higher than approximately 1000 eV."]
70        HigherEnergyBeamTypeCollisionInducedDissociation,
71        #[term(cv=MS, accession=1002678, name="supplemental beam-type collision-induced dissociation", flags={0}, parents={["MS:1000422"]})]
72        #[doc = "supplemental beam-type collision-induced dissociation - A supplemental collision-induced dissociation process that occurs in a beam-type collision cell in addition to another primary type of dissociation."]
73        SupplementalBeamTypeCollisionInducedDissociation,
74        #[term(cv=MS, accession=1002679, name="supplemental collision-induced dissociation", flags={0}, parents={["MS:1000133"]})]
75        #[doc = "supplemental collision-induced dissociation - The dissociation of an ion after supplemental collisional excitation."]
76        SupplementalCollisionInducedDissociation,
77        #[term(cv=MS, accession=1003246, name="ultraviolet photodissociation", flags={0}, parents={["MS:1000435"]})]
78        #[doc = "ultraviolet photodissociation - Multiphoton ionization where the reactant ion dissociates as a result of the absorption of multiple UV photons."]
79        UltravioletPhotodissociation,
80        #[term(cv=MS, accession=1003247, name="negative electron transfer dissociation", flags={0}, parents={["MS:1000044"]})]
81        #[doc = "negative electron transfer dissociation - A process to fragment ions in a mass spectrometer by inducing fragmentation of anions (e.g. peptides or proteins) by transferring electrons to a radical-cation."]
82        NegativeElectronTransferDissociation,
83        #[term(cv=MS, accession=1003294, name="electron activated dissociation", flags={0}, parents={["MS:1000250"]})]
84        #[doc = "electron activated dissociation - A process to fragment ions in a high intensity electron beam which results in a dissociation of various analytes ranging from singly charged small molecules to multiply protonated proteins."]
85        ElectronActivatedDissociation,
86    }
87    //[[[end]]] (sum: wPbHz8tdQw)
88}
89
90impl DissociationMethodTerm {
91
92    /// Test if the dissociation method is based upon the transfer of electrons to or from
93    /// a radical ion reagent
94    pub fn is_electronic(&self) -> bool {
95        matches!(self, Self::ElectronActivatedDissociation
96            | Self::ElectronCaptureDissociation
97            | Self::ElectronTransferDissociation
98            | Self::NegativeElectronTransferDissociation)
99    }
100
101    /// Test if the dissociation method is based upon a reaction following collision with a neutral gas
102    pub fn is_collisional(&self) -> bool {
103        matches!(self, Self::CollisionInducedDissociation
104            | Self::LowEnergyCollisionInducedDissociation
105            | Self::BeamTypeCollisionInducedDissociation
106            | Self::TrapTypeCollisionInducedDissociation
107            | Self::InSourceCollisionInducedDissociation
108            | Self::SupplementalBeamTypeCollisionInducedDissociation
109            | Self::SupplementalCollisionInducedDissociation
110            | Self::HigherEnergyBeamTypeCollisionInducedDissociation)
111    }
112}
113
114crate::cvmap! {
115    #[value_type=f32]
116    #[flag_type=i32]
117    #[doc = "Energy for an ion experiencing some form of dissociation"]
118    #[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
119    /*[[[cog
120    import cog
121    import subprocess
122    buf = subprocess.check_output(['python', 'cv/extract_energy.py']).decode('utf8')
123    for line in buf.splitlines():
124        cog.outl(line)
125    ]]]*/
126    pub enum DissociationEnergyTerm {
127        #[term(cv=MS, accession=1000045, name="collision energy", flags={0}, parents={["MS:1000510"]})]
128        #[doc = "collision energy - Energy for an ion experiencing collision with a stationary gas particle resulting in dissociation of the ion."]
129        CollisionEnergy(f32),
130        #[term(cv=MS, accession=1000138, name="normalized collision energy", flags={0}, parents={["MS:1000510"]})]
131        #[doc = "normalized collision energy - Instrument setting, expressed in percent, for adjusting collisional energies of ions in an effort to provide equivalent excitation of all ions."]
132        NormalizedCollisionEnergy(f32),
133        #[term(cv=MS, accession=1002013, name="collision energy ramp start", flags={0}, parents={["MS:1000045"]})]
134        #[doc = "collision energy ramp start - Collision energy at the start of the collision energy ramp."]
135        CollisionEnergyRampStart(f32),
136        #[term(cv=MS, accession=1002014, name="collision energy ramp end", flags={0}, parents={["MS:1000045"]})]
137        #[doc = "collision energy ramp end - Collision energy at the end of the collision energy ramp."]
138        CollisionEnergyRampEnd(f32),
139        #[term(cv=MS, accession=1002218, name="percent collision energy ramp start", flags={0}, parents={["MS:1000138"]})]
140        #[doc = "percent collision energy ramp start - Collision energy at the start of the collision energy ramp in percent, normalized to the mass of the ion."]
141        PercentCollisionEnergyRampStart(f32),
142        #[term(cv=MS, accession=1002219, name="percent collision energy ramp end", flags={0}, parents={["MS:1000138"]})]
143        #[doc = "percent collision energy ramp end - Collision energy at the end of the collision energy ramp in percent, normalized to the mass of the ion."]
144        PercentCollisionEnergyRampEnd(f32),
145        #[term(cv=MS, accession=1002680, name="supplemental collision energy", flags={0}, parents={["MS:1000510"]})]
146        #[doc = "supplemental collision energy - Energy for an ion experiencing supplemental collision with a stationary gas particle resulting in dissociation of the ion."]
147        SupplementalCollisionEnergy(f32),
148        #[term(cv=MS, accession=1003410, name="electron beam energy", flags={0}, parents={["MS:1000510"]})]
149        #[doc = "electron beam energy - The kinetic energy of the electron beam used in dissociation methods induced by a free electron beam, such as electron-capture dissociation (ECD), electron-detachment dissociation (EDD), and electron-activated dissociation (EAD)."]
150        ElectronBeamEnergy(f32),
151    }
152    //[[[end]]] (sum: JSWX/2BnuQ)
153}
154
155impl Display for DissociationEnergyTerm {
156    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
157        write!(f, "{:?}", self)
158    }
159}
160
161impl DissociationEnergyTerm {
162    /// Is the collision energy supplemental to another dissociation method?
163    pub const fn is_supplemental(&self) -> bool {
164        matches!(self, Self::SupplementalCollisionEnergy(_))
165    }
166
167    /// Is this the start of an energy ramp?
168    pub const fn is_ramp_start(&self) -> bool {
169        matches!(self, Self::CollisionEnergyRampStart(_) | Self::PercentCollisionEnergyRampStart(_))
170    }
171
172    /// Is this the end of an energy ramp?
173    pub const fn is_ramp_end(&self) -> bool {
174        matches!(self, Self::CollisionEnergyRampEnd(_) | Self::PercentCollisionEnergyRampEnd(_))
175    }
176
177    /// Get the scalar energy value for this term
178    pub const fn energy(&self) -> f32 {
179        *match self {
180            DissociationEnergyTerm::CollisionEnergy(x) => x,
181            DissociationEnergyTerm::NormalizedCollisionEnergy(x) => x,
182            DissociationEnergyTerm::CollisionEnergyRampStart(x) => x,
183            DissociationEnergyTerm::CollisionEnergyRampEnd(x) => x,
184            DissociationEnergyTerm::PercentCollisionEnergyRampStart(x) => x,
185            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(x) => x,
186            DissociationEnergyTerm::SupplementalCollisionEnergy(x) => x,
187            DissociationEnergyTerm::ElectronBeamEnergy(x) => x,
188        }
189    }
190
191    /// Get a mutable reference to the energy in the term
192    pub fn energy_mut(&mut self) -> &mut f32 {
193        match self {
194            DissociationEnergyTerm::CollisionEnergy(x) => x,
195            DissociationEnergyTerm::NormalizedCollisionEnergy(x) => x,
196            DissociationEnergyTerm::CollisionEnergyRampStart(x) => x,
197            DissociationEnergyTerm::CollisionEnergyRampEnd(x) => x,
198            DissociationEnergyTerm::PercentCollisionEnergyRampStart(x) => x,
199            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(x) => x,
200            DissociationEnergyTerm::SupplementalCollisionEnergy(x) => x,
201            DissociationEnergyTerm::ElectronBeamEnergy(x) => x,
202        }
203    }
204}
205
206/// A [`DissociationEnergyTerm`] can be treated as a reference to their energy value
207impl AsRef<f32> for DissociationEnergyTerm {
208    fn as_ref(&self) -> &f32 {
209        match self {
210            DissociationEnergyTerm::CollisionEnergy(x) => x,
211            DissociationEnergyTerm::NormalizedCollisionEnergy(x) => x,
212            DissociationEnergyTerm::CollisionEnergyRampStart(x) => x,
213            DissociationEnergyTerm::CollisionEnergyRampEnd(x) => x,
214            DissociationEnergyTerm::PercentCollisionEnergyRampStart(x) => x,
215            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(x) => x,
216            DissociationEnergyTerm::SupplementalCollisionEnergy(x) => x,
217            DissociationEnergyTerm::ElectronBeamEnergy(x) => x,
218        }
219    }
220}
221
222#[allow(unused)]
223#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
224pub enum DissociationEnergy {
225    Energy(DissociationEnergyTerm),
226    Ramp { start: DissociationEnergyTerm, end: DissociationEnergyTerm },
227    Combined { primary: DissociationEnergyTerm, supplementary: DissociationEnergyTerm}
228}
229
230#[cfg(test)]
231mod test {
232    use crate::params::{ControlledVocabulary, ParamCow, ValueRef, Param};
233
234    use super::*;
235
236    #[test]
237    fn test_categories() {
238        assert!(DissociationMethodTerm::CollisionInducedDissociation.is_collisional());
239        assert!(DissociationMethodTerm::BeamTypeCollisionInducedDissociation.is_collisional());
240        assert!(!DissociationMethodTerm::BeamTypeCollisionInducedDissociation.is_electronic());
241        assert!(!DissociationMethodTerm::ElectronTransferDissociation.is_collisional());
242        assert!(DissociationMethodTerm::ElectronTransferDissociation.is_electronic());
243
244        assert_eq!(DissociationEnergyTerm::CollisionEnergy(30.0).to_string(), "CollisionEnergy(30.0)");
245
246        assert!(!DissociationEnergyTerm::CollisionEnergy(30.0).is_ramp_end());
247        assert!(!DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).is_ramp_start());
248        assert!(*DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).as_ref() == 30.0);
249
250        let mut energies = [
251            DissociationEnergyTerm::CollisionEnergy(10.0),
252            DissociationEnergyTerm::NormalizedCollisionEnergy(10.0),
253            DissociationEnergyTerm::CollisionEnergyRampStart(10.0),
254            DissociationEnergyTerm::CollisionEnergyRampEnd(10.0),
255            DissociationEnergyTerm::PercentCollisionEnergyRampStart(10.0),
256            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(10.0),
257            DissociationEnergyTerm::SupplementalCollisionEnergy(10.0),
258            DissociationEnergyTerm::ElectronBeamEnergy(10.0),
259        ];
260        for e in energies.iter_mut() {
261            assert_eq!(e.energy(), 10.0);
262            assert_eq!(*e.energy_mut(), 10.0);
263            assert_eq!(*e.as_ref(), 10.0);
264        }
265    }
266
267    #[test]
268    fn test_meta() {
269        // #[term(cv=MS, accession=1000138, name="normalized collision energy", flags={0}, parents={["MS:1000510"]})]
270        // #[doc = "normalized collision energy - Instrument setting, expressed in percent, for adjusting collisional energies of ions in an effort to provide equivalent excitation of all ions."]
271        // NormalizedCollisionEnergy(f32),
272
273        assert_eq!(
274            DissociationEnergyTerm::from_accession(1000138, 0.0),
275            Some(DissociationEnergyTerm::NormalizedCollisionEnergy(0.0))
276        );
277
278        let mut param = DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).to_param();
279        param.value = 30.0.into();
280        assert_eq!(
281            DissociationEnergyTerm::from_param(&param),
282            Some(DissociationEnergyTerm::NormalizedCollisionEnergy(30.0))
283        );
284
285        let term: DissociationEnergyTerm = param.clone().into();
286        assert_eq!(
287            term,
288            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)
289        );
290
291        let p: Param = DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).into();
292        param.value = ValueRef::Empty;
293        assert_eq!(
294            p,
295            param
296        );
297
298        let p: Param = (&DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)).into();
299        assert_eq!(
300            p,
301            param
302        );
303
304        let p: ParamCow = DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).into();
305        assert_eq!(
306            p,
307            param
308        );
309
310        let p: ParamCow = (&DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)).into();
311        assert_eq!(
312            p,
313            param
314        );
315
316        param.value = 30.0.into();
317        let term: DissociationEnergyTerm = Param::from(param.clone()).into();
318        assert_eq!(
319            term,
320            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)
321        );
322
323        assert_eq!(
324            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).accession(),
325            1000138
326        );
327
328        assert_eq!(
329            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).parents(),
330            []
331        );
332
333        assert_eq!(
334            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).flags(),
335            0,
336        );
337
338        assert_eq!(
339            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).controlled_vocabulary(),
340            ControlledVocabulary::MS,
341        );
342
343        assert_eq!(
344            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).name(),
345            "normalized collision energy"
346        );
347
348        assert_eq!(
349            DissociationEnergyTerm::from_name("normalized collision energy"),
350            Some(DissociationEnergyTerm::NormalizedCollisionEnergy(Default::default()))
351        );
352    }
353}