Skip to content

Commit

Permalink
Small database cleanup and more output from de novo align
Browse files Browse the repository at this point in the history
  • Loading branch information
douweschulte committed Sep 19, 2024
1 parent 37e304b commit 5cbdc44
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
34 changes: 33 additions & 1 deletion examples/de-novo-align/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ fn main() {
),
("Protein".to_string(), db.id.clone()),
(
"Score".to_string(),
"Alignment score".to_string(),
alignment.normalised_score().to_string(),
),
("Start".to_string(), alignment.start_a().to_string()),
Expand All @@ -79,6 +79,38 @@ fn main() {
(alignment.start_a() + alignment.len_a()).to_string(),
),
("Path".to_string(), alignment.short()),
(
"Mass".to_string(),
peptide
.peptide()
.map_or(f64::NAN, |p| {
p.clone()
.into_unambiguous()
.map_or(f64::NAN, |p| p.formula().monoisotopic_mass().value)
})
.to_string(),
),
(
"Z".to_string(),
peptide.charge().map_or(0, |c| c.value).to_string(),
),
(
"Peptide length".to_string(),
peptide.peptide().map_or(0, |p| p.len()).to_string(),
),
(
"Scan".to_string(),
peptide
.scan_indices()
.map_or(String::new(), |s| s.into_iter().join(",")),
),
(
"Retention time".to_string(),
peptide
.retention_time()
.map_or(f64::NAN, |t| t.value)
.to_string(),
),
])
})
.collect();
Expand Down
6 changes: 6 additions & 0 deletions rustyms/src/build/ontology_modification.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use itertools::Itertools;
use ordered_float::OrderedFloat;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -47,6 +48,11 @@ impl OntologyModification {
{
let mut new = Vec::new();
for rule in rules.iter() {
let rule = (
rule.0.clone(),
rule.1.iter().unique().sorted().cloned().collect(),
rule.2.iter().unique().sorted().cloned().collect(),
); // Remove duplicate neutral losses and diagnostic ions, and sort for a better guarantee of equality
if new.is_empty() {
new.push(rule.clone());
} else {
Expand Down

0 comments on commit 5cbdc44

Please sign in to comment.