#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Strand {
Forward,
Reverse,
}
impl std::fmt::Display for Strand {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Strand::Forward => write!(f, "+"),
Strand::Reverse => write!(f, "-"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum StartCodon {
ATG,
GTG,
TTG,
Edge,
}
impl std::fmt::Display for StartCodon {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StartCodon::ATG => write!(f, "ATG"),
StartCodon::GTG => write!(f, "GTG"),
StartCodon::TTG => write!(f, "TTG"),
StartCodon::Edge => write!(f, "Edge"),
}
}
}
#[derive(Debug, Clone)]
pub struct PredictedGene {
pub begin: usize,
pub end: usize,
pub strand: Strand,
pub start_codon: StartCodon,
pub translation_table: u8,
pub partial: (bool, bool),
pub rbs_motif: String,
pub rbs_spacer: String,
pub gc_content: f64,
pub confidence: f64,
pub score: f64,
pub cscore: f64,
pub sscore: f64,
pub rscore: f64,
pub uscore: f64,
pub tscore: f64,
}
#[derive(Debug, Clone)]
pub struct ProdigalConfig {
pub translation_table: u8,
pub closed_ends: bool,
pub mask_n_runs: bool,
pub force_non_sd: bool,
}
impl Default for ProdigalConfig {
fn default() -> Self {
ProdigalConfig {
translation_table: 11,
closed_ends: false,
mask_n_runs: false,
force_non_sd: false,
}
}
}
#[derive(Debug)]
pub enum ProdigalError {
EmptySequence,
SequenceTooShort { length: usize, min: usize },
SequenceTooLong { length: usize, max: usize },
InvalidTranslationTable(u8),
Io(std::io::Error),
}
impl std::fmt::Display for ProdigalError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ProdigalError::EmptySequence => write!(f, "sequence is empty"),
ProdigalError::SequenceTooShort { length, min } => {
write!(f, "sequence too short ({length} bp, need >= {min} bp)")
}
ProdigalError::SequenceTooLong { length, max } => {
write!(f, "sequence too long ({length} bp, max {max} bp)")
}
ProdigalError::InvalidTranslationTable(t) => {
write!(f, "invalid translation table: {t}")
}
ProdigalError::Io(e) => write!(f, "I/O error: {e}"),
}
}
}
impl std::error::Error for ProdigalError {}
impl From<std::io::Error> for ProdigalError {
fn from(e: std::io::Error) -> Self {
ProdigalError::Io(e)
}
}