// create a TE alignment from a tabular::Data (skip if it doesn't meet criteria)
// we have 2 criteria:
// 1. SAM flag does not "&" with 4 (4 means unmapped)
// 2. read aligns at the start or end of the transposon
create a TE alignment from a tabular::Data (skip if it doesn't meet criteria)
we have 2 criteria:
1. SAM flag does not "&" with 4 (4 means unmapped)
2. read aligns at the start or end of the transposon
create a TE alignment from a tabular :: Data ( skip if it doesn ' t meet criteria ) we have 2 criteria : 1 . SAM flag does not " & " with 4 ( 4 means unmapped ) 2 . read aligns at the start or end of the transposon
pub fn create(data: Data, transposon_lengths: &HashMap<String, u64>) -> Result<TeAlignment> {
        if !TeAlignment::is_mapped(data.get("FLAG")?) {
            bail!("unmapped read");
        }
        let qname = data.get("QNAME")?;
        let rname = data.get("RNAME")?;
        let pos: u64 = data.get("POS")?.parse()?;
        let cigar_str = data.get("CIGAR")?;
        let seq = data.get("SEQ")?;
        let split_read =
            TeAlignment::validate_cigar_string(cigar_str, pos, &rname, transposon_lengths)?;
        let s_size = split_read.s();
        let m_size = split_read.m();
        let is_sm: bool;
        let is_start: bool;
        match split_read {
            SplitReadTE::SM(_) => {
                is_sm = true;
                is_start = true;
            }
            SplitReadTE::MS(_) => {
                is_sm = false;
                is_start = false;
            }
        }
        Ok(TeAlignment {
            qname: qname,
            rname: rname,
            m_size: m_size,
            s_size: s_size,
            is_sm: is_sm,
            is_start: is_start,
            seq: seq,
        })
    }
pub fn create ( data : Data , transposon_lengths : & HashMap < String , u64 > ) -> Result < TeAlignment > { if ! TeAlignment :: is_mapped ( data . get ( " " ) ? ) { bail ! ( " " ) ; } let qname = data . get ( " " ) ? ; let rname = data . get ( " " ) ? ; let pos : u64 = data . get ( " " ) ? . parse ( ) ? ; let cigar_str = data . get ( " " ) ? ; let seq = data . get ( " " ) ? ; let split_read = TeAlignment :: validate_cigar_string ( cigar_str , pos , & rname , transposon_lengths ) ? ; let s_size = split_read . s ( ) ; let m_size = split_read . m ( ) ; let is_sm : bool ; let is_start : bool ; match split_read { SplitReadTE :: SM ( _ ) => { is_sm = true ; is_start = true ; } SplitReadTE :: MS ( _ ) => { is_sm = false ; is_start = false ; } } Ok ( TeAlignment { qname : qname , rname : rname , m_size : m_size , s_size : s_size , is_sm : is_sm , is_start : is_start , seq : seq , } ) }
create a TE alignment from a tabular::Data (skip if it doesn't meet criteria)
we have 2 criteria:
1.
create a TE alignment from a tabular :: Data ( skip if it doesn ' t meet criteria ) we have 2 criteria : 1 .
data
Data
transposon_lengths
&HashMap<String, u64>