1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Find the intersection between two slices of `Feature` objects.
use crateFeature;
use HashSet;
/// Computes the size of the intersection of two slices of `&Feature` based on their IDs.
///
/// This function takes two slices of references to `Feature` objects and calculates
/// the number of `Feature` objects that are present in both input slices. The comparison
/// is performed using the unique `id` of each `Feature`.
///
/// # Arguments
///
/// - `genes1`: A slice of references to `Feature` objects.
/// - `genes2`: Another slice of references to `Feature` objects.
///
/// # Returns
///
/// The size of the intersection between the two input slices, as a `usize`.
///
/// # Examples
///
/// ```rust
/// use dual_threshold_optimization::collections::Feature;
/// use dual_threshold_optimization::stat_operations::intersect_genes;
///
/// let gene1 = Feature::from("gene1");
/// let gene2 = Feature::from("gene2");
/// let gene3 = Feature::from("gene3");
/// let gene4 = Feature::from("gene4");
///
/// let genes1 = vec![gene1.clone(), gene2.clone(), gene3.clone()];
/// let genes2 = vec![gene2.clone(), gene3.clone(), gene4.clone()];
///
/// let intersection_size = intersect_genes(&genes1, &genes2);
///
/// assert_eq!(intersection_size, 2);
/// ```