Skip to content

Commit

Permalink
Added known misbehaving alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
douweschulte committed Sep 10, 2024
1 parent 292f7a4 commit 3298c20
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
34 changes: 34 additions & 0 deletions rustyms/src/align/bad_alignments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#![allow(clippy::missing_panics_doc)]

use crate::{
align::{align, matrix, AlignType},
LinearPeptide, SimpleLinear, Tolerance,
};

#[test]
fn overextended_rotation() {
test_alignment("IVQEVS", "LEVQVES", "1i1I2=2r1=");
}

fn test_alignment(peptide_one: &str, peptide_two: &str, path: &str) {
let first_peptide = LinearPeptide::pro_forma(peptide_one, None)
.unwrap()
.into_simple_linear()
.unwrap();
let second_peptide = LinearPeptide::pro_forma(peptide_two, None)
.unwrap()
.into_simple_linear()
.unwrap();
let alignment = align::<4, SimpleLinear, SimpleLinear>(
&first_peptide,
&second_peptide,
matrix::BLOSUM62,
Tolerance::new_ppm(10.0),
AlignType::GLOBAL,
);
assert_eq!(
alignment.short(),
path,
"Alignment of {peptide_one} vs {peptide_two} did not go to plan"
);
}
2 changes: 2 additions & 0 deletions rustyms/src/align/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

mod align_type;
mod alignment;
#[cfg(test)]
mod bad_alignments;
mod diagonal_array;
mod mass_alignment;
mod piece;
Expand Down
9 changes: 7 additions & 2 deletions rustyms/src/glycan/positioned_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ pub struct PositionedGlycanStructure {
}

impl Chemical for PositionedGlycanStructure {
fn formula_inner(&self, sequence_index: SequencePosition, peptide_index: usize) -> MolecularFormula {
fn formula_inner(
&self,
sequence_index: SequencePosition,
peptide_index: usize,
) -> MolecularFormula {
self.sugar.formula_inner(sequence_index, peptide_index)
+ self
.branches
Expand Down Expand Up @@ -72,7 +76,8 @@ impl PositionedGlycanStructure {
.flat_map(move |(f, bonds)| {
full_formula.iter().map(move |full| {
Fragment::new(
full - self.formula_inner(SequencePosition::default(), peptide_index)
full - self
.formula_inner(SequencePosition::default(), peptide_index)
+ f,
Charge::zero(),
peptidoform_index,
Expand Down

0 comments on commit 3298c20

Please sign in to comment.