Skip to content

Commit

Permalink
wip tryinto minhash for signature
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Oct 12, 2024
1 parent 62f03eb commit e7e2ae5
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/core/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,28 @@ impl PartialEq for Signature {
}
}

impl TryInto<KmerMinHash> for Signature {
type Error = crate::Error;

fn try_into(self) -> Result<KmerMinHash, Self::Error> {
match self.signatures.len() {
1 => self
.signatures
.into_iter()
.find_map(|sk| {
if let Sketch::MinHash(mh) = sk {
Some(mh)
} else {
None
}
})
.ok_or_else(|| todo!("error, no minhash found")),
0 => todo!("error, empty signature"),
2.. => todo!("Multiple sketches found! Please run select first."),
}
}
}

#[cfg(test)]
mod test {
use std::fs::File;
Expand Down

0 comments on commit e7e2ae5

Please sign in to comment.