Skip to main content

salmon_core/
mate.rs

1//! Mate/fragment status, mirroring pufferfish's `util::MateStatus`.
2
3use serde::{Deserialize, Serialize};
4
5/// Which part(s) of a fragment a mapping accounts for.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
7pub enum MateStatus {
8    /// only the left/first mate of a pair mapped
9    PairedEndLeft,
10    /// only the right/second mate of a pair mapped
11    PairedEndRight,
12    /// both mates mapped as a proper pair
13    PairedEndPaired,
14    /// single-end read
15    SingleEnd,
16}
17
18impl MateStatus {
19    /// True when only one mate of a pair contributed (an orphan mapping).
20    pub fn is_orphan(&self) -> bool {
21        matches!(self, MateStatus::PairedEndLeft | MateStatus::PairedEndRight)
22    }
23
24    /// True for a properly paired mapping.
25    pub fn is_paired(&self) -> bool {
26        matches!(self, MateStatus::PairedEndPaired)
27    }
28}