Skip to content

Commit

Permalink
fix!: adjusting enum values (#279)
Browse files Browse the repository at this point in the history
This adds a dummy "_UNKNOWN = 0;" value to all enums for compatility
with pb-json package.

Release-As: 0.21.0
  • Loading branch information
holtgrewe committed Nov 22, 2023
1 parent 270ec0c commit 6921b39
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 81 deletions.
35 changes: 27 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ path = "src/main.rs"

[dependencies]
actix-web = "4.4"
annonars = "0.24"
annonars = "0.29"
anyhow = "1.0"
async-compression = { version = "0.4", features = ["tokio", "gzip"] }
bgzip = "0.3"
Expand All @@ -53,10 +53,10 @@ log = "0.4"
nom = "7.1"
noodles-bgzf = { version = "0.25", features = ["async"] }
noodles-core = "0.12"
noodles-csi = "0.26"
noodles-csi = "0.28"
noodles-fasta = "0.30"
noodles-tabix = "0.32"
noodles-vcf = { version = "0.45", features = ["async"] }
noodles-tabix = "0.34"
noodles-vcf = { version = "0.47", features = ["async"] }
parse-display = "0.8"
procfs = "0.16"
prost = "0.12"
Expand Down Expand Up @@ -95,3 +95,9 @@ pretty_assertions = "1.4"
rstest = "0.18"
temp_testdir = "0.2"
tracing-test = "0.2"

# Compile insta with full optimization.
[profile.dev.package.insta]
opt-level = 3
[profile.dev.package.similar]
opt-level = 3
1 change: 0 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// The custo build script, used to (1) generate the Rust classes for the
// protobuf implementation and (2) use pbjson for proto3 JSON serialization.

use pbjson_build;
use std::{env, path::PathBuf};

fn main() -> Result<(), anyhow::Error> {
Expand Down
38 changes: 23 additions & 15 deletions protos/mehari/txs.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,30 @@ message TranscriptDb {

// Enumeration for `Transcript::biotype`.
enum TranscriptBiotype {
// unknown
TRANSCRIPT_BIOTYPE_UNKNOWN = 0;
// Coding transcript.
CODING = 0;
TRANSCRIPT_BIOTYPE_CODING = 1;
// Non-coding transcript.
NON_CODING = 1;
TRANSCRIPT_BIOTYPE_NON_CODING = 2;
}

// Bit values for the transcript tags.
enum TranscriptTag{
enum TranscriptTag {
// unknown
TRANSCRIPT_TAG_UNKNOWN = 0;
// Member of Ensembl basic.
BASIC = 0;
TRANSCRIPT_TAG_BASIC = 1;
// Member of Ensembl canonical.
ENSEMBL_CANONICAL = 1;
TRANSCRIPT_TAG_ENSEMBL_CANONICAL = 2;
// Member of MANE Select.
MANE_SELECT = 2;
TRANSCRIPT_TAG_MANE_SELECT = 3;
// Member of MANE Plus Clinical.
MANE_PLUS_CLINICAL = 3;
TRANSCRIPT_TAG_MANE_PLUS_CLINICAL = 4;
// Member of RefSeq Select.
REF_SEQ_SELECT = 4;
TRANSCRIPT_TAG_REF_SEQ_SELECT = 5;
// Flagged as being a selenoprotein (UGA => selenon).
SELENOPROTEIN = 5;
TRANSCRIPT_TAG_SELENOPROTEIN = 6;
}

// Store information about a transcript.
Expand All @@ -80,19 +84,23 @@ message Transcript {
}

// Enumeration for the known genome builds.
enum GenomeBuild{
enum GenomeBuild {
// unknown
GENOME_BUILD_UNKNOWN = 0;
// GRCH37.
GRCH37 = 0;
GENOME_BUILD_GRCH37 = 1;
// GRCh38.
GRCH38 = 1;
GENOME_BUILD_GRCH38 = 2;
}

// Enumeration for the two strands of the genome.
enum Strand{
enum Strand {
// unknown
STRAND_UNKNOWN = 0;
// Forward / plus
PLUS = 0;
STRAND_PLUS = 1;
// Reverse / minus
MINUS = 1;
STRAND_MINUS = 2;
}

// Store information about a transcript aligning to a genome.
Expand Down
6 changes: 6 additions & 0 deletions src/annotate/seqvars/csq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ impl ConsequencePredictor {
match Strand::try_from(alignment.strand).expect("invalid strand") {
Strand::Plus => consequences.push(Consequence::SpliceDonorVariant),
Strand::Minus => consequences.push(Consequence::SpliceAcceptorVariant),
_ => unreachable!("invalid strand: {}", alignment.strand),
}
}
// Check the case where the variant overlaps with the splice donor site.
Expand All @@ -406,6 +407,7 @@ impl ConsequencePredictor {
match Strand::try_from(alignment.strand).expect("invalid strand") {
Strand::Plus => consequences.push(Consequence::SpliceAcceptorVariant),
Strand::Minus => consequences.push(Consequence::SpliceDonorVariant),
_ => unreachable!("invalid strand: {}", alignment.strand),
}
}
}
Expand Down Expand Up @@ -459,6 +461,7 @@ impl ConsequencePredictor {
let mut feature_biotypes = vec![match transcript_biotype {
TranscriptBiotype::Coding => FeatureBiotype::Coding,
TranscriptBiotype::NonCoding => FeatureBiotype::Noncoding,
_ => unreachable!("invalid biotype: {:?}", transcript_biotype),
}];

if tx.tags.contains(&(TranscriptTag::ManeSelect as i32)) {
Expand Down Expand Up @@ -488,6 +491,7 @@ impl ConsequencePredictor {
match Strand::try_from(alignment.strand).expect("invalid strand") {
Strand::Plus => consequences.push(Consequence::UpstreamGeneVariant),
Strand::Minus => consequences.push(Consequence::DownstreamGeneVariant),
_ => unreachable!("invalid strand: {}", alignment.strand),
}
}
if distance.is_none() {
Expand All @@ -499,6 +503,7 @@ impl ConsequencePredictor {
match Strand::try_from(alignment.strand).expect("invalid strand") {
Strand::Plus => consequences.push(Consequence::DownstreamGeneVariant),
Strand::Minus => consequences.push(Consequence::UpstreamGeneVariant),
_ => unreachable!("invalid strand: {}", alignment.strand),
}
}
if distance.is_none() {
Expand Down Expand Up @@ -752,6 +757,7 @@ impl ConsequencePredictor {
(var_c, Some(var_p), hgvs_p, cds_pos, protein_pos)
}
TranscriptBiotype::NonCoding => (var_n, None, None, None, None),
_ => unreachable!("invalid transcript biotype: {:?}", transcript_biotype),
};
let hgvs_t = format!("{}", &var_t);
let hgvs_t = hgvs_t.split(':').nth(1).unwrap().to_owned();
Expand Down
6 changes: 3 additions & 3 deletions src/annotate/seqvars/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,15 @@ where
{
if let Some(raw_value) = db.get_cf(cf, key)? {
let clinvar_record =
clinvar_minimal::pbs::Record::decode(&mut std::io::Cursor::new(&raw_value))?;
annonars::pbs::clinvar::minimal::Record::decode(&mut std::io::Cursor::new(&raw_value))?;

let clinvar_minimal::pbs::Record {
let annonars::pbs::clinvar::minimal::Record {
vcv,
reference_assertions,
..
} = clinvar_record;
if let Some(reference_assertion) = reference_assertions.first() {
let clinvar_minimal::pbs::ReferenceAssertion {
let annonars::pbs::clinvar::minimal::ReferenceAssertion {
rcv,
clinical_significance,
..
Expand Down
2 changes: 2 additions & 0 deletions src/annotate/seqvars/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ impl ProviderInterface for Provider {
{
Strand::Plus => 1,
Strand::Minus => -1,
_ => unreachable!("invalid strand {}", &genome_alignment.strand),
},
ord: exon.ord,
tx_start_i: exon.alt_cds_start_i.map(|val| val - 1).unwrap_or(-1),
Expand Down Expand Up @@ -530,6 +531,7 @@ impl ProviderInterface for Provider {
alt_strand: match Strand::try_from(alt_strand).expect("invalid strand") {
Strand::Plus => 1,
Strand::Minus => -1,
_ => unreachable!("invalid strand {}", alt_strand),
},
alt_aln_method: ALT_ALN_METHOD.to_string(),
start_i,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ expression: res
feature_id: NM_133379.5
feature_biotype:
- Coding
- ManePlusClinical
rank:
ord: 41
total: 46
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,4 @@ expression: res
total: 35992
distance: 0
messages: ~
- allele:
Alt:
alternative: A
consequences:
- stop_gained
putative_impact: HIGH
gene_symbol: TTN
gene_id: "HGNC:12403"
feature_type:
SoTerm:
term: Transcript
feature_id: NM_133379.5
feature_biotype:
- Coding
- ManePlusClinical
rank:
ord: 41
total: 46
hgvs_t: c.9565C>T
hgvs_p: p.Q3189*
tx_pos:
ord: 9790
total: 18220
cds_pos:
ord: 9565
total: 16815
protein_pos:
ord: 3189
total: 5605
distance: 0
messages: ~

1 change: 1 addition & 0 deletions src/db/create/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ fn load_and_extract(
.collect::<Vec<_>>(),
);
}
tracing::info!("{:?}", txid_to_label);

tracing::info!(
"...done loading label TSV file ({} entries)",
Expand Down
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ txDb:
- id: NM_004261.5
geneSymbol: SELENOF
geneId: HGNC:17705
biotype: TRANSCRIPT_BIOTYPE_CODING
tags:
- MANE_SELECT
- SELENOPROTEIN
- TRANSCRIPT_TAG_MANE_SELECT
- TRANSCRIPT_TAG_SELENOPROTEIN
protein: NP_004252.2
startCodon: 15
stopCodon: 513
genomeAlignments:
- genomeBuild: GRCH38
- genomeBuild: GENOME_BUILD_GRCH38
contig: NC_000001.11
cdsStart: 86863473
cdsEnd: 86914111
strand: MINUS
strand: STRAND_MINUS
exons:
- altStartI: 86862444
altEndI: 86863605
Expand Down Expand Up @@ -52,17 +53,18 @@ txDb:
- id: NM_203341.3
geneSymbol: SELENOF
geneId: HGNC:17705
biotype: TRANSCRIPT_BIOTYPE_CODING
tags:
- SELENOPROTEIN
- TRANSCRIPT_TAG_SELENOPROTEIN
protein: NP_976086.1
startCodon: 15
stopCodon: 390
genomeAlignments:
- genomeBuild: GRCH38
- genomeBuild: GENOME_BUILD_GRCH38
contig: NC_000001.11
cdsStart: 86863546
cdsEnd: 86914111
strand: MINUS
strand: STRAND_MINUS
exons:
- altStartI: 86862444
altEndI: 86863605
Expand Down
4 changes: 2 additions & 2 deletions tests/data/annotate/db/grch37/bootstrap.sh
Git LFS file not shown
4 changes: 2 additions & 2 deletions tests/data/annotate/db/grch37/txs.bin.zst
Git LFS file not shown
Loading

0 comments on commit 6921b39

Please sign in to comment.