use crate::F32Bw0and1;
use derive_builder::UninitializedFieldError;
use std::char::TryFromCharError;
use std::fmt;
use std::io;
use std::num::{ParseFloatError, ParseIntError, TryFromIntError};
use std::str::Utf8Error;
use std::string::FromUtf8Error;
use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("unknown alignment state: `{0}`")]
UnknownAlignState(String),
#[error("invalid sequence length: `{0}`")]
InvalidSeqLength(String),
#[error("invalid alignment length: `{0}`")]
InvalidAlignLength(String),
#[error("invalid contig and/or start: `{0}`")]
InvalidContigAndStart(String),
#[error(
"invalid alignment coordinates (contig/start/end): `{0}`. \n\
In command line tool, you can use `nanalogue peek` to check contig names and contig lengths. \n\
In command line tool, if piping in a samtools view command, please include header with -h in samtools. "
)]
InvalidAlignCoords(String),
#[error("invalid mod coordinates: `{0}`")]
InvalidModCoords(String),
#[error("invalid mod probabilities: `{0}`")]
InvalidModProbs(String),
#[error("invalid sequence: `{0}`")]
InvalidSeq(String),
#[error("invalid base: `{0}`")]
InvalidBase(String),
#[error("invalid read id: `{0}`")]
InvalidReadID(String),
#[error("invalid mod type: `{0}`")]
InvalidModType(String),
#[error("empty mod type: `{0}`")]
EmptyModType(String),
#[error(
"rust_htslib error: `{0}` \n\
In command line tool, you can use `nanalogue peek` to check contig names and contig lengths. \n\
In command line tool, if piping in a samtools view command, please include header with -h in samtools. "
)]
RustHtslibError(#[from] rust_htslib::errors::Error),
#[error("integer conversion error: `{0}`")]
IntConversionError(#[from] TryFromIntError),
#[error("error involving string conversion: `{0}`")]
StringConversionError(#[from] Utf8Error),
#[error("UTF-8 conversion error: `{0}`")]
Utf8ConversionError(#[from] FromUtf8Error),
#[error("JSON parsing error: `{0}`")]
JsonParseError(#[from] serde_json::Error),
#[error("ordered pair conversion error: `{0}`")]
OrdPairConversion(String),
#[error("integer parsing error: `{0}`")]
IntParseError(#[from] ParseIntError),
#[error("float parsing error: `{0}`")]
FloatParseError(#[from] ParseFloatError),
#[error("input output error: `{0}`")]
InputOutputError(#[from] io::Error),
#[error("formatting error: `{0}`")]
FormattingError(#[from] fmt::Error),
#[error("error parsing csv: `{0}`")]
CsvError(#[from] csv::Error),
#[error("duplicates detected: `{0}`")]
InvalidDuplicates(String),
#[error("`{0}`")]
InvalidState(String),
#[error("error while writing output: `{0}`")]
WriteOutput(String),
#[error("not implemented: `{0}`")]
NotImplemented(String),
#[error("items in wrong order: `{0}`")]
WrongOrder(String),
#[error("data not available: `{0}`")]
UnavailableData(String),
#[error("read is unmapped: `{0}`")]
Unmapped(String),
#[error("zero values not allowed: `{0}`")]
Zero(String),
#[error("zero sequence length: `{0}`")]
ZeroSeqLen(String),
#[error(
"invalid region '{region}': position {pos} exceeds contig length {contig_length}\n\
In command line tool, you can use `nanalogue peek` to check contig names and contig lengths."
)]
InvalidRegion {
region: String,
pos: u64,
contig_length: u64,
},
#[error("invalid sorting: {0}")]
InvalidSorting(String),
#[error("window density {density} below threshold {threshold}")]
WindowDensBelowThres {
density: F32Bw0and1,
threshold: F32Bw0and1,
},
#[error("window does not contain any data: `{0}`")]
EmptyWindow(String),
#[error("data is not of sufficient size (e.g. in a window): `{0}`")]
InsufficientDataSize(String),
#[error("unanticipated arithmetic error e.g. overflow: `{0}`")]
Arithmetic(String),
#[error("building error, are you missing inputs?: `{0}`")]
BuilderError(#[from] UninitializedFieldError),
#[error("building error, input validation failed: `{0}`")]
BuilderValidation(String),
#[error("error converting between DNA bases: `{0}`")]
FromCharError(#[from] TryFromCharError),
#[error("Polars error: `{0}`")]
PolarsError(#[from] polars::error::PolarsError),
#[error("Simulate DNA sequence error; problem at end of CIGAR: {0}")]
SimulateDNASeqCIGAREndProblem(String),
}