Struct rustyms::LinearPeptide
source · pub struct LinearPeptide {
pub labile: Vec<Modification>,
pub n_term: Option<Modification>,
pub c_term: Option<Modification>,
pub sequence: Vec<SequenceElement>,
pub ambiguous_modifications: Vec<Vec<usize>>,
pub charge_carriers: Option<MolecularCharge>,
/* private fields */
}
Expand description
A peptide with all data as provided by pro forma. Preferably generated by using the crate::ComplexPeptide::pro_forma
function.
Fields§
§labile: Vec<Modification>
Labile modifications, which will not be found in the actual spectrum.
n_term: Option<Modification>
N terminal modification
c_term: Option<Modification>
C terminal modification
sequence: Vec<SequenceElement>
The sequence of this peptide (includes local modifications)
ambiguous_modifications: Vec<Vec<usize>>
For each ambiguous modification list all possible positions it can be placed on. Indexed by the ambiguous modification id.
charge_carriers: Option<MolecularCharge>
The adduct ions, if specified
Implementations§
source§impl LinearPeptide
impl LinearPeptide
Builder style methods to create a LinearPeptide
sourcepub fn new(sequence: impl IntoIterator<Item = SequenceElement>) -> Self
pub fn new(sequence: impl IntoIterator<Item = SequenceElement>) -> Self
Create a new LinearPeptide
, if you want an empty peptide look at LinearPeptide::default
.
Potentially the .collect()
or .into()
methods can be useful as well.
sourcepub fn global(
self,
global: impl IntoIterator<Item = (Element, Option<u16>)>
) -> Option<Self>
pub fn global( self, global: impl IntoIterator<Item = (Element, Option<u16>)> ) -> Option<Self>
Add global isotope modifications, if any is invalid it returns None
sourcepub fn labile(self, labile: impl IntoIterator<Item = Modification>) -> Self
pub fn labile(self, labile: impl IntoIterator<Item = Modification>) -> Self
Add labile modifications
sourcepub fn n_term(self, term: Option<Modification>) -> Self
pub fn n_term(self, term: Option<Modification>) -> Self
Add the N terminal modification
sourcepub fn c_term(self, term: Option<Modification>) -> Self
pub fn c_term(self, term: Option<Modification>) -> Self
Add the C terminal modification
sourcepub fn charge_carriers(self, charge: Option<MolecularCharge>) -> Self
pub fn charge_carriers(self, charge: Option<MolecularCharge>) -> Self
Add the charge carriers
source§impl LinearPeptide
impl LinearPeptide
sourcepub fn pro_forma(value: &str) -> Result<Self, CustomError>
pub fn pro_forma(value: &str) -> Result<Self, CustomError>
Convenience wrapper to parse a linear peptide in pro forma notation, to handle all possible pro forma sequences look at ComplexPeptide::pro_forma
.
§Errors
It gives an error when the peptide is not correctly formatted. (Also see the ComplexPeptide
main function for this.)
It additionally gives an error if the peptide specified was multimeric (see ComplexPeptide::singular
).
sourcepub fn sloppy_pro_forma(
line: &str,
location: Range<usize>
) -> Result<Self, CustomError>
pub fn sloppy_pro_forma( line: &str, location: Range<usize> ) -> Result<Self, CustomError>
Read sloppy pro forma like sequences. Defined by the use of square or round braces to indicate modifications and missing any particular method of defining the N or C terminal modifications. Additionally any underscores will be ignored both on the ends and inside the sequence.
All modifications follow the same definitions as the strict pro forma syntax, if it cannot be
parsed as a strict pro forma modification it falls back to Modification::sloppy_modification
.
§Errors
If it does not fit the above description.
sourcepub fn get_n_term(&self) -> MolecularFormula
pub fn get_n_term(&self) -> MolecularFormula
The mass of the N terminal modifications. The global isotope modifications are NOT applied.
sourcepub fn get_c_term(&self) -> MolecularFormula
pub fn get_c_term(&self) -> MolecularFormula
The mass of the C terminal modifications. The global isotope modifications are NOT applied.
sourcepub fn get_global(&self) -> &[(Element, Option<u16>)]
pub fn get_global(&self) -> &[(Element, Option<u16>)]
Get the global isotope modifications
sourcepub fn assume_simple(&self)
pub fn assume_simple(&self)
Assume that the underlying peptide does not use fancy parts of the Pro Forma spec. This is the common lower bound for support in all functions of rustyms.
If you want to be even more strict on the kind of peptides you want to take take a look at Self::assume_very_simple
.
§Panics
When any of these functions are used:
- Labile modifications
- Global isotope modifications
- Charge carriers, use of charged ions apart from protons
- or when the sequence is empty.
sourcepub fn assume_very_simple(&self)
pub fn assume_very_simple(&self)
Assume that the underlying peptide does not use fancy parts of the Pro Forma spec.
§Panics
When any of these functions are used:
- Ambiguous modifications
- Labile modifications
- Global isotope modifications
- Ambiguous amino acids (B/Z)
- Ambiguous amino acid sequence
(?AA)
- Charge carriers, use of charged ions apart from protons
- or when the sequence is empty.
sourcepub fn bare_formulas(&self) -> Multi<MolecularFormula>
pub fn bare_formulas(&self) -> Multi<MolecularFormula>
Gives all the formulas for the whole peptide with no C and N terminal modifications. With the global isotope modifications applied.
sourcepub fn generate_theoretical_fragments(
&self,
max_charge: Charge,
model: &Model
) -> Vec<Fragment>
pub fn generate_theoretical_fragments( &self, max_charge: Charge, model: &Model ) -> Vec<Fragment>
Generate the theoretical fragments for this peptide, with the given maximal charge of the fragments, and the given model. With the global isotope modifications applied.
§Panics
If max_charge
outside the range 1..=u64::MAX
.
sourcepub fn sub_peptide(&self, index: impl RangeBounds<usize>) -> Self
pub fn sub_peptide(&self, index: impl RangeBounds<usize>) -> Self
Get a region of this peptide as a new peptide (with all terminal/global/ambiguous modifications).
Trait Implementations§
source§impl Clone for LinearPeptide
impl Clone for LinearPeptide
source§fn clone(&self) -> LinearPeptide
fn clone(&self) -> LinearPeptide
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for LinearPeptide
impl Debug for LinearPeptide
source§impl Default for LinearPeptide
impl Default for LinearPeptide
source§fn default() -> LinearPeptide
fn default() -> LinearPeptide
source§impl<'de> Deserialize<'de> for LinearPeptide
impl<'de> Deserialize<'de> for LinearPeptide
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for LinearPeptide
impl Display for LinearPeptide
source§impl<Collection, Item> From<Collection> for LinearPeptide
impl<Collection, Item> From<Collection> for LinearPeptide
source§impl<Item> FromIterator<Item> for LinearPeptidewhere
Item: Into<SequenceElement>,
impl<Item> FromIterator<Item> for LinearPeptidewhere
Item: Into<SequenceElement>,
source§fn from_iter<T: IntoIterator<Item = Item>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Item>>(iter: T) -> Self
source§impl Hash for LinearPeptide
impl Hash for LinearPeptide
source§impl<I: SliceIndex<[SequenceElement]>> Index<I> for LinearPeptide
impl<I: SliceIndex<[SequenceElement]>> Index<I> for LinearPeptide
§type Output = <I as SliceIndex<[SequenceElement]>>::Output
type Output = <I as SliceIndex<[SequenceElement]>>::Output
source§impl MultiChemical for LinearPeptide
impl MultiChemical for LinearPeptide
source§fn formulas(&self) -> Multi<MolecularFormula>
fn formulas(&self) -> Multi<MolecularFormula>
Gives the formulas for the whole peptide. With the global isotope modifications applied. (Any B/Z will result in multiple possible formulas.)
source§impl Ord for LinearPeptide
impl Ord for LinearPeptide
source§fn cmp(&self, other: &LinearPeptide) -> Ordering
fn cmp(&self, other: &LinearPeptide) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for LinearPeptide
impl PartialEq for LinearPeptide
source§fn eq(&self, other: &LinearPeptide) -> bool
fn eq(&self, other: &LinearPeptide) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for LinearPeptide
impl PartialOrd for LinearPeptide
source§fn partial_cmp(&self, other: &LinearPeptide) -> Option<Ordering>
fn partial_cmp(&self, other: &LinearPeptide) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more