Skip to main content

mzdata_meta/
activation.rs

1use std::fmt::Display;
2
3
4
5crate::cvmap! {
6    #[flag_type=i32]
7    #[allow(unused)]
8    #[doc = "A method used for dissociation or fragmentation."]
9    #[derive(Debug, Clone, Copy, PartialEq, Eq)]
10    #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11    /*[[[cog
12    import cog
13    import subprocess
14    buf = subprocess.check_output(['python', 'cv/extract_activation.py']).decode('utf8')
15    for line in buf.splitlines():
16        cog.outl(line)
17    ]]]*/
18    pub enum DissociationMethodTerm {
19        #[term(cv=MS, accession=1000044, name="dissociation method", flags={0}, parents={[]})]
20        #[doc = "dissociation method - Fragmentation method used for dissociation or fragmentation."]
21        DissociationMethod,
22        #[term(cv=MS, accession=1000133, name="collision-induced dissociation", flags={0}, parents={["MS:1000044"]})]
23        #[doc = "collision-induced dissociation - The dissociation of an ion after collisional excitation. The term collisional-activated dissociation is not recommended."]
24        CollisionInducedDissociation,
25        #[term(cv=MS, accession=1000134, name="plasma desorption", flags={0}, parents={["MS:1000044"]})]
26        #[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."]
27        PlasmaDesorption,
28        #[term(cv=MS, accession=1000135, name="post-source decay", flags={0}, parents={["MS:1000044"]})]
29        #[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."]
30        PostSourceDecay,
31        #[term(cv=MS, accession=1000136, name="surface-induced dissociation", flags={0}, parents={["MS:1000044"]})]
32        #[doc = "surface-induced dissociation - Fragmentation that results from the collision of an ion with a surface."]
33        SurfaceInducedDissociation,
34        #[term(cv=MS, accession=1000242, name="blackbody infrared radiative dissociation", flags={0}, parents={["MS:1000044"]})]
35        #[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."]
36        BlackbodyInfraredRadiativeDissociation,
37        #[term(cv=MS, accession=1000250, name="electron capture dissociation", flags={0}, parents={["MS:1000044"]})]
38        #[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."]
39        ElectronCaptureDissociation,
40        #[term(cv=MS, accession=1000262, name="infrared multiphoton dissociation", flags={0}, parents={["MS:1000435"]})]
41        #[doc = "infrared multiphoton dissociation - Multiphoton ionization where the reactant ion dissociates as a result of the absorption of multiple infrared photons."]
42        InfraredMultiphotonDissociation,
43        #[term(cv=MS, accession=1000282, name="sustained off-resonance irradiation", flags={0}, parents={["MS:1000044"]})]
44        #[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."]
45        SustainedOffResonanceIrradiation,
46        #[term(cv=MS, accession=1000422, name="beam-type collision-induced dissociation", flags={0}, parents={["MS:1000133"]})]
47        #[doc = "beam-type collision-induced dissociation - A collision-induced dissociation process that occurs in a beam-type collision cell."]
48        BeamTypeCollisionInducedDissociation,
49        #[term(cv=MS, accession=1000433, name="low-energy collision-induced dissociation", flags={0}, parents={["MS:1000044"]})]
50        #[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."]
51        LowEnergyCollisionInducedDissociation,
52        #[term(cv=MS, accession=1000435, name="photodissociation", flags={0}, parents={["MS:1000044"]})]
53        #[doc = "photodissociation - A process wherein the reactant ion is dissociated as a result of absorption of one or more photons."]
54        Photodissociation,
55        #[term(cv=MS, accession=1000598, name="electron transfer dissociation", flags={0}, parents={["MS:1000044"]})]
56        #[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."]
57        ElectronTransferDissociation,
58        #[term(cv=MS, accession=1000599, name="pulsed q dissociation", flags={0}, parents={["MS:1000044"]})]
59        #[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."]
60        PulsedQDissociation,
61        #[term(cv=MS, accession=1001880, name="in-source collision-induced dissociation", flags={0}, parents={["MS:1000044"]})]
62        #[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."]
63        InSourceCollisionInducedDissociation,
64        #[term(cv=MS, accession=1002000, name="LIFT", flags={0}, parents={["MS:1000044"]})]
65        #[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."]
66        LIFT,
67        #[term(cv=MS, accession=1002472, name="trap-type collision-induced dissociation", flags={0}, parents={["MS:1000133"]})]
68        #[doc = "trap-type collision-induced dissociation - A collision-induced dissociation process that occurs in a trap-type collision cell."]
69        TrapTypeCollisionInducedDissociation,
70        #[term(cv=MS, accession=1002481, name="higher energy beam-type collision-induced dissociation", flags={0}, parents={["MS:1000422"]})]
71        #[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."]
72        HigherEnergyBeamTypeCollisionInducedDissociation,
73        #[term(cv=MS, accession=1002678, name="supplemental beam-type collision-induced dissociation", flags={0}, parents={["MS:1000422"]})]
74        #[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."]
75        SupplementalBeamTypeCollisionInducedDissociation,
76        #[term(cv=MS, accession=1002679, name="supplemental collision-induced dissociation", flags={0}, parents={["MS:1000133"]})]
77        #[doc = "supplemental collision-induced dissociation - The dissociation of an ion after supplemental collisional excitation."]
78        SupplementalCollisionInducedDissociation,
79        #[term(cv=MS, accession=1003246, name="ultraviolet photodissociation", flags={0}, parents={["MS:1000435"]})]
80        #[doc = "ultraviolet photodissociation - Multiphoton ionization where the reactant ion dissociates as a result of the absorption of multiple UV photons."]
81        UltravioletPhotodissociation,
82        #[term(cv=MS, accession=1003247, name="negative electron transfer dissociation", flags={0}, parents={["MS:1000044"]})]
83        #[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."]
84        NegativeElectronTransferDissociation,
85        #[term(cv=MS, accession=1003294, name="electron activated dissociation", flags={0}, parents={["MS:1000250"]})]
86        #[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."]
87        ElectronActivatedDissociation,
88    }
89    //[[[end]]] (sum: wPbHz8tdQw)
90}
91
92impl DissociationMethodTerm {
93
94    pub fn is_electronic(&self) -> bool {
95        matches!(self, Self::ElectronActivatedDissociation
96            | Self::ElectronCaptureDissociation
97            | Self::ElectronTransferDissociation
98            | Self::NegativeElectronTransferDissociation)
99    }
100
101    pub fn is_collisional(&self) -> bool {
102        matches!(self, Self::CollisionInducedDissociation
103            | Self::LowEnergyCollisionInducedDissociation
104            | Self::BeamTypeCollisionInducedDissociation
105            | Self::TrapTypeCollisionInducedDissociation
106            | Self::InSourceCollisionInducedDissociation
107            | Self::SupplementalBeamTypeCollisionInducedDissociation
108            | Self::SupplementalCollisionInducedDissociation
109            | Self::HigherEnergyBeamTypeCollisionInducedDissociation)
110    }
111}
112
113crate::cvmap! {
114    #[value_type=f32]
115    #[flag_type=i32]
116    #[doc = "Energy for an ion experiencing some form of dissociation"]
117    #[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
118    /*[[[cog
119    import cog
120    import subprocess
121    buf = subprocess.check_output(['python', 'cv/extract_energy.py']).decode('utf8')
122    for line in buf.splitlines():
123        cog.outl(line)
124    ]]]*/
125    pub enum DissociationEnergyTerm {
126        #[term(cv=MS, accession=1000045, name="collision energy", flags={0}, parents={["MS:1000510"]})]
127        #[doc = "collision energy - Energy for an ion experiencing collision with a stationary gas particle resulting in dissociation of the ion."]
128        CollisionEnergy(f32),
129        #[term(cv=MS, accession=1000138, name="normalized collision energy", flags={0}, parents={["MS:1000510"]})]
130        #[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."]
131        NormalizedCollisionEnergy(f32),
132        #[term(cv=MS, accession=1002013, name="collision energy ramp start", flags={0}, parents={["MS:1000045"]})]
133        #[doc = "collision energy ramp start - Collision energy at the start of the collision energy ramp."]
134        CollisionEnergyRampStart(f32),
135        #[term(cv=MS, accession=1002014, name="collision energy ramp end", flags={0}, parents={["MS:1000045"]})]
136        #[doc = "collision energy ramp end - Collision energy at the end of the collision energy ramp."]
137        CollisionEnergyRampEnd(f32),
138        #[term(cv=MS, accession=1002218, name="percent collision energy ramp start", flags={0}, parents={["MS:1000138"]})]
139        #[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."]
140        PercentCollisionEnergyRampStart(f32),
141        #[term(cv=MS, accession=1002219, name="percent collision energy ramp end", flags={0}, parents={["MS:1000138"]})]
142        #[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."]
143        PercentCollisionEnergyRampEnd(f32),
144        #[term(cv=MS, accession=1002680, name="supplemental collision energy", flags={0}, parents={["MS:1000510"]})]
145        #[doc = "supplemental collision energy - Energy for an ion experiencing supplemental collision with a stationary gas particle resulting in dissociation of the ion."]
146        SupplementalCollisionEnergy(f32),
147        #[term(cv=MS, accession=1003410, name="electron beam energy", flags={0}, parents={["MS:1000510"]})]
148        #[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)."]
149        ElectronBeamEnergy(f32),
150    }
151    //[[[end]]] (sum: JSWX/2BnuQ)
152}
153
154impl Display for DissociationEnergyTerm {
155    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
156        write!(f, "{:?}", self)
157    }
158}
159
160impl DissociationEnergyTerm {
161    pub const fn is_supplemental(&self) -> bool {
162        matches!(self, Self::SupplementalCollisionEnergy(_))
163    }
164
165    pub const fn is_ramp_start(&self) -> bool {
166        matches!(self, Self::CollisionEnergyRampStart(_) | Self::PercentCollisionEnergyRampStart(_))
167    }
168
169    pub const fn is_ramp_end(&self) -> bool {
170        matches!(self, Self::CollisionEnergyRampEnd(_) | Self::PercentCollisionEnergyRampEnd(_))
171    }
172
173    pub const fn energy(&self) -> f32 {
174        *match self {
175            DissociationEnergyTerm::CollisionEnergy(x) => x,
176            DissociationEnergyTerm::NormalizedCollisionEnergy(x) => x,
177            DissociationEnergyTerm::CollisionEnergyRampStart(x) => x,
178            DissociationEnergyTerm::CollisionEnergyRampEnd(x) => x,
179            DissociationEnergyTerm::PercentCollisionEnergyRampStart(x) => x,
180            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(x) => x,
181            DissociationEnergyTerm::SupplementalCollisionEnergy(x) => x,
182            DissociationEnergyTerm::ElectronBeamEnergy(x) => x,
183        }
184    }
185
186    pub fn energy_mut(&mut self) -> &mut f32 {
187        match self {
188            DissociationEnergyTerm::CollisionEnergy(x) => x,
189            DissociationEnergyTerm::NormalizedCollisionEnergy(x) => x,
190            DissociationEnergyTerm::CollisionEnergyRampStart(x) => x,
191            DissociationEnergyTerm::CollisionEnergyRampEnd(x) => x,
192            DissociationEnergyTerm::PercentCollisionEnergyRampStart(x) => x,
193            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(x) => x,
194            DissociationEnergyTerm::SupplementalCollisionEnergy(x) => x,
195            DissociationEnergyTerm::ElectronBeamEnergy(x) => x,
196        }
197    }
198}
199
200impl AsRef<f32> for DissociationEnergyTerm {
201    fn as_ref(&self) -> &f32 {
202        match self {
203            DissociationEnergyTerm::CollisionEnergy(x) => x,
204            DissociationEnergyTerm::NormalizedCollisionEnergy(x) => x,
205            DissociationEnergyTerm::CollisionEnergyRampStart(x) => x,
206            DissociationEnergyTerm::CollisionEnergyRampEnd(x) => x,
207            DissociationEnergyTerm::PercentCollisionEnergyRampStart(x) => x,
208            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(x) => x,
209            DissociationEnergyTerm::SupplementalCollisionEnergy(x) => x,
210            DissociationEnergyTerm::ElectronBeamEnergy(x) => x,
211        }
212    }
213}
214
215#[allow(unused)]
216#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
217pub enum DissociationEnergy {
218    Energy(DissociationEnergyTerm),
219    Ramp { start: DissociationEnergyTerm, end: DissociationEnergyTerm },
220    Combined { primary: DissociationEnergyTerm, supplementary: DissociationEnergyTerm}
221}
222
223#[cfg(test)]
224mod test {
225    use crate::params::{ControlledVocabulary, ParamCow, ValueRef, Param};
226
227    use super::*;
228
229    #[test]
230    fn test_categories() {
231        assert!(DissociationMethodTerm::CollisionInducedDissociation.is_collisional());
232        assert!(DissociationMethodTerm::BeamTypeCollisionInducedDissociation.is_collisional());
233        assert!(!DissociationMethodTerm::BeamTypeCollisionInducedDissociation.is_electronic());
234        assert!(!DissociationMethodTerm::ElectronTransferDissociation.is_collisional());
235        assert!(DissociationMethodTerm::ElectronTransferDissociation.is_electronic());
236
237        assert_eq!(DissociationEnergyTerm::CollisionEnergy(30.0).to_string(), "CollisionEnergy(30.0)");
238
239        assert!(!DissociationEnergyTerm::CollisionEnergy(30.0).is_ramp_end());
240        assert!(!DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).is_ramp_start());
241        assert!(*DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).as_ref() == 30.0);
242
243        let mut energies = [
244            DissociationEnergyTerm::CollisionEnergy(10.0),
245            DissociationEnergyTerm::NormalizedCollisionEnergy(10.0),
246            DissociationEnergyTerm::CollisionEnergyRampStart(10.0),
247            DissociationEnergyTerm::CollisionEnergyRampEnd(10.0),
248            DissociationEnergyTerm::PercentCollisionEnergyRampStart(10.0),
249            DissociationEnergyTerm::PercentCollisionEnergyRampEnd(10.0),
250            DissociationEnergyTerm::SupplementalCollisionEnergy(10.0),
251            DissociationEnergyTerm::ElectronBeamEnergy(10.0),
252        ];
253        for e in energies.iter_mut() {
254            assert_eq!(e.energy(), 10.0);
255            assert_eq!(*e.energy_mut(), 10.0);
256            assert_eq!(*e.as_ref(), 10.0);
257        }
258    }
259
260    #[test]
261    fn test_meta() {
262        // #[term(cv=MS, accession=1000138, name="normalized collision energy", flags={0}, parents={["MS:1000510"]})]
263        // #[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."]
264        // NormalizedCollisionEnergy(f32),
265
266        assert_eq!(
267            DissociationEnergyTerm::from_accession(1000138, 0.0),
268            Some(DissociationEnergyTerm::NormalizedCollisionEnergy(0.0))
269        );
270
271        let mut param = DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).to_param();
272        param.value = 30.0.into();
273        assert_eq!(
274            DissociationEnergyTerm::from_param(&param),
275            Some(DissociationEnergyTerm::NormalizedCollisionEnergy(30.0))
276        );
277
278        let term: DissociationEnergyTerm = param.clone().into();
279        assert_eq!(
280            term,
281            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)
282        );
283
284        let p: Param = DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).into();
285        param.value = ValueRef::Empty;
286        assert_eq!(
287            p,
288            param
289        );
290
291        let p: Param = (&DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)).into();
292        assert_eq!(
293            p,
294            param
295        );
296
297        let p: ParamCow = DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).into();
298        assert_eq!(
299            p,
300            param
301        );
302
303        let p: ParamCow = (&DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)).into();
304        assert_eq!(
305            p,
306            param
307        );
308
309        param.value = 30.0.into();
310        let term: DissociationEnergyTerm = Param::from(param.clone()).into();
311        assert_eq!(
312            term,
313            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0)
314        );
315
316        assert_eq!(
317            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).accession(),
318            1000138
319        );
320
321        assert_eq!(
322            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).parents(),
323            []
324        );
325
326        assert_eq!(
327            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).flags(),
328            0,
329        );
330
331        assert_eq!(
332            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).controlled_vocabulary(),
333            ControlledVocabulary::MS,
334        );
335
336        assert_eq!(
337            DissociationEnergyTerm::NormalizedCollisionEnergy(30.0).name(),
338            "normalized collision energy"
339        );
340
341        assert_eq!(
342            DissociationEnergyTerm::from_name("normalized collision energy"),
343            Some(DissociationEnergyTerm::NormalizedCollisionEnergy(Default::default()))
344        );
345    }
346}