orphos_core/results.rs
1use crate::types::{Gene, Training};
2
3/// Gene finding results from Orphos analysis.
4///
5/// Contains all information from a gene prediction run including
6/// predicted genes, training parameters, and sequence statistics.
7///
8/// # Fields
9///
10/// - `genes`: Vector of predicted genes sorted by position
11/// - `training_used`: Statistical model parameters from training
12/// - `sequence_info`: Metadata about the analyzed sequence
13/// - `metagenomic_model`: Model name if metagenomic mode was used
14///
15/// # Examples
16///
17/// ```rust,no_run
18/// use orphos_core::{OrphosAnalyzer, config::OrphosConfig, config::OutputFormat};
19/// use orphos_core::output::write_results;
20///
21/// let mut analyzer = OrphosAnalyzer::new(OrphosConfig::default());
22/// let results = analyzer.analyze_sequence("ATGCGATCG...", None)?;
23///
24/// println!("Sequence: {}", results.sequence_info.header);
25/// println!("Length: {} bp", results.sequence_info.length);
26/// println!("GC%: {:.2}", results.sequence_info.gc_content * 100.0);
27/// println!("Genes: {}", results.genes.len());
28///
29/// // Write results to file
30/// let mut output = std::fs::File::create("output.gbk")?;
31/// write_results(&mut output, &results, OutputFormat::Genbank)?;
32/// # Ok::<(), Box<dyn std::error::Error>>(())
33/// ```
34#[derive(Debug)]
35pub struct OrphosResults {
36 /// Vector of predicted genes sorted by genomic position.
37 ///
38 /// Each gene contains coordinates, strand, scores, and sequence information.
39 pub genes: Vec<Gene>,
40
41 /// Training parameters used for gene prediction.
42 ///
43 /// Includes statistical models for start codons, RBS motifs, and codon usage.
44 pub training_used: Training,
45
46 /// Information about the analyzed sequence.
47 ///
48 /// Contains length, GC content, gene count, and sequence identifiers.
49 pub sequence_info: SequenceInfo,
50
51 /// Name of metagenomic model used, if applicable.
52 ///
53 /// Set to `Some("Best")` in metagenomic mode, `None` in single genome mode.
54 pub metagenomic_model: Option<String>,
55}
56
57/// Information about a processed sequence.
58///
59/// Contains metadata and statistics for a sequence that was analyzed.
60///
61/// # Examples
62///
63/// ```rust,no_run
64/// # use orphos_core::results::SequenceInfo;
65/// let info = SequenceInfo {
66/// length: 4_641_652,
67/// gc_content: 0.5079,
68/// num_genes: 4321,
69/// header: "E. coli K12".to_string(),
70/// description: Some("Complete genome".to_string()),
71/// };
72///
73/// println!("{}: {} bp, {:.2}% GC, {} genes",
74/// info.header,
75/// info.length,
76/// info.gc_content * 100.0,
77/// info.num_genes);
78/// ```
79#[derive(Debug, Clone)]
80pub struct SequenceInfo {
81 /// Length of the sequence in base pairs.
82 pub length: usize,
83
84 /// GC content as a fraction (0.0 to 1.0).
85 ///
86 /// Multiply by 100 to get percentage.
87 pub gc_content: f64,
88
89 /// Number of genes predicted in the sequence.
90 pub num_genes: usize,
91
92 /// Sequence identifier from FASTA header.
93 ///
94 /// The first word of the FASTA header line (after '>').
95 pub header: String,
96
97 /// Full sequence description from FASTA header.
98 ///
99 /// Everything after the first word in the FASTA header line.
100 pub description: Option<String>,
101}