pub fn find_tid(tree: &COITree<ExonNode, u32>, ranges: &Vec<(i32, i32)>) -> HashMap<i32, (i32, Strand)> {
    let mut tid_set: HashSet<i32> = HashSet::new(); // stores all the transcripts that are overlapping ALL the ranges of the spliced alignment
    let mut tid_pos: HashMap<i32, (i32, Strand)> = HashMap::new(); // final (tid, pos, strand) to return
    for (i, range) in ranges.iter().enumerate() {
        let range_cov = tree.coverage(range.0, range.1);
        let mut tid_curr: HashSet<i32> = HashSet::new(); // stores all the transcript ids that are covered by the current range 
        log::debug!("range coverage: {:?}", range_cov);
        if range_cov.0 != 0 || range_cov.1 != 0 {
            tree.query(range.0, range.1, |node| {
                log::debug!("query for {} {} => {}", range.0, range.1, node.metadata);
                // TODO: for now we are dropping overhanging alignments. This can be improved.
                if node.metadata.start <= range.0 && node.metadata.end >= range.1 {
                    // add to tid_curr
                    if  ranges.len() == 1 || // if there is only a single range, so no need to check splicing boundaries. Otherwise, obey splicing!
                    (i == 0 && range.1 == node.metadata.end) ||
                    (i == ranges.len() - 1 && range.0 == node.metadata.start) || 
                    (i > 0 && i < ranges.len() - 1 && range.0 == node.metadata.start && range.1 == node.metadata.end) {
                        log::debug!("keeping");
                        tid_curr.insert(node.metadata.tid);
                    }
                    // keep track of the alignment position and strand
                    if i == 0 && node.metadata.strand == Strand::Forward { // first range of the spliced alignment 
                        log::debug!("inserting => tid:{}, strand:{}, pos:{} = start:{} - tpos_start:{}", 
                            node.metadata.tid, 
                            node.metadata.strand, 
                            node.metadata.start - node.metadata.tpos_start, 
                            node.metadata.start, 
                            node.metadata.tpos_start);
                        tid_pos.insert(node.metadata.tid, (node.metadata.start - node.metadata.tpos_start, Strand::Forward));
                    } else if i == ranges.len() - 1 && node.metadata.strand == Strand::Reverse {
                        log::debug!("inserting => tid:{}, strand:{}, pos:{} = end:{} - tpos_start:{} + 1", 
                            node.metadata.tid, 
                            node.metadata.strand, 
                            node.metadata.end + node.metadata.tpos_start + 1, 
                            node.metadata.end, 
                            node.metadata.tpos_start);
                        tid_pos.insert(node.metadata.tid, (node.metadata.end + node.metadata.tpos_start + 1, Strand::Reverse));
                    }
                }
            });
            log::debug!("found coverage: {:?}", range_cov);
        }
        if i ==0 {
            tid_set = tid_curr;
        } else {
            tid_set = &tid_set & &tid_curr; // only transcripts that overlap ALL the ranges will be reported, hence the intersection
        }
    }
    // 
    let mut tid_to_remove: HashSet<i32> = HashSet::new();
    for (k, _v) in &tid_pos {
        if tid_set.contains(k) == false {
            tid_to_remove.insert(*k);
        }
    }
    for tid in tid_to_remove {
        tid_pos.remove(&tid);
    }
    for (k, _v) in &tid_pos {
        log::debug!("overlapping tid: {}", k);
    }
    return tid_pos;
}
/// Given ranges of genomic bases where a spliced alignment is mapped against, returns a map of transcripts that are covered by the projected alignments.
/// For each transcript, the position and orientation of the alignment is also returned.
///
/// # Arguments
///
/// * `tree` - INPUT. The COITree containing exon coordinates of the target chromosome
/// * `ranges` - INPUT. The ranges of genomic bases for the input spliced alignment
Given ranges of genomic bases where a spliced alignment is mapped against, returns a map of transcripts that are covered by the projected alignments.
For each transcript, the position and orientation of the alignment is also returned.
Given ranges of genomic bases where a spliced alignment is mapped against returns a map of transcripts that are covered by the projected alignments . For each transcript the position and orientation of the alignment is also returned .
pub fn find_tid(tree: &COITree<ExonNode, u32>, ranges: &Vec<(i32, i32)>) -> HashMap<i32, (i32, Strand)> {
    let mut tid_set: HashSet<i32> = HashSet::new(); // stores all the transcripts that are overlapping ALL the ranges of the spliced alignment
    let mut tid_pos: HashMap<i32, (i32, Strand)> = HashMap::new(); // final (tid, pos, strand) to return
    for (i, range) in ranges.iter().enumerate() {
        let range_cov = tree.coverage(range.0, range.1);
        let mut tid_curr: HashSet<i32> = HashSet::new(); // stores all the transcript ids that are covered by the current range 
        log::debug!("range coverage: {:?}", range_cov);
        if range_cov.0 != 0 || range_cov.1 != 0 {
            tree.query(range.0, range.1, |node| {
                log::debug!("query for {} {} => {}", range.0, range.1, node.metadata);
                // TODO: for now we are dropping overhanging alignments. This can be improved.
                if node.metadata.start <= range.0 && node.metadata.end >= range.1 {
                    // add to tid_curr
                    if  ranges.len() == 1 || // if there is only a single range, so no need to check splicing boundaries. Otherwise, obey splicing!
                    (i == 0 && range.1 == node.metadata.end) ||
                    (i == ranges.len() - 1 && range.0 == node.metadata.start) || 
                    (i > 0 && i < ranges.len() - 1 && range.0 == node.metadata.start && range.1 == node.metadata.end) {
                        log::debug!("keeping");
                        tid_curr.insert(node.metadata.tid);
                    }
                    // keep track of the alignment position and strand
                    if i == 0 && node.metadata.strand == Strand::Forward { // first range of the spliced alignment 
                        log::debug!("inserting => tid:{}, strand:{}, pos:{} = start:{} - tpos_start:{}", 
                            node.metadata.tid, 
                            node.metadata.strand, 
                            node.metadata.start - node.metadata.tpos_start, 
                            node.metadata.start, 
                            node.metadata.tpos_start);
                        tid_pos.insert(node.metadata.tid, (node.metadata.start - node.metadata.tpos_start, Strand::Forward));
                    } else if i == ranges.len() - 1 && node.metadata.strand == Strand::Reverse {
                        log::debug!("inserting => tid:{}, strand:{}, pos:{} = end:{} - tpos_start:{} + 1", 
                            node.metadata.tid, 
                            node.metadata.strand, 
                            node.metadata.end + node.metadata.tpos_start + 1, 
                            node.metadata.end, 
                            node.metadata.tpos_start);
                        tid_pos.insert(node.metadata.tid, (node.metadata.end + node.metadata.tpos_start + 1, Strand::Reverse));
                    }
                }
            });
            log::debug!("found coverage: {:?}", range_cov);
        }
        if i ==0 {
            tid_set = tid_curr;
        } else {
            tid_set = &tid_set & &tid_curr; // only transcripts that overlap ALL the ranges will be reported, hence the intersection
        }
    }
    // 
    let mut tid_to_remove: HashSet<i32> = HashSet::new();
    for (k, _v) in &tid_pos {
        if tid_set.contains(k) == false {
            tid_to_remove.insert(*k);
        }
    }
    for tid in tid_to_remove {
        tid_pos.remove(&tid);
    }
    for (k, _v) in &tid_pos {
        log::debug!("overlapping tid: {}", k);
    }
    return tid_pos;
}
pub fn find_tid ( tree : & COITree < ExonNode , u32 > , ranges : & Vec < ( i32 , i32 ) > ) -> HashMap < i32 , ( i32 , Strand ) > { let mut tid_set : HashSet < i32 > = HashSet :: new ( ) ; // stores all the transcripts that are overlapping ALL the ranges of the spliced alignment let mut tid_pos : HashMap < i32 , ( i32 , Strand ) > = HashMap :: new ( ) ; // final (tid, pos, strand) to return for ( i , range ) in ranges . iter ( ) . enumerate ( ) { let range_cov = tree . coverage ( range . 0 , range . 1 ) ; let mut tid_curr : HashSet < i32 > = HashSet :: new ( ) ; // stores all the transcript ids that are covered by the current range  log :: debug ! ( " " range_cov ) ; if range_cov . 0 != 0 || range_cov . 1 != 0 { tree . query ( range . 0 , range . 1 , | node | { log :: debug ! ( " " range 0 range 1 node metadata ) ; // TODO: for now we are dropping overhanging alignments. This can be improved. if node . metadata . start <= range . 0 && node . metadata . end >= range . 1 { // add to tid_curr if ranges . len ( ) == 1 || // if there is only a single range, so no need to check splicing boundaries. Otherwise, obey splicing! ( i == 0 && range . 1 == node . metadata . end ) || ( i == ranges . len ( ) - 1 && range . 0 == node . metadata . start ) || ( i > 0 && i < ranges . len ( ) - 1 && range . 0 == node . metadata . start && range . 1 == node . metadata . end ) { log :: debug ! ( " " ) ; tid_curr . insert ( node . metadata . tid ) ; } // keep track of the alignment position and strand if i == 0 && node . metadata . strand == Strand :: Forward { // first range of the spliced alignment  log :: debug ! ( " " node metadata tid node metadata strand node metadata start node metadata tpos_start node metadata start node metadata tpos_start ) ; tid_pos . insert ( node . metadata . tid , ( node . metadata . start - node . metadata . tpos_start , Strand :: Forward ) ) ; } else if i == ranges . len ( ) - 1 && node . metadata . strand == Strand :: Reverse { log :: debug ! ( " " node metadata tid node metadata strand node metadata end node metadata tpos_start 1 node metadata end node metadata tpos_start ) ; tid_pos . insert ( node . metadata . tid , ( node . metadata . end + node . metadata . tpos_start + 1 , Strand :: Reverse ) ) ; } } } ) ; log :: debug ! ( " " range_cov ) ; } if i == 0 { tid_set = tid_curr ; } else { tid_set = & tid_set & & tid_curr ; // only transcripts that overlap ALL the ranges will be reported, hence the intersection } } //  let mut tid_to_remove : HashSet < i32 > = HashSet :: new ( ) ; for ( k , _v ) in & tid_pos { if tid_set . contains ( k ) == false { tid_to_remove . insert ( * k ) ; } } for tid in tid_to_remove { tid_pos . remove ( & tid ) ; } for ( k , _v ) in & tid_pos { log :: debug ! ( " " k ) ; } return tid_pos ; }
Given ranges of genomic bases where a spliced alignment is mapped against, returns a map of transcripts that are covered by the projected alignments.
Given ranges of genomic bases where a spliced alignment is mapped against returns a map of transcripts that are covered by the projected alignments .
tree
&COITree<ExonNode, u32>
ranges
&Vec<(i32, i32)>