Skip to content

Commit

Permalink
feat: snake_case in REST APIs and rename /tx/csq to /seqvars/csq (#150)…
Browse files Browse the repository at this point in the history
… (#189)
  • Loading branch information
holtgrewe authored Oct 2, 2023
1 parent 9e14c09 commit e1021ed
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,22 @@ jobs:

- uses: Swatinem/rust-cache@v2
with:
key: "${{ matrix.label }}"
cache-directories: |
~/.cargo/registry/src/**/librocksdb-sys-*
- name: Run cargo-tarpaulin with fast tests
uses: actions-rs/[email protected]
with:
version: 0.21.0
args: "-- --test-threads 1"
args: "--skip-clean -- --test-threads 1"
if: ${{ matrix.label == 'fast' }}

- name: Run cargo-tarpaulin with full tests
uses: actions-rs/[email protected]
with:
version: 0.21.0
args: "--release --timeout=180 -- --include-ignored"
args: "--skip-clean --release --timeout=180 -- --include-ignored"
if: ${{ matrix.label == 'full' }}

- name: Codecov submission of fast test results
Expand Down
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn trace_rss_now() {
#[derive(
clap::ValueEnum, serde::Serialize, serde::Deserialize, Clone, Copy, Debug, PartialEq, Eq, Hash,
)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "snake_case")]
pub enum GenomeRelease {
Grch37,
Grch38,
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn version() -> &'static str {
/// Version information that is returned by the HTTP server.
#[derive(serde::Serialize, serde::Deserialize, Default, Debug, Clone)]
#[serde_with::skip_serializing_none]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "snake_case")]
pub struct Version {
/// Version of the transcript database data.
pub tx_db: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions src/server/actix_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use actix_web::ResponseError;
use crate::annotate::strucvars::csq::ConsequencePredictor as StrucvarConsequencePredictor;
use crate::{annotate::seqvars::csq::ConsequencePredictor, common::GenomeRelease};

pub mod seqvars_csq;
pub mod strucvars_csq;
pub mod tx_csq;

#[derive(Debug)]
struct CustomError {
Expand Down Expand Up @@ -47,7 +47,7 @@ pub async fn main(
actix_web::HttpServer::new(move || {
actix_web::App::new()
.app_data(data.clone())
.service(tx_csq::handle)
.service(seqvars_csq::handle)
.service(strucvars_csq::handle)
.wrap(actix_web::middleware::Logger::default())
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Implementation of `/tx/csq` endpoint.
//! Implementation of `/seqvars/csq` endpoint.
use actix_web::{
get,
Expand All @@ -16,10 +16,10 @@ use crate::{
common::GenomeRelease,
};

/// Parameters for `/tx/csq`.
/// Parameters for `/seqvars/csq`.
///
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "snake_case")]
#[serde_with::skip_serializing_none]
struct Query {
/// The assembly.
Expand All @@ -38,7 +38,7 @@ struct Query {

/// Result entry for the API.
#[derive(Debug, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "kebab-case")]
#[serde(rename_all = "snake_case")]
struct ResultEntry {
/// The consequences of the allele.
pub consequences: Vec<Consequence>,
Expand Down Expand Up @@ -85,7 +85,7 @@ struct Container {

/// Query for consequence of a variant.
#[allow(clippy::unused_async)]
#[get("/tx/csq")]
#[get("/seqvars/csq")]
async fn handle(
data: Data<super::WebServerData>,
_path: Path<()>,
Expand Down
13 changes: 10 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,21 @@ pub fn print_hints(args: &Args) {
// The endpoint `/tx/csq` to comput ethe consequence of a variant; without and with filtering
// for HGNC gene ID.
tracing::info!(
" try: http://{}:{}/tx/csq?genome-release=grch37\
" try: http://{}:{}/seqvars/csq?genome_release=grch37\
&chromosome=17&position=48275363&reference=C&alternative=A",
args.listen_host.as_str(),
args.listen_port
);
tracing::info!(
" try: http://{}:{}/tx/csq?genome-release=grch37\
&chromosome=17&position=48275363&reference=C&alternative=A&hgnc-id=HGNC:2197",
" try: http://{}:{}/seqvars/csq?genome_release=grch37\
&chromosome=17&position=48275363&reference=C&alternative=A&hgnc_id=HGNC:2197",
args.listen_host.as_str(),
args.listen_port
);
// The endpoint `/strucvars/csq` computes the consequence of an SV.
tracing::info!(
" try: http://{}:{}/strucvars/csq?genome_release=grch37\
&chromosome=17&start=48275360&&stop=48275370&sv_type=DEL",
args.listen_host.as_str(),
args.listen_port
);
Expand Down

0 comments on commit e1021ed

Please sign in to comment.