Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rustyms/src/align/mass_alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ fn calculate_masses<const STEPS: u16>(
.iter()
.map(|p| {
p.formulas_all(
&[sequence],
&[],
&[],
&mut Vec::new(),
false,
Expand Down
29 changes: 29 additions & 0 deletions rustyms/src/aminoacid/aminoacid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,35 @@ impl AminoAcid {
Self::Valine,
];

/// All amino acids (including I/L/J/B/Z but excluding X)
pub const ALL_AMINO_ACIDS: &'static [Self] = &[
Self::Alanine,
Self::AmbiguousAsparagine,
Self::AmbiguousGlutamine,
Self::AmbiguousLeucine,
Self::Arginine,
Self::Asparagine,
Self::AsparticAcid,
Self::Cysteine,
Self::GlutamicAcid,
Self::Glutamine,
Self::Glycine,
Self::Histidine,
Self::Isoleucine,
Self::Leucine,
Self::Lysine,
Self::Methionine,
Self::Phenylalanine,
Self::Proline,
Self::Pyrrolysine,
Self::Selenocysteine,
Self::Serine,
Self::Threonine,
Self::Tryptophan,
Self::Tyrosine,
Self::Valine,
];

// TODO: generalise over used storage type, so using molecularformula, monoisotopic mass, or average mass, also make sure that AAs can return these numbers in a const fashion
#[expect(clippy::too_many_lines, clippy::too_many_arguments)]
pub(crate) fn fragments(
Expand Down
18 changes: 11 additions & 7 deletions rustyms/src/peptidoform/peptidoform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,7 @@ impl<Complexity> Peptidoform<Complexity> {
if let Modification::Ambiguous { .. } = f {
acc
} else {
let attachment = all_peptides[peptidoform_index]
.sequence
.first()
.map(|s| s.aminoacid.aminoacid());
let attachment = self.sequence.first().map(|s| s.aminoacid.aminoacid());
let (formula, specific, _seen) = f.formula_inner(
all_peptides,
visited_peptides,
Expand Down Expand Up @@ -1514,16 +1511,23 @@ impl<Complexity: AtMax<Linear>> Peptidoform<Complexity> {
}

/// Digest this sequence with the given protease and the given maximal number of missed cleavages.
pub fn digest(&self, protease: &Protease, max_missed_cleavages: usize) -> Vec<Self> {
pub fn digest(
&self,
protease: &Protease,
max_missed_cleavages: usize,
size_range: impl RangeBounds<usize>,
) -> Vec<Self> {
let mut sites = vec![0];
sites.extend_from_slice(&protease.match_locations(&self.sequence));
sites.push(self.len());

let mut result = Vec::new();

for (index, start) in sites.iter().enumerate() {
for end in sites.iter().skip(index).take(max_missed_cleavages + 1) {
result.push(self.sub_peptide((*start)..*end));
for end in sites.iter().skip(index + 1).take(max_missed_cleavages + 1) {
if size_range.contains(&(end - start)) {
result.push(self.sub_peptide((*start)..*end));
}
}
}
result
Expand Down
Loading