Skip to main content

Crate read_structure

Crate read_structure 

Source
Expand description

Read structures is a library for working with strings that describe how the bases in a sequencing run should be allocated into logical reads.

Each read structure is made up of one or more read segments which are in turn a segment type.

For more details see here

§Example

Parsing a complex read structure.

use std::str::FromStr;
use read_structure::ReadStructure;

let rs = ReadStructure::from_str("76T8B8B76T").unwrap();
let templates: String = rs.templates().map(|s| s.to_string()).collect();
assert_eq!(templates, "76T76T");

Extracting segments from an actual read based on the read structure:

use std::str::FromStr;
use read_structure::{ReadStructure, SegmentType, SkipHandling};

let bases = b"\
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGGGGGGGGCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT";
let quals = &[b'I'; 168][..];
let rs = ReadStructure::from_str("76T8B8B76T").unwrap();

let templates: Vec<&[u8]> = rs.extract(bases, quals, SkipHandling::Exclude)
    .unwrap()
    .filter(|(seg, _, _)| seg.kind == SegmentType::Template)
    .map(|(_, bases, _)| bases)
    .collect();

assert_eq!(templates, vec![
    &b"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"[..],
    &b"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"[..],
]);

Structs§

ErrorMessageParts
Helper struct for isolating the erroneous portion of a string.
ExtractedSegments
Iterator returned by ReadStructure::extract.
ReadSegment
A single segment of a read structure: a segment type and an optional fixed length.
ReadStructure
A read structure made up of one or more ReadSegments.
SegmentTypeIter
An iterator over the variants of SegmentType

Enums§

ReadStructureError
SegmentType
The SegmentType type. See the module level documentation for more.
SkipHandling
Controls whether SegmentType::Skip segments are emitted by ReadStructure::extract.

Constants§

ANY_LENGTH_BYTE
A character that can be put in place of a number in a read structure to mean “1 or more bases”.
ANY_LENGTH_BYTE_SLICE
Defined for efficiency, same as ANY_LENGTH_BYTE.
ANY_LENGTH_STR
A string that can be put in place of a number in a read structure to mean “1 or more bases”.