OrphosAnalyzer

Struct OrphosAnalyzer 

Source
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: OrphosConfig

Configuration options for gene prediction

Implementations§

Source§

impl OrphosAnalyzer

Source

pub const fn new(config: OrphosConfig) -> Self

Creates a new analyzer with the specified configuration.

§Arguments
  • config - Configuration options for gene prediction
§Examples
use orphos_core::{OrphosAnalyzer, config::OrphosConfig};

let analyzer = OrphosAnalyzer::new(OrphosConfig::default());
Source

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());
}
Source

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);
Source

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 output
  • description - 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§

Source§

impl Debug for OrphosAnalyzer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V