this is my code: pub fn consensus5ebranch(tracks: TranscriptMap, mode: &str) ->…
- User
this is my code:
pub fn consensus_5e_branch(tracks: TranscriptMap, mode: &str) -> ConsensusMap {
let cmap: Mutex = Mutex::new(HashMap::new());
// iterate over each chromosome in parallel
tracks.into_par_iter().for_each(|(chr, txs)| {
// creates a local-thread accumulator -> Vec
let mut acc: ConsensusTxHash = Vec::new();
for (start, end, exons, introns, , ) in txs {
// find an existing group that overlaps and merge, or create a new group
let group = acc
.iter_mut()
.any(|(group_start, group_end, seen_5e, group_exons)| {
// check if this transcript overlaps with the current group
if start >= group_start && end <= group_end {
_group_start = (_group_start).min(start);
_group_end = (_group_end).max(end);
// group_exons.extend(&exons);
// group_introns.extend(&introns);
true
} else {
false
}
});
if !group {
let mut x: HashSet<(u64, u64)> = HashSet::new();
if let Some(first_exon) = exons.get(&0) {
x.insert(*first_exon);
}
acc.push((start, end, x, exons));
}
}
// HashSet -> Vec to allow sorting
let sort_acc: ConsensusTx = acc
.into_iter()
.map(|(s, e, mut exs, mut ints)| {
let mut vex: Vec<(u64, u64)> = exs.drain().collect::<Vec<_>>();
let mut vint: Vec<(u64, u64)> = ints.drain().collect::<Vec<_>>();
vex.par_sort_unstable();
vint.par_sort_unstable();
let c_vex = if mode == FIVEND {
reduce_ends(vex)
} else {
vex
};
(s, e, c_vex, vint)
})
.collect();
cmap.lock().unwrap().insert(chr, sort_acc);
});
cmap.into_inner().unwrap()
}
I am getting this error:
error[E0277]: the trait bound (u64, u64): Borrow<{integer}> is not satisfied
--> src/track.rs:212:53
|
212 | if let Some(first_exon) = exons.get(&0) {
| --- ^^ the trait Borrow<{integer}> is not implemented for (u64, u64)
| |
| required by a bound introduced by this call
|
= note: required for {integer} to implement Equivalent<(u64, u64)>
note: required by a bound in hashbrown::HashSet::<T, S, A>::get
- Assistant
- User
is this the most efficient and fastest way to extract the min tuple from a HashSet of (u64, u64)?
pub fn get_min(a: HashSet<(u64, u64)>) -> (u64, u64) { let mut min = (u64::MAX, u64::MAX); for (start, end) in a.iter() { if *start < min.0 { min.0 = *start; }
codeif *end < min.1 { min.1 = *end; } } min}
if not, please give me your implementation
- Assistant