Struct rust_htslib::bam::record::CigarString[][src]

pub struct CigarString(pub Vec<Cigar>);
Expand description

A CIGAR string. This type wraps around a Vec<Cigar>.

Example

use rust_htslib::bam::record::{Cigar, CigarString};

let cigar = CigarString(vec![Cigar::Match(100), Cigar::SoftClip(10)]);

// access by index
assert_eq!(cigar[0], Cigar::Match(100));
// format into classical string representation
assert_eq!(format!("{}", cigar), "100M10S");
// iterate
for op in &cigar {
   println!("{}", op);
}

Implementations

Create a CigarStringView from this CigarString at position pos

Calculate the bam cigar from the alignment struct. x is the target string and y is the reference. hard_clip controls how unaligned read bases are encoded in the cigar string. Set to true to use the hard clip (H) code, or false to use soft clip (S) code. See the SAM spec for more details.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Create a CigarString from given &u8.

Example

use rust_htslib::bam::record::*;
use rust_htslib::bam::record::CigarString;
use rust_htslib::bam::record::Cigar::*;
use std::convert::TryFrom;

let cigar_str = "2H10M5X3=2H".as_bytes();
let cigar = CigarString::try_from(cigar_str)
    .expect("Unable to parse cigar string.");
let expected_cigar = CigarString(vec![
    HardClip(2),
    Match(10),
    Diff(5),
    Equal(3),
    HardClip(2),
]);
assert_eq!(cigar, expected_cigar);

The type returned in the event of a conversion error.

Create a CigarString from given &str.

Example

use rust_htslib::bam::record::*;
use rust_htslib::bam::record::CigarString;
use rust_htslib::bam::record::Cigar::*;
use std::convert::TryFrom;

let cigar_str = "2H10M5X3=2H";
let cigar = CigarString::try_from(cigar_str)
    .expect("Unable to parse cigar string.");
let expected_cigar = CigarString(vec![
    HardClip(2),
    Match(10),
    Diff(5),
    Equal(3),
    HardClip(2),
]);
assert_eq!(cigar, expected_cigar);

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.