pub fn from_samtools_stats<R: io::Read>(
        samtools_stats: &mut R,
    ) -> Result<InsertSize, Box<dyn Error>> {
        let mut rdr = csv::ReaderBuilder::new()
            .delimiter(b'\t')
            .comment(Some(b'#'))
            .has_headers(false)
            .flexible(true)
            .from_reader(samtools_stats);

        let mut insert_size = InsertSize::default();

        for rec in rdr.records() {
            let rec = rec?;
            if &rec[0] == "SN" {
                if &rec[1] == "insert size average:" {
                    insert_size.mean = f64::from_str(&rec[2])?;
                } else if &rec[1] == "insert size standard deviation:" {
                    insert_size.sd = f64::from_str(&rec[2])?;
                    break;
                }
            }
        }

        Ok(insert_size)
    }
/// Obtain insert size from samtools stats output.
Obtain insert size from samtools stats output.
Obtain insert size from samtools stats output .
pub fn from_samtools_stats<R: io::Read>(
        samtools_stats: &mut R,
    ) -> Result<InsertSize, Box<dyn Error>> {
        let mut rdr = csv::ReaderBuilder::new()
            .delimiter(b'\t')
            .comment(Some(b'#'))
            .has_headers(false)
            .flexible(true)
            .from_reader(samtools_stats);
        let mut insert_size = InsertSize::default();
        for rec in rdr.records() {
            let rec = rec?;
            if &rec[0] == "SN" {
                if &rec[1] == "insert size average:" {
                    insert_size.mean = f64::from_str(&rec[2])?;
                } else if &rec[1] == "insert size standard deviation:" {
                    insert_size.sd = f64::from_str(&rec[2])?;
                    break;
                }
            }
        }
        Ok(insert_size)
    }
pub fn from_samtools_stats < R : io :: Read > ( samtools_stats : & mut R , ) -> Result < InsertSize , Box < dyn Error > > { let mut rdr = csv :: ReaderBuilder :: new ( ) . delimiter ( b'\t' ) . comment ( Some ( b'#' ) ) . has_headers ( false ) . flexible ( true ) . from_reader ( samtools_stats ) ; let mut insert_size = InsertSize :: default ( ) ; for rec in rdr . records ( ) { let rec = rec ? ; if & rec [ 0 ] == " " { if & rec [ 1 ] == " " { insert_size . mean = f64 :: from_str ( & rec [ 2 ] ) ? ; } else if & rec [ 1 ] == " " { insert_size . sd = f64 :: from_str ( & rec [ 2 ] ) ? ; break ; } } } Ok ( insert_size ) }
Obtain insert size from samtools stats output.
Obtain insert size from samtools stats output .
samtools_stats
&mut R
samtools_stats
&mut R