Struct minimap2::Aligner

source ·
pub struct Aligner {
    pub idxopt: IdxOpt,
    pub mapopt: MapOpt,
    pub threads: usize,
    pub idx: Option<mm_idx_t>,
    pub idx_reader: Option<mm_idx_reader_t>,
    pub cigar_clipping: bool,
}
Expand description

Aligner struct, mimicking minimap2’s python interface

Aligner::builder();

Fields§

§idxopt: IdxOpt

Index options passed to minimap2 (mm_idxopt_t)

§mapopt: MapOpt

Mapping options passed to minimap2 (mm_mapopt_t)

§threads: usize

Number of threads to create the index with

§idx: Option<mm_idx_t>

Index created by minimap2

§idx_reader: Option<mm_idx_reader_t>

Index reader created by minimap2

§cigar_clipping: bool

Whether to add soft clipping to CIGAR result

Implementations§

source§

impl Aligner

source

pub fn populate_header(&self, header: &mut Header)

source

pub fn map_to_sam( &self, seq: &[u8], qual: Option<&[u8]>, name: Option<&[u8]>, header: &HeaderView, max_frag_len: Option<usize>, extra_flags: Option<Vec<u64>> ) -> Result<Vec<Record>, &'static str>

source§

impl Aligner

source

pub fn builder() -> Self

Create a new aligner with default options

source§

impl Aligner

source

