forked from COMBINE-lab/splitp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start of an ambient RNA identification process.
- Loading branch information
Showing
8 changed files
with
33,695 additions
and
2,408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use std::hash::{Hash, Hasher}; | ||
use core::fmt; | ||
use std::cmp::{max, Ord}; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
pub struct GeneUmiHash( pub usize, pub u64); | ||
impl PartialEq for GeneUmiHash { | ||
fn eq(&self, other: &Self) -> bool { | ||
return (self.0 == other.0) && (self.1 == other.1) | ||
} | ||
} | ||
|
||
|
||
impl Ord for GeneUmiHash { | ||
fn cmp(&self, other: &Self) -> std::cmp::Ordering { | ||
// Compare based on the first field (usize) first | ||
match self.0.cmp(&other.0) { | ||
std::cmp::Ordering::Equal => { | ||
// If the first fields are equal, compare based on the second field (u64) | ||
self.1.cmp(&other.1) | ||
} | ||
ordering => ordering, | ||
} | ||
} | ||
} | ||
|
||
impl PartialOrd for GeneUmiHash { | ||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | ||
Some(self.cmp(other)) | ||
} | ||
} | ||
|
||
impl Eq for GeneUmiHash {} | ||
|
||
impl Hash for GeneUmiHash { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.0.hash(state); | ||
self.1.hash(state); | ||
} | ||
} | ||
|
||
// Implementing Display trait for GeneUmiHash | ||
impl fmt::Display for GeneUmiHash { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
write!(f, "GeneUmiHash (gene_id: {}, umi: {})", self.0, self.1 ) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// singlecelldata/cell_data/mod.rs | ||
|
||
pub mod cell_data; | ||
pub mod gene_umi_hash; | ||
|
||
pub use cell_data::CellData as CellData; | ||
pub use gene_umi_hash::GeneUmiHash as GeneUmiHash; | ||
|
Oops, something went wrong.