check this code: pub fn cmp_introns( introns: &Vec<(u32, u32)>, exons: &Vec<&(u32,…
- User
check this code:
pub fn cmp_introns( introns: &Vec<(u32, u32)>, exons: &Vec<&(u32, u32)>, ) -> Result<(String, Status), anyhow::Error> { let mut status = Status::IntronRetentionStatus::NoIntronRetention; let mut irs: Vec = vec![]; let mut n: u32 = 0;
for (k, (start, end)) in introns.iter().enumerate() { for (i, exon) in exons.iter().enumerate() { if start > &exon.0 && end < &exon.1 { irs.push(k as u32); n += 1; } } } if n > 0 { status = Status::IntronRetentionStatus::IntronRetention; } let line = format!("{}\t{:?}", n, irs); bail!("Error: {:?}", line); Ok((line, status))}
is it anything wrong?
- Assistant
- User
implement this: 2. Error Handling with bail!: You are unconditionally using bail! to return an error at the end of your function, which means that this function will never successfully return Ok((line, status)). If your intention is to use bail! under certain conditions only, make sure to place it inside a conditional branch.
- Assistant
- User
help me fixing this:
pub fn send_tx( exons: &Vec<(u32, u32)>, introns: &Vec<(u32, u32)>, tx: Vec<&(u32, u32)>, id: Arc, mode: &str, ) -> MapInfo { let Ok(line, status): Result<(String, Status), Error> = match mode { INTRON => cmp_introns(introns, &tx).expect("Error in cmp_introns"), // FIVEND => bif::fivend::map_5_prime(exons, &tx), // THREEND => {} _ => bail!("Invalid mode"), };
MapInfo::new(id, line, status)}
- Assistant
- User
help me:
pub fn send_tx( exons: &Vec<(u32, u32)>, introns: &Vec<(u32, u32)>, tx: Vec<&(u32, u32)>, id: Arc, mode: &str, ) -> MapInfo { let info = match mode { INTRON => cmp_introns(introns, &tx), // FIVEND => bif::fivend::map_5_prime(exons, &tx), // THREEND => {} _ => , };
match info { Ok((line, status)) => MapInfo::new(id, line, status), Err(e) => { error!("Error: {}", e); std::process::exit(1); } }}
- Assistant
- User
i do not want to return a result from send_tx
- Assistant