Skip to content

Commit

Permalink
Updated rustyms and prepared for new version
Browse files Browse the repository at this point in the history
Signed-off-by: Douwe Schulte <[email protected]>
  • Loading branch information
douweschulte committed Mar 18, 2024
1 parent 7fef7d2 commit 5d93ab7
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 68 deletions.
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
with:
tagName: v__VERSION__
releaseName: 'Version __VERSION__'
Expand Down
4 changes: 3 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Douwe Schulte <[email protected]>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/snijderlab/annotator"
edition = "2021"
rust-version = "1.57"
rust-version = "1.70.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand All @@ -19,7 +19,7 @@ itertools = "0.12"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.6", features = ["shell-open", "dialog-open", "updater"] }
rustyms = { path = "../../rustyms/rustyms", default-features = false, features = [
rustyms = { version = "0.8.3", default-features = false, features = [
"identification",
"align",
] }
Expand Down
1 change: 0 additions & 1 deletion src-tauri/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::io::Write;
use std::{fs::File, io::BufWriter};
use tauri;

fn create_loss_modal(id: &str) -> String {
format!(
Expand Down
12 changes: 5 additions & 7 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async fn search_modification(text: &str, tolerance: f64) -> Result<String, Strin
.map(|(ontology, id, _, modification)| {
[
modification.to_string(),
format!("{}:{}", ontology.name(), id),
format!("<a onclick='document.getElementById(\"search-modification\").value=\"{0}:{1}\";document.getElementById(\"search-modification-button\").click()'>{0}:{1}</a>", ontology.name(), id),
display_mass(modification.formula().monoisotopic_mass()).to_string(),
format!(
"<span class='formula'>{}</span>",
Expand All @@ -284,21 +284,20 @@ async fn search_modification(text: &str, tolerance: f64) -> Result<String, Strin
.map(|(ontology, id, _, modification)| {
[
modification.to_string(),
format!("{}:{}", ontology.name(), id),
format!("<a onclick='document.getElementById(\"search-modification\").value=\"{0}:{1}\";document.getElementById(\"search-modification-button\").click()'>{0}:{1}</a>", ontology.name(), id),
]
})
.collect_vec(),
)
.to_string())
}
ModificationSearchResult::Glycan(_, modifications) => Ok(html_builder::HtmlElement::table(
Some(&["Name", "Id", "Structure"]),
Some(&["Name", "Structure"]),
&modifications
.iter()
.map(|(ontology, id, _, modification)| {
.map(|(_, _, _, modification)| {
[
modification.to_string(),
format!("{}:{}", ontology.name(), id),
format!("<a onclick='document.getElementById(\"search-modification\").value=\"{0}\";document.getElementById(\"search-modification-button\").click()'>{0}</a>", modification),
if let Modification::Gno(GnoComposition::Structure(structure), _) =
modification
{
Expand Down Expand Up @@ -408,7 +407,6 @@ fn spectrum_details(index: usize, state: ModifiableState) -> String {

#[tauri::command]
fn identified_peptide_details(index: usize, state: ModifiableState) -> String {
// TODO: show local confidence on the sequence (maybe as done in stitch before?)
state.lock().unwrap().peptides.get(index).map_or(
"Identified peptide index not valid".to_string(),
|peptide| peptide.to_html().to_string(),
Expand Down
56 changes: 1 addition & 55 deletions src-tauri/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,65 +670,11 @@ fn render_linear_peptide(
write!(output, "<span class='modification term'></span>").unwrap();
}
if let Some(charge_carriers) = &peptide.charge_carriers {
// TODO: When rustyms is updated use the display impl here
write!(output, "<span class='charge-carriers'>/",).unwrap();
write!(
output,
"{}",
charge_carriers
.charge_carriers
.iter()
.map(|c| c.0)
.sum::<isize>()
"<span class='charge-carriers'>/{charge_carriers}</span>",
)
.unwrap();
if !charge_carriers.charge_carriers.iter().all(|c| {
c.1 == MolecularFormula::new(&[(Element::H, None, 1), (Element::Electron, None, -1)])
.unwrap()
}) {
write!(output, "[").unwrap();
let mut first = true;
for (amount, formula) in &charge_carriers.charge_carriers {
if first {
first = false;
} else {
write!(output, ",").unwrap();
}
let electron_index = formula
.elements()
.iter()
.position(|el| el.0 == Element::Electron);
let charge = electron_index.map(|ei| match -formula.elements()[ei].2 {
1 => "+".to_string(),
-1 => "-".to_string(),
n => n.to_string(),
});
if let (Some(electron_index), Some(charge), 2) =
(electron_index, &charge, formula.elements().len())
{
let element_index = 1 - electron_index;
write!(
output,
"{}{}{}",
amount,
formula.elements()[element_index].0,
charge
)
.unwrap();
} else {
write!(
output,
"{}({}){}",
amount,
formula,
charge.unwrap_or_default()
)
.unwrap();
}
}
write!(output, "]").unwrap();
}
write!(output, "</span>").unwrap();
}
write!(output, "</div>").unwrap();
}
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"https://gist.github.com/douweschulte/4afc3cac1a8f12473b281ac4e255e636"
],
"dialog": true,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEUyRjQ4NDA2MEU5NkNGOUQKUldTZHo1WU9Cb1QwNG1URkMwdUNtL0xKVjczSUNXbTZRWUE2K2QzUk96U0xXcTFLVGtuSGp3QWcK"
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEJGQTVFRjQwREVERjBBRjkKUldUNUN0L2VRTytsdjhrSjRDY1ZWVlNCOFNYV292anozRXZyZDR0eC95c3FMRWtjdWM1MHpIczIK"
},
"windows": [
{
Expand Down

0 comments on commit 5d93ab7

Please sign in to comment.