Skip to content

Commit

Permalink
fix: resolve issue with enum conversion to protobuf ones (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Nov 24, 2023
1 parent a213313 commit 517ba37
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
66 changes: 33 additions & 33 deletions protos/annonars/genes/base.proto
Original file line number Diff line number Diff line change
Expand Up @@ -725,71 +725,71 @@ enum GtexTissueDetailed {
// Cells - EBV-transformed lymphocytes
GTEX_TISSUE_DETAILED_CELLS_EBV_TRANSFORMED_LYMPHOCYTES = 23;
// Cells - Leukemia cell line (CML)
GTEX_TISSUE_DETAILED_CELLS_LEUKEMIA_CELL_LINE = 24;
GTEX_TISSUE_DETAILED_CELLS_LEUKEMIA_CELL_LINE = 24;
// Cervix - Ectocervix
GTEX_TISSUE_DETAILED_CERVIX_ECTOCERVIX = 25;
GTEX_TISSUE_DETAILED_CERVIX_ECTOCERVIX = 25;
// Cervix - Endocervix
GTEX_TISSUE_DETAILED_CERVIX_ENDOCERVIX = 26;
GTEX_TISSUE_DETAILED_CERVIX_ENDOCERVIX = 26;
// Colon - Sigmoid
GTEX_TISSUE_DETAILED_COLON_SIGMOID = 27;
GTEX_TISSUE_DETAILED_COLON_SIGMOID = 27;
// Colon - Transverse
GTEX_TISSUE_DETAILED_COLON_TRANSVERSE = 28;
GTEX_TISSUE_DETAILED_COLON_TRANSVERSE = 28;
// Esophagus - Gastroesophageal Junction
GTEX_TISSUE_DETAILED_ESOPHAGUS_GASTROESOPHAGEAL_JUNCTION = 29;
GTEX_TISSUE_DETAILED_ESOPHAGUS_GASTROESOPHAGEAL_JUNCTION = 29;
// Esophagus - Mucosa
GTEX_TISSUE_DETAILED_ESOPHAGUS_MUCOSA = 30;
GTEX_TISSUE_DETAILED_ESOPHAGUS_MUCOSA = 30;
// Esophagus - Muscularis
GTEX_TISSUE_DETAILED_ESOPHAGUS_MUSCULARIS = 31;
GTEX_TISSUE_DETAILED_ESOPHAGUS_MUSCULARIS = 31;
// Fallopian Tube
GTEX_TISSUE_DETAILED_FALLOPIAN_TUBE = 32;
GTEX_TISSUE_DETAILED_FALLOPIAN_TUBE = 32;
// Heart - Atrial Appendage
GTEX_TISSUE_DETAILED_HEART_ATRIAL_APPENDAGE = 33;
GTEX_TISSUE_DETAILED_HEART_ATRIAL_APPENDAGE = 33;
// Heart - Left Ventricle
GTEX_TISSUE_DETAILED_HEART_LEFT_VENTRICLE = 34;
GTEX_TISSUE_DETAILED_HEART_LEFT_VENTRICLE = 34;
// Kidney - Cortex
GTEX_TISSUE_DETAILED_KIDNEY_CORTEX = 35;
GTEX_TISSUE_DETAILED_KIDNEY_CORTEX = 35;
// Kidney - Medulla
GTEX_TISSUE_DETAILED_KIDNEY_MEDULLA = 36;
GTEX_TISSUE_DETAILED_KIDNEY_MEDULLA = 36;
// Liver
GTEX_TISSUE_DETAILED_LIVER = 37;
GTEX_TISSUE_DETAILED_LIVER = 37;
// Lung
GTEX_TISSUE_DETAILED_LUNG = 38;
GTEX_TISSUE_DETAILED_LUNG = 38;
// Minor Salivary Gland
GTEX_TISSUE_DETAILED_MINOR_SALIVARY_GLAND = 39;
GTEX_TISSUE_DETAILED_MINOR_SALIVARY_GLAND = 39;
// Muscle - Skeletal
GTEX_TISSUE_DETAILED_MUSCLE_SKELETAL = 40;
GTEX_TISSUE_DETAILED_MUSCLE_SKELETAL = 40;
// Nerve - Tibial
GTEX_TISSUE_DETAILED_NERVE_TIBIAL = 41;
GTEX_TISSUE_DETAILED_NERVE_TIBIAL = 41;
// Ovary
GTEX_TISSUE_DETAILED_OVARY = 42;
GTEX_TISSUE_DETAILED_OVARY = 42;
// Pancreas
GTEX_TISSUE_DETAILED_PANCREAS = 43;
GTEX_TISSUE_DETAILED_PANCREAS = 43;
// Pituitary
GTEX_TISSUE_DETAILED_PITUITARY = 44;
GTEX_TISSUE_DETAILED_PITUITARY = 44;
// Prostate
GTEX_TISSUE_DETAILED_PROSTATE = 45;
GTEX_TISSUE_DETAILED_PROSTATE = 45;
// Salivary Gland
GTEX_TISSUE_DETAILED_SALIVARY_GLAND = 46;
GTEX_TISSUE_DETAILED_SALIVARY_GLAND = 46;
// Skin - Not Sun Exposed (Suprapubic)
GTEX_TISSUE_DETAILED_SKIN_NOT_SUN_EXPOSED_SUPRAPUBIC = 47;
GTEX_TISSUE_DETAILED_SKIN_NOT_SUN_EXPOSED_SUPRAPUBIC = 47;
// Skin - Sun Exposed (Lower leg)
GTEX_TISSUE_DETAILED_SKIN_SUN_EXPOSED_LOWER_LEG = 48;
GTEX_TISSUE_DETAILED_SKIN_SUN_EXPOSED_LOWER_LEG = 48;
// Small Intestine - Terminal Ileum
GTEX_TISSUE_DETAILED_SMALL_INTESTINE_TERMINAL_ILEUM = 49;
GTEX_TISSUE_DETAILED_SMALL_INTESTINE_TERMINAL_ILEUM = 49;
// Spleen
GTEX_TISSUE_DETAILED_SPLEEN = 50;
GTEX_TISSUE_DETAILED_SPLEEN = 50;
// Stomach
GTEX_TISSUE_DETAILED_STOMACH = 51;
GTEX_TISSUE_DETAILED_STOMACH = 51;
// Testis
GTEX_TISSUE_DETAILED_TESTIS = 52;
GTEX_TISSUE_DETAILED_TESTIS = 52;
// Thyroid
GTEX_TISSUE_DETAILED_THYROID = 53;
GTEX_TISSUE_DETAILED_THYROID = 53;
// Uterus
GTEX_TISSUE_DETAILED_UTERUS = 54;
GTEX_TISSUE_DETAILED_UTERUS = 54;
// Vagina
GTEX_TISSUE_DETAILED_VAGINA = 55;
GTEX_TISSUE_DETAILED_VAGINA = 55;
// Whole Blood
GTEX_TISSUE_DETAILED_WHOLE_BLOOD = 56;
GTEX_TISSUE_DETAILED_WHOLE_BLOOD = 56;
}

// Entry with the tissue-specific information for a gene.
Expand Down
11 changes: 11 additions & 0 deletions src/genes/cli/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,8 @@ pub mod hgnc {
use serde::{Deserialize, Serialize};
use serde_with::DisplayFromStr;

use crate::pbs;

/// Status of the symbol report, which can be either "Approved" or "Entry Withdrawn".
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum Status {
Expand All @@ -1361,6 +1363,15 @@ pub mod hgnc {
Withdrawn,
}

impl Into<pbs::genes::base::HgncStatus> for Status {

Check warning on line 1366 in src/genes/cli/data.rs

View workflow job for this annotation

GitHub Actions / clippy

an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true

warning: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true --> src/genes/cli/data.rs:1366:5 | 1366 | impl Into<pbs::genes::base::HgncStatus> for Status { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_over_into = note: `#[warn(clippy::from_over_into)]` on by default help: replace the `Into` implementation with `From<genes::cli::data::hgnc::Status>` | 1366 ~ impl From<Status> for pbs::genes::base::HgncStatus { 1367 ~ fn from(val: Status) -> Self { 1368 ~ match val { |
fn into(self) -> pbs::genes::base::HgncStatus {
match self {
Status::Approve => pbs::genes::base::HgncStatus::Approved,
Status::Withdrawn => pbs::genes::base::HgncStatus::Withdrawn,
}
}
}

/// Information from the locus-specific dabase.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Lsdb {
Expand Down
8 changes: 5 additions & 3 deletions src/genes/cli/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ fn convert_record(record: data::Record) -> pbs::genes::base::Record {
name,
locus_group,
locus_type,
status: status as i32,
status: Into::<pbs::genes::base::HgncStatus>::into(status) as i32,
location,
location_sortable,
alias_symbol: alias_symbol.unwrap_or_default(),
Expand Down Expand Up @@ -967,8 +967,10 @@ fn convert_record(record: data::Record) -> pbs::genes::base::Record {
tpms,
} = record;
pbs::genes::base::GtexTissueRecord {
tissue: tissue as i32,
tissue_detailed: tissue_detailed as i32,
tissue: Into::<pbs::genes::base::GtexTissue>::into(tissue) as i32,
tissue_detailed: Into::<pbs::genes::base::GtexTissueDetailed>::into(
tissue_detailed,
) as i32,
tpms,
}
})
Expand Down

0 comments on commit 517ba37

Please sign in to comment.