Skip to content

Commit

Permalink
Add author_and_year to modification features
Browse files Browse the repository at this point in the history
  • Loading branch information
kimrutherford committed Sep 26, 2024
1 parent bbc161e commit 930295a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
37 changes: 29 additions & 8 deletions src/pombase/bio/protein_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use regex::Regex;


use crate::types::GeneUniquename;
use crate::data_types::{ProteinViewData, UniquenameGeneMap,
IdOntAnnotationDetailMap, DisplayUniquenameGenotypeMap,
UniquenameAlleleDetailsMap, AlleleShort,
ProteinViewFeature, ProteinViewTrack,
UniquenameTranscriptMap, GeneDetails,
TermIdDetailsMap, AlleleDetails, ProteinDetails,
ProteinViewFeaturePos, TermNameAndId, ExtPart, ExtRange};
use crate::data_types::{AlleleDetails, AlleleShort, DisplayUniquenameGenotypeMap,
ExtPart, ExtRange, GeneDetails, IdOntAnnotationDetailMap,
ProteinDetails, ProteinViewData, ProteinViewFeature,
ProteinViewFeaturePos, ProteinViewTrack, TermIdDetailsMap,
TermNameAndId, UniquenameAlleleDetailsMap, UniquenameGeneMap,
UniquenameReferenceMap, UniquenameTranscriptMap};
use crate::web::config::{Config, CvConfig};

use flexstr::{shared_str as flex_str, SharedStr as FlexStr, shared_fmt as flex_fmt};
Expand Down Expand Up @@ -146,6 +145,7 @@ fn feature_from_allele(allele_details: &AlleleDetails, seq_length: usize)
feature_group: None,
display_extension: BTreeSet::new(),
assigned_by: None,
author_and_year: None,
evidence: None,
positions,
})
Expand Down Expand Up @@ -176,6 +176,7 @@ fn make_mutant_summary(mutants_track: &ProteinViewTrack) -> ProteinViewTrack {
feature_group: None,
display_extension: BTreeSet::new(),
assigned_by: None,
author_and_year: None,
evidence: None,
positions: vec![(residue_and_pos, pos, pos)],
}
Expand Down Expand Up @@ -373,6 +374,7 @@ fn make_modification_track(gene_details: &GeneDetails,
config: &Config,
gene_details_maps: &UniquenameGeneMap,
term_details_map: &TermIdDetailsMap,
references_map: &UniquenameReferenceMap,
annotation_details_map: &IdOntAnnotationDetailMap) -> ProteinViewTrack {
let ext_rel_types = &config.protein_feature_view.modification_extension_rel_types;

Expand All @@ -393,6 +395,20 @@ fn make_modification_track(gene_details: &GeneDetails,
.unwrap_or_else(|| panic!("can't find annotation {}", annotation_id));

let assigned_by = &annotation_detail.assigned_by;
let mut author_and_year = None;

if let Some(ref reference_uniquename) = annotation_detail.reference {
if let Some(ref ref_details) = references_map.get(reference_uniquename) {
if let Some(ref authors_abbrev) = ref_details.authors_abbrev {
if let Some(ref year) = ref_details.publication_year {
author_and_year = Some(flex_fmt!("{} ({})", authors_abbrev, year));
} else {
author_and_year = Some(authors_abbrev.clone());
}
}
}
}

let evidence = &annotation_detail.evidence;

let mut annotation_residues = vec![];
Expand Down Expand Up @@ -459,6 +475,7 @@ fn make_modification_track(gene_details: &GeneDetails,
feature_group,
display_extension: BTreeSet::new(),
assigned_by: assigned_by.clone(),
author_and_year: author_and_year.clone(),
evidence: evidence.clone(),
positions: vec![(description, residue_pos, residue_pos)],
}
Expand Down Expand Up @@ -513,6 +530,7 @@ fn make_pfam_track(gene_details: &GeneDetails) -> ProteinViewTrack {
feature_group: None,
assigned_by: Some(flex_str!["InterPro"]),
evidence: None,
author_and_year: None,
display_extension: BTreeSet::new(),

positions,
Expand Down Expand Up @@ -551,6 +569,7 @@ fn make_generic_track(track_name: FlexStr, feature_coords: &Vec<(usize, usize)>,
feature_group: None,
display_extension: BTreeSet::new(),
assigned_by: None,
author_and_year: None,
evidence: None,
positions,
}
Expand Down Expand Up @@ -580,6 +599,7 @@ fn make_binding_sites_track(gene_details: &GeneDetails) -> ProteinViewTrack {
feature_group: None,
display_extension: BTreeSet::new(),
assigned_by: None,
author_and_year: None,
evidence: None,
positions: vec![(feature_name.clone(), start, end)],
}
Expand Down Expand Up @@ -621,6 +641,7 @@ pub fn make_protein_view_data_map(gene_details_maps: &UniquenameGeneMap,
genotypes: &DisplayUniquenameGenotypeMap,
alleles: &UniquenameAlleleDetailsMap,
transcripts: &UniquenameTranscriptMap,
references: &UniquenameReferenceMap,
config: &Config)
-> HashMap<GeneUniquename, ProteinViewData>
{
Expand Down Expand Up @@ -670,7 +691,7 @@ pub fn make_protein_view_data_map(gene_details_maps: &UniquenameGeneMap,

let modification_track =
make_modification_track(gene_details, config, gene_details_maps, term_details_map,
annotation_details_map);
references, annotation_details_map);

let pfam_track = make_pfam_track(gene_details);

Expand Down
3 changes: 3 additions & 0 deletions src/pombase/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2479,6 +2479,9 @@ pub struct ProteinViewFeature {
#[serde(skip_serializing_if="Option::is_none")]
pub assigned_by: Option<AssignedBy>,

#[serde(skip_serializing_if="Option::is_none")]
pub author_and_year: Option<FlexStr>,

#[serde(skip_serializing_if="Option::is_none")]
pub evidence: Option<Evidence>,

Expand Down
3 changes: 2 additions & 1 deletion src/pombase/web/data_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5404,7 +5404,8 @@ phenotypes, so just the first part of this extension will be used:
&self.terms,
&self.annotation_details,
&self.genotypes, &self.alleles,
&self.transcripts, &self.config);
&self.transcripts, &self.references,
&self.config);

let gocam_data_by_gene = make_gocam_data_by_gene(&self.genes);
let gocam_data_by_gocam_id = make_gocam_data_by_id(&self.genes, &self.terms);
Expand Down

0 comments on commit 930295a

Please sign in to comment.