Skip to content

Commit

Permalink
Comments based on review and start on AA trait
Browse files Browse the repository at this point in the history
  • Loading branch information
douweschulte committed Feb 5, 2025
1 parent aa455ca commit e9347b1
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
37 changes: 36 additions & 1 deletion rustyms/src/aminoacids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,44 @@ use crate::{
fragment::{Fragment, FragmentType, PeptidePosition},
model::*,
molecular_charge::CachedCharge,
Multi, MultiChemical, NeutralLoss, SequencePosition,
system::Mass,
MassMode, Multi, MultiChemical, NeutralLoss, SequencePosition,
};

use std::borrow::Cow;

// TODO: document
pub trait IsAminoAcid {
fn name(&self) -> Cow<'_, str>;
fn three_letter_code(&self) -> Option<Cow<'_, str>>;
#[doc(alias = "code")]
fn one_letter_code(&self) -> Option<char>;
fn pro_forma_definition(&self) -> Cow<'_, str>;
fn formulas(&self) -> Cow<'_, Multi<MolecularFormula>>;
fn monoisotopic_mass(&self) -> Cow<'_, Multi<Mass>> {
Cow::Owned(
self.formulas()
.iter()
.map(MolecularFormula::monoisotopic_mass)
.collect(),
)
}
fn average_weight(&self) -> Cow<'_, Multi<Mass>> {
Cow::Owned(
self.formulas()
.iter()
.map(MolecularFormula::average_weight)
.collect(),
)
}
fn mass(&self, mode: MassMode) -> Cow<'_, Multi<Mass>> {
Cow::Owned(self.formulas().iter().map(|f| f.mass(mode)).collect())
}
fn side_chain(&self) -> Cow<'_, Multi<MolecularFormula>>;
fn satellite_ion_fragments(&self) -> Option<Cow<'_, Multi<MolecularFormula>>>;
fn immonium_losses(&self) -> Cow<'_, [NeutralLoss]>;
}

include!("shared/aminoacid.rs");

impl AminoAcid {
Expand Down
4 changes: 0 additions & 4 deletions rustyms/src/modification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ impl Chemical for SimpleModificationInner {

impl SimpleModificationInner {
/// Get a url for more information on this modification. Only defined for modifications from ontologies.
#[expect(clippy::missing_panics_doc)]
pub fn ontology_url(&self) -> Option<String> {
match self {
Self::Mass(_) | Self::Formula(_) | Self::Glycan(_) | Self::GlycanStructure(_) => None,
Expand Down Expand Up @@ -593,9 +592,7 @@ impl Modification {
Self::Ambiguous { modification, .. } => modification.formula(),
}
}
}

impl Modification {
/// Check if this is a simple modification
pub const fn simple(&self) -> Option<&SimpleModification> {
match self {
Expand All @@ -613,7 +610,6 @@ impl Modification {
}

/// Get a url for more information on this modification. Only defined for modifications from ontologies.
#[expect(clippy::missing_panics_doc)]
pub fn ontology_url(&self) -> Option<String> {
match self {
Self::Simple(modification)
Expand Down
3 changes: 3 additions & 0 deletions rustyms/src/neutral_loss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use crate::{
include!("shared/neutral_loss.rs");

impl NeutralLoss {
// TODO: extend with full list from annotator, plus figure out a way to make them const
//const WATER_LOSS: Self = Self::Loss(molecular_formula!(H 2 O 1));

/// Check if this neutral loss if empty (has an empty molecular formula)
pub fn is_empty(&self) -> bool {
match self {
Expand Down
2 changes: 0 additions & 2 deletions rustyms/src/peptidoform/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ impl PeptidoformIon {
///
/// # Errors
/// It fails when the string is not a valid ProForma string. Or when the string has multiple peptidoforms.
#[expect(clippy::too_many_lines)]
pub fn pro_forma(
value: &str,
custom_database: Option<&CustomDatabase>,
Expand All @@ -96,7 +95,6 @@ impl CompoundPeptidoformIon {
///
/// # Errors
/// It fails when the string is not a valid ProForma string.
#[expect(clippy::too_many_lines)]
pub fn pro_forma(
value: &str,
custom_database: Option<&CustomDatabase>,
Expand Down
1 change: 1 addition & 0 deletions rustyms/src/shared/modification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub enum Modification {
},
}

// TODO: document what the usizes mean
/// Indicate the cross-link side
#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize)]
pub enum CrossLinkSide {
Expand Down

0 comments on commit e9347b1

Please sign in to comment.