pub struct Contig<R, S> { /* private fields */ }
Expand description

Contiguous sequence region on a particular, named sequence (e.g. a chromosome)

Parameterized over the type of the reference sequence identifier and over the strandedness of the position.

The display format for a Contig is chr:start-end(+/-/.). The boundaries are given as a half-open 0-based interval, like the Rust Range and BED format.

use bio_types::annot::contig::Contig;
use bio_types::strand::ReqStrand;
let tma19 = Contig::new("chrXI".to_owned(), 334412, (334916 - 334412), ReqStrand::Reverse);
let tma19_str = tma19.to_string();
assert_eq!(tma19_str, "chrXI:334412-334916(-)");
let tma19_str_loc = tma19_str.parse()?;
assert_eq!(tma19, tma19_str_loc);

Implementations

Construct a new sequence contig location

use std::rc::Rc;
use bio_types::annot::contig::Contig;
use bio_types::strand::ReqStrand;
let chr = Rc::new("chrX".to_owned());
let tma22 = Contig::new(chr, 461829, 462426 - 461829, ReqStrand::Forward);

Construct a new sequence contig location from a starting position and length.

In general, the starting position must have a “strandedness”, and reverse-strand starting positions will extend towards lower coordinates from the starting position.

use bio_types::annot::contig::Contig;
use bio_types::annot::pos::Pos;
use bio_types::strand::ReqStrand;

let tma22_first = Pos::new("chrX".to_string(), 461829, ReqStrand::Forward);
let tma22 = Contig::with_first_length(&tma22_first, 462426 - 461829)?;
assert_eq!(tma22.to_string(), "chrX:461829-462426(+)");

let tma19_first = Pos::new("chrXI".to_string(), 335015, ReqStrand::Reverse);
let tma19 = Contig::with_first_length(&tma19_first, 335016 - 334412)?;
assert_eq!(tma19.to_string(), "chrXI:334412-335016(-)");

Convert into a stranded sequence location on the specified strand

Extend the annotation by dist in the upstream direction on the annotated strand.

Arguments
  • dist specifies the offset for sliding the position. The left, 5’-most end of the contig will expand for forward-strand annotations and the right, 3’-most end will expand for reverse-strand annotations.
use bio_types::annot::contig::Contig;
use bio_types::strand::ReqStrand;
let mut tma22 = Contig::new("chrX".to_owned(), 461829, 462426 - 461829, ReqStrand::Forward);
tma22.extend_upstream(100);
assert_eq!(tma22.to_string(), "chrX:461729-462426(+)");
let mut tma19 = Contig::new("chrXI".to_owned(), 334412, 334916 - 334412, ReqStrand::Reverse);
tma19.extend_upstream(100);
assert_eq!(tma19.to_string(), "chrXI:334412-335016(-)");

Extend the annotation by dist in the downstream direction on the annotated strand.

Arguments
  • dist specifies the offset for sliding the position. The right, 3’-most end of the contig will expand for forward-strand annotations and the left, 5’-most end will expand for reverse-strand annotations.
use bio_types::annot::contig::Contig;
use bio_types::strand::ReqStrand;
let mut tma22 = Contig::new("chrX".to_owned(), 461829, 462426 - 461829, ReqStrand::Forward);
tma22.extend_downstream(100);
assert_eq!(tma22.to_string(), "chrX:461829-462526(+)");
let mut tma19 = Contig::new("chrXI".to_owned(), 334412, 334916 - 334412, ReqStrand::Reverse);
tma19.extend_downstream(100);
assert_eq!(tma19.to_string(), "chrXI:334312-334916(-)");

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

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

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

Name of the reference sequence (chromosome name, etc.)

Starting (lowest, left-most, 5’-most) position on the reference sequence (0-based). Read more

Length of the region

Strand of the position

Map a sequence position on a reference sequence into a relative position within an annotated location on the reference sequence. Read more

Map a relative position within an annotated location out of that location onto the enclosing reference sequence. Read more

Contiguous sequence location that fully covers the location.

The first Pos in a location, on the annotated strand. Read more

The last Pos in a location, on the annotated strand. Read more

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

This method tests for !=.

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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

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

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.