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::convert::TryFrom;
use std::str::FromStr;
use read_structure::{
    ReadStructure,
    SegmentType,
};
let read_sequence = b"\
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGGGGGGGGCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"
.to_vec();
let kind_of_interest = SegmentType::Template;
let rs = ReadStructure::from_str("76T8B8B76T").unwrap();

let mut sections = vec![];
for segment in rs.segments_by_type(kind_of_interest) {
    sections.push(segment.extract_bases(read_sequence.as_slice()).unwrap())
}
assert_eq!(sections, vec![
    b"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
    b"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT"
]);

Structs

Enums

Constants