varlociraptor/
lib.rs

1// Copyright 2016-2019 Johannes Köster, David Lähnemann.
2// Licensed under the GNU GPLv3 license (https://opensource.org/licenses/GPL-3.0)
3// This file may not be copied, modified, or distributed
4// except according to those terms.
5
6#![warn(clippy::all)]
7
8#[macro_use]
9extern crate log;
10#[macro_use]
11extern crate approx;
12#[macro_use]
13extern crate serde_derive;
14#[macro_use]
15extern crate lazy_static;
16extern crate askama;
17#[macro_use]
18extern crate derive_new;
19#[macro_use]
20extern crate pest_derive;
21#[macro_use]
22extern crate getset;
23#[macro_use]
24extern crate strum_macros;
25#[macro_use]
26extern crate derive_builder;
27#[macro_use]
28extern crate shrinkwraprs;
29#[macro_use]
30extern crate derefable;
31#[macro_use]
32extern crate typed_builder;
33extern crate paste;
34
35pub mod calling;
36pub mod candidates;
37pub mod cli;
38pub(crate) mod conversion;
39pub(crate) mod errors;
40pub(crate) mod estimation;
41pub mod filtration;
42pub(crate) mod grammar;
43pub(crate) mod reference;
44pub mod testcase;
45pub mod utils;
46pub mod variants;
47
48/// Event to call.
49pub trait Event {
50    fn name(&self) -> &str;
51
52    fn tag_name(&self, prefix: &str) -> String {
53        format!("{}_{}", prefix, self.name().to_ascii_uppercase())
54    }
55
56    fn header_entry(&self, prefix: &str, desc: &str) -> String {
57        format!(
58            "##INFO=<ID={tag_name},Number=A,Type=Float,\
59             Description=\"{desc} {name} variant\">",
60            name = self.name().replace('_', "-"),
61            desc = desc,
62            tag_name = &self.tag_name(prefix)
63        )
64    }
65}
66
67/// A simple event that just has a name.
68#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
69pub struct SimpleEvent {
70    /// event name
71    pub name: String,
72}
73
74impl SimpleEvent {
75    pub fn new(name: &str) -> Self {
76        Self {
77            name: name.to_string(),
78        }
79    }
80}
81
82impl Event for SimpleEvent {
83    fn name(&self) -> &str {
84        &self.name
85    }
86}