pub fn resolve_features(features: &[Feature], read_len: i32) -> Cigar {
    use noodles_sam::record::cigar::{op::Kind, Op};

    let mut ops = Vec::new();
    let mut i = 1;

    for feature in features {
        if feature.position() > i {
            let len = feature.position() - i;
            let op = Op::new(Kind::Match, len as u32);
            ops.push(op);

            i = feature.position();
        }

        let (kind, len) = match feature {
            Feature::Substitution(..) => (Kind::Match, 1),
            Feature::Insertion(_, bases) => (Kind::Insertion, bases.len() as i32),
            Feature::Deletion(_, len) => (Kind::Deletion, *len),
            Feature::InsertBase(..) => (Kind::Insertion, 1),
            Feature::ReferenceSkip(_, len) => (Kind::Skip, *len),
            Feature::SoftClip(_, bases) => (Kind::SoftClip, bases.len() as i32),
            Feature::Padding(_, len) => (Kind::Pad, *len),
            Feature::HardClip(_, len) => (Kind::HardClip, *len),
            _ => continue,
        };

        let op = Op::new(kind, len as u32);
        ops.push(op);

        if matches!(
            kind,
            Kind::Match | Kind::Insertion | Kind::SoftClip | Kind::SeqMatch | Kind::SeqMismatch
        ) {
            i += len;
        }
    }

    if i <= read_len {
        let len = read_len - i + 1;
        let op = Op::new(Kind::Match, len as u32);
        ops.push(op);
    }

    Cigar::from(ops)
}
/// Resolves the read features as CIGAR operations.
Resolves the read features as CIGAR operations.
Resolves the read features as CIGAR operations .
pub fn resolve_features(features: &[Feature], read_len: i32) -> Cigar {
    use noodles_sam::record::cigar::{op::Kind, Op};
    let mut ops = Vec::new();
    let mut i = 1;
    for feature in features {
        if feature.position() > i {
            let len = feature.position() - i;
            let op = Op::new(Kind::Match, len as u32);
            ops.push(op);
            i = feature.position();
        }
        let (kind, len) = match feature {
            Feature::Substitution(..) => (Kind::Match, 1),
            Feature::Insertion(_, bases) => (Kind::Insertion, bases.len() as i32),
            Feature::Deletion(_, len) => (Kind::Deletion, *len),
            Feature::InsertBase(..) => (Kind::Insertion, 1),
            Feature::ReferenceSkip(_, len) => (Kind::Skip, *len),
            Feature::SoftClip(_, bases) => (Kind::SoftClip, bases.len() as i32),
            Feature::Padding(_, len) => (Kind::Pad, *len),
            Feature::HardClip(_, len) => (Kind::HardClip, *len),
            _ => continue,
        };
        let op = Op::new(kind, len as u32);
        ops.push(op);
        if matches!(
            kind,
            Kind::Match | Kind::Insertion | Kind::SoftClip | Kind::SeqMatch | Kind::SeqMismatch
        ) {
            i += len;
        }
    }
    if i <= read_len {
        let len = read_len - i + 1;
        let op = Op::new(Kind::Match, len as u32);
        ops.push(op);
    }
    Cigar::from(ops)
}
pub fn resolve_features ( features : & [ Feature ] , read_len : i32 ) -> Cigar { use noodles_sam :: record :: cigar :: { op :: Kind , Op } ; let mut ops = Vec :: new ( ) ; let mut i = 1 ; for feature in features { if feature . position ( ) > i { let len = feature . position ( ) - i ; let op = Op :: new ( Kind :: Match , len as u32 ) ; ops . push ( op ) ; i = feature . position ( ) ; } let ( kind , len ) = match feature { Feature :: Substitution ( .. ) => ( Kind :: Match , 1 ) , Feature :: Insertion ( _ , bases ) => ( Kind :: Insertion , bases . len ( ) as i32 ) , Feature :: Deletion ( _ , len ) => ( Kind :: Deletion , * len ) , Feature :: InsertBase ( .. ) => ( Kind :: Insertion , 1 ) , Feature :: ReferenceSkip ( _ , len ) => ( Kind :: Skip , * len ) , Feature :: SoftClip ( _ , bases ) => ( Kind :: SoftClip , bases . len ( ) as i32 ) , Feature :: Padding ( _ , len ) => ( Kind :: Pad , * len ) , Feature :: HardClip ( _ , len ) => ( Kind :: HardClip , * len ) , _ => continue , } ; let op = Op :: new ( kind , len as u32 ) ; ops . push ( op ) ; if matches ! ( kind Kind Match Kind Insertion Kind SoftClip Kind SeqMatch Kind SeqMismatch ) { i += len ; } } if i <= read_len { let len = read_len - i + 1 ; let op = Op :: new ( Kind :: Match , len as u32 ) ; ops . push ( op ) ; } Cigar :: from ( ops ) }
Resolves the read features as CIGAR operations.
Resolves the read features as CIGAR operations .
features
&[Feature]
read_len
i32
features
&[Feature]
read_len
i32