1use num_traits::{PrimInt, Signed, ToPrimitive, Zero};
2use std::{hash::Hash, str::FromStr};
3
4pub trait PositionType:
5 PrimInt
6 + Signed
7 + Hash
8 + Copy
9 + radsort::Key + Copy
10 + PartialOrd
11 + ToPrimitive
12 + Zero
13 + std::fmt::Display
14{
15}
16impl<T> PositionType for T where
17 T: PrimInt
18 + Signed
19 + Hash
20 + Copy
21 + radsort::Key + Copy
22 + PartialOrd
23 + ToPrimitive
24 + Zero
25 + std::fmt::Display
26{
27}
28pub trait GroupType: PrimInt + Hash + Copy + radsort::Key + Zero {}
29impl<T> GroupType for T where T: PrimInt + Hash + Copy + radsort::Key + Zero {}
30
31pub struct GenomicData<C: GroupType, P: PositionType> {
32 pub chroms: Vec<C>,
33 pub starts: Vec<P>,
34 pub ends: Vec<P>,
35 pub strands: Option<Vec<bool>>,
36}
37
38#[derive(Debug, Clone)]
39pub struct MinInterval<T: PositionType> {
40 pub start: T,
41 pub end: T,
42 pub idx: u32,
43}
44
45#[derive(Debug, Clone)]
46pub struct StrandInterval<T: PositionType> {
47 pub start: T,
48 pub end: T,
49 pub idx: u32,
50 pub fwd: bool,
51}
52
53#[derive(Debug, Clone)]
54pub struct Interval<C: GroupType, T: PositionType> {
55 pub group: C,
56 pub start: T,
57 pub end: T,
58 pub idx: u32,
59}
60
61#[derive(Debug, Clone, Hash)]
62pub struct EventUsize {
63 pub chr: i64,
64 pub pos: i64,
65 pub is_start: bool,
66 pub first_set: bool,
67 pub idx: usize,
68}
69#[derive(Debug, Clone, Hash)]
75pub struct Event<C: GroupType, T: PositionType> {
76 pub chr: C,
77 pub pos: T,
78 pub is_start: bool,
79 pub first_set: bool,
80 pub idx: u32,
81}
82
83#[derive(Debug, Clone, Hash)]
84pub struct MaxEvent<C: GroupType, T: PositionType> {
85 pub chr: C,
86 pub pos: T,
87 pub start: T,
88 pub end: T,
89 pub is_start: bool,
90 pub first_set: bool,
91 pub idx: u32,
92}
93
94#[derive(Debug, Clone, Hash)]
95pub struct MinEvent<C: GroupType, T: PositionType> {
96 pub chr: C,
97 pub pos: T,
98 pub idx: u32,
99}
100
101#[derive(Debug, Clone, Hash)]
102pub struct GroupStruct<C: GroupType> {
103 pub chr: C,
104 pub idx: u32,
105}
106
107#[derive(Debug, Clone, Hash)]
108pub struct OverlapPair {
109 pub idx: u32,
110 pub idx2: u32,
111}
112
113#[derive(Debug, Clone, Hash, Copy)]
114pub struct Nearest<T: PositionType> {
115 pub distance: T,
116 pub idx: u32,
117 pub idx2: u32,
118}
119
120#[derive(Debug, Clone)]
121pub struct SplicedSubsequenceInterval<G: GroupType, T: PositionType> {
122 pub chr: G,
124
125 pub start: T,
127
128 pub end: T,
130
131 pub idx: u32,
132
133 pub forward_strand: bool,
134
135 pub temp_length: T,
137
138 pub temp_cumsum: T,
140}
141
142#[derive(Clone)]
144pub struct SubsequenceInterval {
145 pub group_id: i64, pub start: i64, pub end: i64, pub idx: i64, pub forward_strand: bool, }
151
152pub struct GenericEvent<C: GroupType, T: PositionType> {
153 pub chr: C,
154 pub pos: T,
155 pub is_start: bool,
156 pub first_set: bool,
157 pub idx: u32,
158}
159
160#[derive(Copy, Clone, Debug, PartialEq, Eq)]
161pub enum OverlapType {
162 First,
163 Last,
164 All,
165}
166
167impl FromStr for OverlapType {
168 type Err = &'static str;
169
170 fn from_str(s: &str) -> Result<Self, Self::Err> {
171 match s.to_lowercase().as_str() {
172 "all" => Ok(OverlapType::All),
173 "first" => Ok(OverlapType::First),
174 "last" => Ok(OverlapType::Last),
175 _ => Err("Invalid direction string"),
176 }
177 }
178}
179
180pub struct SplicedRecord<T> {
181 pub idx: u32,
182 pub start: T,
183 pub end: T,
184 pub strand: bool,
185}