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 partial: (bool, bool),
50 pub rbs_motif: String,
52 pub rbs_spacer: String,
54 pub gc_content: f64,
56 pub confidence: f64,
58 pub score: f64,
60 pub cscore: f64,
62 pub sscore: f64,
64 pub rscore: f64,
66 pub uscore: f64,
68 pub tscore: f64,
70}
71
72#[derive(Debug, Clone)]
74pub struct ProdigalConfig {
75 pub translation_table: u8,
77 pub closed_ends: bool,
79 pub mask_n_runs: bool,
81 pub force_non_sd: bool,
83}
84
85impl Default for ProdigalConfig {
86 fn default() -> Self {
87 ProdigalConfig {
88 translation_table: 11,
89 closed_ends: false,
90 mask_n_runs: false,
91 force_non_sd: false,
92 }
93 }
94}
95
96#[derive(Debug)]
98pub enum ProdigalError {
99 EmptySequence,
100 SequenceTooShort { length: usize, min: usize },
101 SequenceTooLong { length: usize, max: usize },
102 InvalidTranslationTable(u8),
103 Io(std::io::Error),
104}
105
106impl std::fmt::Display for ProdigalError {
107 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
108 match self {
109 ProdigalError::EmptySequence => write!(f, "sequence is empty"),
110 ProdigalError::SequenceTooShort { length, min } => {
111 write!(f, "sequence too short ({length} bp, need >= {min} bp)")
112 }
113 ProdigalError::SequenceTooLong { length, max } => {
114 write!(f, "sequence too long ({length} bp, max {max} bp)")
115 }
116 ProdigalError::InvalidTranslationTable(t) => {
117 write!(f, "invalid translation table: {t}")
118 }
119 ProdigalError::Io(e) => write!(f, "I/O error: {e}"),
120 }
121 }
122}
123
124impl std::error::Error for ProdigalError {}
125
126impl From<std::io::Error> for ProdigalError {
127 fn from(e: std::io::Error) -> Self {
128 ProdigalError::Io(e)
129 }
130}