[−][src]Struct twobit::TwoBitFile
Read data from a 2bit file
Usage:
extern crate twobit; use twobit::TwoBitFile; let enable_softmask=true; //set to false to enforce upper case sequences let tb = TwoBitFile::open("assets/foo.2bit", enable_softmask).unwrap(); let chromosome_lengths = tb.chroms(); assert_eq!(chromosome_lengths["chr1"], 150); assert_eq!(chromosome_lengths["chr2"], 100);
2bit files offer two types of masks: N masks (aka hard masks) for unknown or arbitrary nucleotides and soft masks for lower-case nucleotides (e.g. "t" instead of "T").
let expected_seq = "NNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTagctagctGATC"; // some lower and some upper case assert_eq!(tb.sequence("chr1",24,74).unwrap(), expected_seq);
It is not possible to disable hard masks but you can disable soft masks:
let enable_softmask=false; let tb_nosoft = TwoBitFile::open("assets/foo.2bit", enable_softmask).unwrap(); let expected_seq = "NNNNNNNNNNNNNNNNNNNNNNNNNNACGTACGTACGTAGCTAGCTGATC"; // all upper case assert_eq!(tb_nosoft.sequence("chr1",24,74).unwrap(), expected_seq);
There are 2 variants for every sequence-related method:
- Those that request information on parts of a chromosome
- Those that request information on a complete chromosome
The partial requests require you to provide a start (0-based, inclusive) and a stop (0-based,
exclusive) position as parameters. The full request methods all start with the prefix
full_
.
Implementations
impl TwoBitFile
[src]
pub fn open<P: AsRef<Path>>(
path: P,
softmask_enabled: bool
) -> Result<TwoBitFile, Error>
[src]
path: P,
softmask_enabled: bool
) -> Result<TwoBitFile, Error>
Constructor for a 2bit file.
path
- A path to the 2bit filesoftmask_enabled
- return lower case nucleotides for soft blocks
pub fn chroms(&self) -> HashMap<String, Field>
[src]
Get the sizes of chromosomes in a 2bit file as a HashMap
pub fn full_sequence(&self, chr: &str) -> Result<String, Error>
[src]
Get the full sequence of a chromosome
chr
Name of the chromosome from the 2bit file- returns the full sequence as a
String
on success
pub fn sequence(
&self,
chr: &str,
start: usize,
end: usize
) -> Result<String, Error>
[src]
&self,
chr: &str,
start: usize,
end: usize
) -> Result<String, Error>
Get a partial sequence of a chromosome
chr
Name of the chromosome from the 2bit filestart
Start position of the sequenceend
Stop position of the sequence- returns the full sequence as a
String
on success
pub fn full_bases(&self, chr: &str) -> Result<BaseCounts, Error>
[src]
Count bases of a chromosome
chr
Name of the chromosome from the 2bit file
pub fn full_bases_percentages(
&self,
chr: &str
) -> Result<BasePercentages, Error>
[src]
&self,
chr: &str
) -> Result<BasePercentages, Error>
Calculates percentages of bases of a chromosome
chr
Name of the chromosome from the 2bit file
pub fn bases(
&self,
chr: &str,
start: usize,
end: usize
) -> Result<BaseCounts, Error>
[src]
&self,
chr: &str,
start: usize,
end: usize
) -> Result<BaseCounts, Error>
Count bases of a partial chromosome
chr
Name of the chromosome from the 2bit file
pub fn bases_percentages(
&self,
chr: &str,
start: usize,
end: usize
) -> Result<BasePercentages, Error>
[src]
&self,
chr: &str,
start: usize,
end: usize
) -> Result<BasePercentages, Error>
Calculates percentages of bases of a partial chromosome
chr
Name of the chromosome from the 2bit file
pub fn info(&self) -> Result<TwoBitFileInfo, Error>
[src]
Obtain general information on the 2bit file you are dealing with
pub fn full_hard_masked_blocks(&self, chr: &str) -> Result<Vec<Block>, Error>
[src]
Get all hard blocks (N-blocks) of a chromosome
chr
Name of the chromosome from the 2bit file
pub fn hard_masked_blocks(
&self,
chr: &str,
start: usize,
end: usize
) -> Result<Vec<Block>, Error>
[src]
&self,
chr: &str,
start: usize,
end: usize
) -> Result<Vec<Block>, Error>
Get hard blocks (N-blocks) of a region on a chromosome
chr
Name of the chromosome from the 2bit file
pub fn full_soft_masked_blocks(&self, chr: &str) -> Result<Vec<Block>, Error>
[src]
Get all soft blocks (lower case blocks) of a chromosome
chr
Name of the chromosome from the 2bit file
pub fn soft_masked_blocks(
&self,
chr: &str,
start: usize,
end: usize
) -> Result<Vec<Block>, Error>
[src]
&self,
chr: &str,
start: usize,
end: usize
) -> Result<Vec<Block>, Error>
Get soft blocks (lower case blocks) of a region on a chromosome
chr
Name of the chromosome from the 2bit file
Auto Trait Implementations
impl RefUnwindSafe for TwoBitFile
impl Send for TwoBitFile
impl Sync for TwoBitFile
impl Unpin for TwoBitFile
impl UnwindSafe for TwoBitFile
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,