1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum Strand {
4 Forward,
5 Reverse,
6}
7
8impl std::fmt::Display for Strand {
9 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
10 match self {
11 Strand::Forward => write!(f, "+"),
12 Strand::Reverse => write!(f, "-"),
13 }
14 }
15}
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub enum StartCodon {
20 ATG,
21 GTG,
22 TTG,
23 Edge,
24}
25
26impl std::fmt::Display for StartCodon {
27 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28 match self {
29 StartCodon::ATG => write!(f, "ATG"),
30 StartCodon::GTG => write!(f, "GTG"),
31 StartCodon::TTG => write!(f, "TTG"),
32 StartCodon::Edge => write!(f, "Edge"),
33 }
34 }
35}
36
37#[derive(Debug, Clone)]
39pub struct PredictedGene {
40 pub begin: usize,
42 pub end: usize,
44 pub strand: Strand,
46 pub start_codon: StartCodon,
48 pub translation_table: u8,
50 pub partial: (bool, bool),
52 pub rbs_motif: String,
54 pub rbs_spacer: String,
56 pub gc_content: f64,
58 pub confidence: f64,
60 pub score: f64,
62 pub cscore: f64,
64 pub sscore: f64,
66 pub rscore: f64,
68 pub uscore: f64,
70 pub tscore: f64,
72}
73
74#[derive(Debug, Clone)]
76pub struct ProdigalConfig {
77 pub translation_table: u8,
79 pub closed_ends: bool,
81 pub mask_n_runs: bool,
83 pub force_non_sd: bool,
85}
86
87impl Default for ProdigalConfig {
88 fn default() -> Self {
89 ProdigalConfig {
90 translation_table: 11,
91 closed_ends: false,
92 mask_n_runs: false,
93 force_non_sd: false,
94 }
95 }
96}
97
98#[derive(Debug)]
100pub enum ProdigalError {
101 EmptySequence,
102 SequenceTooShort { length: usize, min: usize },
103 SequenceTooLong { length: usize, max: usize },
104 InvalidTranslationTable(u8),
105 Io(std::io::Error),
106}
107
108impl std::fmt::Display for ProdigalError {
109 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
110 match self {
111 ProdigalError::EmptySequence => write!(f, "sequence is empty"),
112 ProdigalError::SequenceTooShort { length, min } => {
113 write!(f, "sequence too short ({length} bp, need >= {min} bp)")
114 }
115 ProdigalError::SequenceTooLong { length, max } => {
116 write!(f, "sequence too long ({length} bp, max {max} bp)")
117 }
118 ProdigalError::InvalidTranslationTable(t) => {
119 write!(f, "invalid translation table: {t}")
120 }
121 ProdigalError::Io(e) => write!(f, "I/O error: {e}"),
122 }
123 }
124}
125
126impl std::error::Error for ProdigalError {}
127
128impl From<std::io::Error> for ProdigalError {
129 fn from(e: std::io::Error) -> Self {
130 ProdigalError::Io(e)
131 }
132}