rosella/
lib.rs

1pub mod cli;
2pub mod coverage;
3pub mod external_command_checker;
4pub mod external;
5pub mod kmers;
6pub mod recover;
7
8// #[cfg(not(feature = "no_flight"))]
9pub mod refine;
10
11#[cfg(feature = "no_flight")]
12pub mod clustering;
13#[cfg(feature = "no_flight")]
14pub mod embedding;
15#[cfg(feature = "no_flight")]
16pub mod graphs;
17#[cfg(feature = "no_flight")]
18pub mod sketch;
19
20#[macro_use]
21extern crate anyhow;
22
23use log::info;
24use anyhow::Result;
25use std::{path::Path, io::{BufReader, BufRead}};
26
27
28pub const AUTHOR: &str =
29    "Rhys J. P. Newell, Centre for Microbiome Research, School of Biomedical Sciences, Faculty of Health, Queensland University of Technology";
30pub const AUTHOR_AND_EMAIL: &str =
31    "Rhys J. P. Newell, Centre for Microbiome Research, School of Biomedical Sciences, Faculty of Health, Queensland University of Technology <rhys.newell94 near gmail.com>";
32pub const EMAIL: &str = "rhys.newell94 near gmail.com";
33
34pub fn parse_percentage(m: &clap::ArgMatches, parameter: &str) -> f32 {
35    match m.contains_id(parameter) {
36        true => {
37            let mut percentage: f32 = *m.get_one(parameter).unwrap();
38            if percentage >= 1.0 && percentage <= 100.0 {
39                percentage = percentage / 100.0;
40            } else if percentage < 0.0 || percentage > 100.0 {
41                panic!("Invalid alignment percentage: '{}'", percentage);
42            }
43            info!("Using {} {}%", parameter, percentage * 100.0);
44            percentage
45        }
46        false => 0.0,
47    }
48}
49
50// Enum for exclusion out here so long read can find it
51pub enum GenomeExclusionTypes {
52    SeparatorType,
53    NoneType,
54    GenomesAndContigsType,
55}
56
57/// read any file into a buffered reader, optionally unzipping it
58pub fn get_file_reader<P: AsRef<Path>>(file_path: P) -> Result<Box<dyn BufRead>> {
59    let reader = BufReader::new(Box::new(std::fs::File::open(file_path)?));
60    Ok(Box::new(reader))
61}