pub struct OrphosAnalyzer {
pub config: OrphosConfig,
}Expand description
High-level gene finding analyzer with automatic training.
This struct provides a simplified interface for gene prediction that handles training automatically. It’s the recommended entry point for most users.
Unlike the type-safe Orphos struct, OrphosAnalyzer manages training
internally and provides convenient methods for analyzing sequences from various
sources (files, strings, byte slices).
§Modes
- Single Genome Mode (default): Trains on each sequence individually for optimal accuracy on complete genomes
- Metagenomic Mode: Uses pre-computed models for fragmented sequences
§Examples
§Analyze a sequence string
use orphos_core::{OrphosAnalyzer, config::OrphosConfig};
let mut analyzer = OrphosAnalyzer::new(OrphosConfig::default());
let sequence = "ATGAAACGCATTAGCACCACCATT...";
let results = analyzer.analyze_sequence(sequence, Some("genome1".to_string()))?;
println!("Found {} genes in {} bp sequence",
results.genes.len(),
results.sequence_info.length);§Analyze a FASTA file
use orphos_core::{OrphosAnalyzer, config::OrphosConfig};
let mut analyzer = OrphosAnalyzer::new(OrphosConfig::default());
let results = analyzer.analyze_fasta_file("genome.fasta")?;
for result in results {
println!("Sequence: {}", result.sequence_info.header);
println!(" Genes: {}", result.genes.len());
println!(" GC%: {:.2}", result.sequence_info.gc_content * 100.0);
}§With custom configuration
use orphos_core::{OrphosAnalyzer, config::{OrphosConfig, OutputFormat}};
let config = OrphosConfig {
closed_ends: true,
mask_n_runs: true,
output_format: OutputFormat::Gff,
num_threads: Some(4),
..Default::default()
};
let mut analyzer = OrphosAnalyzer::new(config);Fields§
§config: OrphosConfigConfiguration options for gene prediction
Implementations§
Source§impl OrphosAnalyzer
impl OrphosAnalyzer
Sourcepub const fn new(config: OrphosConfig) -> Self
pub const fn new(config: OrphosConfig) -> Self
Sourcepub fn analyze_fasta_file<P: AsRef<Path>>(
&mut self,
path: P,
) -> Result<Vec<OrphosResults>, OrphosError>
pub fn analyze_fasta_file<P: AsRef<Path>>( &mut self, path: P, ) -> Result<Vec<OrphosResults>, OrphosError>
Analyzes sequences from a FASTA file.
Reads all sequences from the FASTA file and performs gene prediction on each. In single genome mode, each sequence is trained and analyzed independently.
§Arguments
path- Path to the FASTA file
§Returns
A vector of OrphosResults, one for each sequence in the file.
§Errors
Returns OrphosError if:
- The file cannot be read
- The FASTA format is invalid
- Any sequence fails analysis
§Examples
use orphos_core::{OrphosAnalyzer, config::OrphosConfig};
let mut analyzer = OrphosAnalyzer::new(OrphosConfig::default());
let results = analyzer.analyze_fasta_file("genomes.fasta")?;
for (i, result) in results.iter().enumerate() {
println!("Sequence {}: {} genes", i + 1, result.genes.len());
}Sourcepub fn analyze_sequence(
&mut self,
sequence: &str,
header: Option<String>,
) -> Result<OrphosResults, OrphosError>
pub fn analyze_sequence( &mut self, sequence: &str, header: Option<String>, ) -> Result<OrphosResults, OrphosError>
Analyzes a single sequence from a string.
Converts the string sequence to bytes and performs gene prediction. This is a convenience method for analyzing sequences already loaded into memory.
§Arguments
sequence- DNA sequence string (A, T, G, C, N)header- Optional sequence identifier (defaults to “Orphos_Seq_1”)
§Returns
OrphosResults containing genes, training data, and sequence info.
§Errors
Returns OrphosError if:
- The sequence is too short (< 20,000 bp recommended)
- Training fails
- Gene prediction fails
§Examples
use orphos_core::{OrphosAnalyzer, config::OrphosConfig};
let mut analyzer = OrphosAnalyzer::new(OrphosConfig::default());
let sequence = "ATGAAACGCATTAGCACCACCATT...";
let results = analyzer.analyze_sequence(sequence, Some("E. coli K12".to_string()))?;
println!("Analyzed: {}", results.sequence_info.header);
println!("Found {} genes", results.genes.len());
println!("GC content: {:.2}%", results.sequence_info.gc_content * 100.0);Sourcepub fn analyze_sequence_bytes(
&mut self,
sequence: &[u8],
header: String,
description: Option<String>,
) -> Result<OrphosResults, OrphosError>
pub fn analyze_sequence_bytes( &mut self, sequence: &[u8], header: String, description: Option<String>, ) -> Result<OrphosResults, OrphosError>
Analyzes a single sequence from raw bytes.
This is the core analysis method used by other convenience methods. It handles the complete workflow: encoding, training, and gene prediction.
§Arguments
sequence- Raw DNA sequence bytes (ASCII: A, T, G, C, N)header- Sequence identifier for outputdescription- Optional sequence description
§Returns
OrphosResults containing:
- Predicted genes with coordinates and scores
- Training parameters used
- Sequence statistics (length, GC content)
§Errors
Returns OrphosError if:
- The sequence is too short for reliable training
- Sequence encoding fails
- Training or prediction fails
§Examples
use orphos_core::{OrphosAnalyzer, config::OrphosConfig};
let mut analyzer = OrphosAnalyzer::new(OrphosConfig::default());
let sequence = b"ATGAAACGCATTAGCACCACCATT...";
let results = analyzer.analyze_sequence_bytes(
sequence,
"sequence1".to_string(),
Some("E. coli genome".to_string())
)?;
println!("Found {} genes", results.genes.len());Trait Implementations§
Auto Trait Implementations§
impl Freeze for OrphosAnalyzer
impl RefUnwindSafe for OrphosAnalyzer
impl Send for OrphosAnalyzer
impl Sync for OrphosAnalyzer
impl Unpin for OrphosAnalyzer
impl UnwindSafe for OrphosAnalyzer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.