Skip to content

Commit

Permalink
Add ProteinViewType::DomainsAndFeatures scope
Browse files Browse the repository at this point in the history
  • Loading branch information
kimrutherford committed Oct 18, 2024
1 parent f47085e commit 70b15cc
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/bin/pombase-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ async fn get_term(Path(id): Path<String>, State(all_state): State<Arc<AllState>>
option_json_to_result(&id, res)
}

async fn get_protein_features(Path((full_or_widget, gene_uniquename)): Path<(String, String)>,
async fn get_protein_features(Path((scope, gene_uniquename)): Path<(String, String)>,
State(all_state): State<Arc<AllState>>)
-> impl IntoResponse
{
let full_or_widget =
match ProteinViewType::try_from(full_or_widget.as_ref()) {
let scope =
match ProteinViewType::try_from(scope.as_ref()) {
Ok(val) => val,
Err(err) => {
eprintln!("get_protein_features(): {}", err);
return Err((StatusCode::INTERNAL_SERVER_ERROR, format!("Internal error: {}", err)));
}
};

let res = all_state.query_exec.get_api_data().get_protein_features_of_gene(full_or_widget, &gene_uniquename)
let res = all_state.query_exec.get_api_data().get_protein_features_of_gene(scope, &gene_uniquename)
.map(|s| s.to_owned())
.map(Json);
option_json_to_result(&gene_uniquename, res)
Expand Down Expand Up @@ -297,12 +297,12 @@ async fn rna_2d_structure(Path((gene_uniquename, urs_id)): Path<(String, String)

}

async fn protein_feature_view(Path((full_or_widget, gene_uniquename)): Path<(String, String)>,
async fn protein_feature_view(Path((scope, gene_uniquename)): Path<(String, String)>,
State(all_state): State<Arc<AllState>>)
-> (StatusCode, Html<String>)
{
let search_url = all_state.config.server.django_url.to_owned() + "/protein_feature_view/";
let params = [("full_or_widget", full_or_widget),
let params = [("scope", scope),
("gene_uniquename", gene_uniquename)];
let client = reqwest::Client::new();
let result = client.get(search_url).query(&params).send().await;
Expand Down Expand Up @@ -741,7 +741,7 @@ async fn main() {
.route("/", get(get_index))
.route("/structure_view/:structure_type/:id", get(structure_view))
.route("/rna_2d_structure/:gene_uniquename/:urs_id", get(rna_2d_structure))
.route("/protein_feature_view/:full_or_widget/:gene_uniquename", get(protein_feature_view))
.route("/protein_feature_view/:scope/:gene_uniquename", get(protein_feature_view))
.route("/gocam_viz/:full_or_widget/:gocam_id", get(gocam_viz))
.route("/simple/gene/:id", get(get_simple_gene))
.route("/simple/genotype/:id", get(get_simple_genotype))
Expand All @@ -762,7 +762,7 @@ async fn main() {
.route("/api/v1/dataset/latest/gene_ex_violin_plot/:plot_size/:genes", get(gene_ex_violin_plot))
.route("/api/v1/dataset/latest/stats/:type", get(get_stats))
.route("/api/v1/dataset/latest/motif_search/:scope/:q/:max_gene_details", get(motif_search))
.route("/api/v1/dataset/latest/protein_features/:full_or_widget/:gene_uniquename", get(get_protein_features))
.route("/api/v1/dataset/latest/protein_features/:scope/:gene_uniquename", get(get_protein_features))
.route("/api/v1/dataset/latest/query/:q", get(query_get))
.route("/api/v1/dataset/latest/query", post(query_post))
.route("/api/v1/dataset/latest/search/:scope/:q", get(solr_search))
Expand Down
13 changes: 8 additions & 5 deletions src/pombase/api_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ impl APIData {
self.maps.seq_feature_page_features.clone()
}

pub fn get_protein_features_of_gene(&self, full_or_widget: ProteinViewType,
pub fn get_protein_features_of_gene(&self, scope: ProteinViewType,
gene_uniquename: &str)
-> Option<ProteinViewData>
{
Expand All @@ -1029,10 +1029,13 @@ impl APIData {
.iter()
.filter(|track| {
let prot_feat_conf = &self.config.protein_feature_view;
if full_or_widget == ProteinViewType::Widget {
prot_feat_conf.widget_track_names.contains(&track.name)
} else {
!prot_feat_conf.full_display_excluded.contains(&track.name)
match scope {
ProteinViewType::Widget =>
prot_feat_conf.widget_tracks.contains(&track.name),
ProteinViewType::DomainsAndFeatures =>
prot_feat_conf.domains_and_features_tracks.contains(&track.name),
ProteinViewType::Full =>
!prot_feat_conf.full_display_excluded.contains(&track.name),
}
})
.map(Clone::clone)
Expand Down
2 changes: 2 additions & 0 deletions src/pombase/data_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2647,6 +2647,7 @@ pub type GeneExDataSetMeasurements =
pub enum ProteinViewType {
Full,
Widget,
DomainsAndFeatures,
}

impl TryFrom<&str> for ProteinViewType {
Expand All @@ -2655,6 +2656,7 @@ impl TryFrom<&str> for ProteinViewType {
match value {
"full" => Ok(ProteinViewType::Full),
"widget" => Ok(ProteinViewType::Widget),
"domains_and_features" => Ok(ProteinViewType::DomainsAndFeatures),
_ => Err(format!("unknown protein view type: {}", value)),
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/pombase/web/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ pub struct ProteinFeatureViewModGroup {
#[derive(Deserialize, Clone, Debug)]
pub struct ProteinFeatureViewConfig {
pub modification_extension_rel_types: HashSet<FlexStr>,
pub widget_track_names: HashSet<FlexStr>,
pub widget_tracks: HashSet<FlexStr>,
pub domains_and_features_tracks: HashSet<FlexStr>,
pub modification_groups: Vec<ProteinFeatureViewModGroup>,
pub full_display_excluded: HashSet<FlexStr>,
}
Expand Down
3 changes: 2 additions & 1 deletion tests/test_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@
"feature_sub_groups": {},
"protein_feature_view": {
"modification_extension_rel_types": [],
"widget_track_names": [],
"widget_tracks": [],
"domains_and_features_tracks": [],
"modification_groups": [],
"full_display_excluded": []
},
Expand Down
3 changes: 2 additions & 1 deletion tests/test_data_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ fn get_test_config() -> Config {
feature_sub_groups: HashMap::new(),
protein_feature_view: ProteinFeatureViewConfig {
modification_extension_rel_types: HashSet::new(),
widget_track_names: HashSet::new(),
widget_tracks: HashSet::new(),
modification_groups: vec![],
full_display_excluded: HashSet::new(),
domains_and_features_tracks: HashSet::new(),
},
apicuron: ApicuronConfig {
resource_id: flex_str!("pombase"),
Expand Down
3 changes: 2 additions & 1 deletion tests/test_db_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,10 @@ fn get_test_config() -> Config {
feature_sub_groups: HashMap::new(),
protein_feature_view: ProteinFeatureViewConfig {
modification_extension_rel_types: HashSet::new(),
widget_track_names: HashSet::new(),
widget_tracks: HashSet::new(),
modification_groups: vec![],
full_display_excluded: HashSet::new(),
domains_and_features_tracks: HashSet::new(),
},
apicuron: ApicuronConfig {
resource_id: flex_str!("pombase"),
Expand Down

0 comments on commit 70b15cc

Please sign in to comment.