pub fn lrhq(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to lr:hq.

source

pub fn splice(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to splice

Aligner::builder().splice();
source

pub fn splice_hq(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to splice:hq

Aligner::builder().splice_hq();
source

pub fn asm(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to Asm

Aligner::builder().asm();
source

pub fn asm5(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to Asm5

Aligner::builder().asm5();
source

pub fn asm10(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to Asm10

Aligner::builder().asm10();
source

pub fn asm20(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to Asm20

Aligner::builder().asm20();
source

pub fn sr(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to sr

Aligner::builder().sr();
source

pub fn map_pb(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to MapPb

Aligner::builder().map_pb();
source

pub fn map_hifi(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to MapHifi

Aligner::builder().map_hifi();
source

pub fn map_ont(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to MapOnt.

Aligner::builder().map_ont();
source

pub fn ava_pb(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to AvaPb

Aligner::builder().ava_pb();
source

pub fn ava_ont(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to AvaOnt.

Aligner::builder().ava_ont();
source

pub fn short(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to Short

Aligner::builder().short();
source

pub fn map10k(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to Map10k

Aligner::builder().map10k();
source

pub fn cdna(self) -> Self

Ergonomic function for Aligner. Sets the minimap2 preset to cdna

Aligner::builder().cdna();
source

pub fn preset(self, preset: Preset) -> Self

Create an aligner using a preset.

source

pub fn with_cigar(self) -> Self

Set Alignment mode / cigar mode in minimap2

Aligner::builder().map_ont().with_cigar();
source

pub fn with_cigar_clipping(self) -> Self

source

pub fn with_sam_out(self) -> Self

source

pub fn with_sam_hit_only(self) -> Self

source

pub fn with_index_threads(self, threads: usize) -> Self

Sets the number of threads minimap2 will use for building the index

Aligner::builder().with_index_threads(10);

Set the number of threads (prefer to use the struct config)

source

pub fn with_threads(self, threads: usize) -> Self

👎Deprecated since 0.1.17: Please use with_index_threads instead
source

pub fn with_index<P>( self, path: P, output: Option<&str> ) -> Result<Self, &'static str>
where P: AsRef<Path>,

Set index parameters for minimap2 using builder pattern Creates the index as well with the given number of threads (set at struct creation). You must set the number of threads before calling this function.

Parameters: path: Location of pre-built index or FASTA/FASTQ file (may be gzipped or plaintext) Output: Option (None) or a filename

Returns the aligner with the index set

// Do not save the index file
Aligner::builder().map_ont().with_index("test_data/test_data.fasta", None);

// Save the index file as my_index.mmi
Aligner::builder().map_ont().with_index("test_data/test_data.fasta", Some("my_index.mmi"));

// Use the previously built index
Aligner::builder().map_ont().with_index("my_index.mmi", None);
source

pub fn set_index<P>( &mut self, path: P, output: Option<&str> ) -> Result<(), &'static str>
where P: AsRef<Path>,

Set the index (in-place, without builder pattern)

source

pub fn with_seq(self, seq: &[u8]) -> Result<Self, &'static str>

Use a single sequence as the index. Sets the sequence ID to “N/A”. Can not be combined with with_index or set_index. Following the mappy implementation, this also sets mapopt.mid_occ to 1000.

let aligner = Aligner::builder().map_ont().with_seq(seq.as_bytes()).expect("Unable to build index");
let query = b"CGGCACCAGGTTAAAATCTGAGTGCTGCAATAGGCGATTACAGTACAGCACCCAGCCTCCG";
let hits = aligner.map(query, false, false, None, None);
assert_eq!(hits.unwrap().len(), 1);
source

pub fn with_seq_and_id( self, seq: &[u8], id: &[u8] ) -> Result<Self, &'static str>

Use a single sequence as the index. Sets the sequence ID to “N/A”. Can not be combined with with_index or set_index. Following the mappy implementation, this also sets mapopt.mid_occ to 1000.

let aligner = Aligner::builder().map_ont().with_seq_and_id(seq.as_bytes(), id.as_bytes()).expect("Unable to build index");
let query = b"CGGCACCAGGTTAAAATCTGAGTGCTGCAATAGGCGATTACAGTACAGCACCCAGCCTCCG";
let hits = aligner.map(query, false, false, None, None);
assert_eq!(hits.as_ref().unwrap().len(), 1);
assert_eq!(hits.as_ref().unwrap()[0].target_name.as_ref().unwrap(), id);
source

pub fn with_seqs(self, seqs: &[Vec<u8>]) -> Result<Self, &'static str>

TODO: Does not work for more than 1 seq currently! Pass multiple sequences to build an index functionally. Following the mappy implementation, this also sets mapopt.mid_occ to 1000. Can not be combined with with_index or set_index. Sets the sequence IDs to “Unnamed Sequence n” where n is the sequence number.

source

pub fn with_seqs_and_ids( self, seqs: &[Vec<u8>], ids: &[Vec<u8>] ) -> Result<Self, &'static str>

TODO: Does not work for more than 1 seq currently! Pass multiple sequences and corresponding IDs to build an index functionally. Following the mappy implementation, this also sets mapopt.mid_occ to 1000.

source

pub fn map( &self, seq: &[u8], cs: bool, md: bool, max_frag_len: Option<usize>, extra_flags: Option<&[u64]> ) -> Result<Vec<Mapping>, &'static str>

Aligns a given sequence (as bytes) to the index associated with this aligner

Parameters: seq: Sequence to align cs: Whether to output CIGAR string MD: Whether to output MD tag max_frag_len: Maximum fragment length extra_flags: Extra flags to pass to minimap2 as Vec<u64>

source

pub fn map_file( &self, file: &str, cs: bool, md: bool ) -> Result<Vec<Mapping>, &'static str>

Map entire file Detects if file is gzip or not and if it’s fastq/fasta or not Best for smaller files (all results are stored in an accumulated Vec!) What you probably want is to loop through the file yourself and use the map() function

TODO: Remove cs and md and make them options on the struct

source

pub fn has_index(&self) -> bool

Trait Implementations§

source§

impl Clone for Aligner

source§

fn clone(&self) -> Aligner

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Aligner

Create a default aligner

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<&Aligner> for MMIndex

source§

fn from(aligner: &Aligner) -> Self

Converts to this type from the input type.
source§

impl Send for Aligner

source§

impl Sync for Aligner

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.