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,