From cb204a05f612870a06e953510703b0bab067fb06 Mon Sep 17 00:00:00 2001 From: ivan-aksamentov Date: Mon, 3 Oct 2022 18:43:24 +0200 Subject: [PATCH 1/3] feat: calculate composite fitness --- packages_rs/nextclade/src/analyze/phenotype.rs | 18 ++++++++++++++++-- .../nextclade/src/run/nextclade_run_one.rs | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/packages_rs/nextclade/src/analyze/phenotype.rs b/packages_rs/nextclade/src/analyze/phenotype.rs index ad525c328..e6068dc32 100644 --- a/packages_rs/nextclade/src/analyze/phenotype.rs +++ b/packages_rs/nextclade/src/analyze/phenotype.rs @@ -28,7 +28,7 @@ pub fn calculate_phenotype(phenotype_data: &PhenotypeData, aa_substitutions: &[A } pub fn get_phenotype_attr_descs(virus_properties: &VirusProperties) -> Vec { - virus_properties + let mut descs = virus_properties .phenotype_data .as_ref() .map_or(vec![], |phenotype_data| { @@ -40,7 +40,21 @@ pub fn get_phenotype_attr_descs(virus_properties: &VirusProperties) -> Vec Vec { diff --git a/packages_rs/nextclade/src/run/nextclade_run_one.rs b/packages_rs/nextclade/src/run/nextclade_run_one.rs index 181df9dda..89efaccf7 100644 --- a/packages_rs/nextclade/src/run/nextclade_run_one.rs +++ b/packages_rs/nextclade/src/run/nextclade_run_one.rs @@ -155,7 +155,7 @@ pub fn nextclade_run_one( let total_covered_nucs = total_aligned_nucs - total_missing - total_non_acgtns; let coverage = total_covered_nucs as f64 / ref_seq.len() as f64; - let phenotype_values = virus_properties.phenotype_data.as_ref().map(|phenotype_data| { + let mut phenotype_values = virus_properties.phenotype_data.as_ref().map(|phenotype_data| { phenotype_data .iter() .filter_map(|phenotype_data| { @@ -183,6 +183,20 @@ pub fn nextclade_run_one( .collect_vec() }); + if let Some(ref mut phenotype_values) = phenotype_values { + let binding = phenotype_values.iter().find(|ph| ph.name.contains("binding")); + let escape = phenotype_values.iter().find(|ph| ph.name.contains("escape")); + if let (Some(binding), Some(escape)) = (binding, escape) { + phenotype_values.push(PhenotypeValue { + name: "composite_fitness".to_owned(), + name_friendly: "Composite fitness".to_owned(), + description: "".to_owned(), + gene: binding.gene.clone(), + value: 1.2 * escape.value + 0.5 * binding.value, + }); + } + } + let qc = qc_run( &private_nuc_mutations, &nucleotide_composition, From 6018ac1bd73a745657695de69b57af79c6f2863d Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 3 Nov 2022 01:36:14 +0100 Subject: [PATCH 2/3] Reduce weight of affinity to 0.15, of RBD score to 1.0 --- packages_rs/nextclade/src/run/nextclade_run_one.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages_rs/nextclade/src/run/nextclade_run_one.rs b/packages_rs/nextclade/src/run/nextclade_run_one.rs index 89efaccf7..89b6fb747 100644 --- a/packages_rs/nextclade/src/run/nextclade_run_one.rs +++ b/packages_rs/nextclade/src/run/nextclade_run_one.rs @@ -175,8 +175,6 @@ pub fn nextclade_run_one( Some(PhenotypeValue { name: name.clone(), gene: gene.clone(), - name_friendly: name_friendly.clone(), - description: description.clone(), value: phenotype, }) }) @@ -192,7 +190,7 @@ pub fn nextclade_run_one( name_friendly: "Composite fitness".to_owned(), description: "".to_owned(), gene: binding.gene.clone(), - value: 1.2 * escape.value + 0.5 * binding.value, + value: 1.0 * escape.value + 0.15 * binding.value, }); } } From 8dfe7a74e90740d450579eaf792e6a4a1e31d5f0 Mon Sep 17 00:00:00 2001 From: Cornelius Roemer Date: Thu, 3 Nov 2022 02:10:27 +0100 Subject: [PATCH 3/3] Add name_friendly back --- packages_rs/nextclade/src/run/nextclade_run_one.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages_rs/nextclade/src/run/nextclade_run_one.rs b/packages_rs/nextclade/src/run/nextclade_run_one.rs index 89b6fb747..b85a545c2 100644 --- a/packages_rs/nextclade/src/run/nextclade_run_one.rs +++ b/packages_rs/nextclade/src/run/nextclade_run_one.rs @@ -175,6 +175,8 @@ pub fn nextclade_run_one( Some(PhenotypeValue { name: name.clone(), gene: gene.clone(), + name_friendly: name_friendly.clone(), + description: description.clone(), value: phenotype, }) })