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
impl Aligner
sourcepub fn splice(self) -> Self
pub fn splice(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to splice
Aligner::builder().splice();
sourcepub fn splice_hq(self) -> Self
pub fn splice_hq(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to splice:hq
Aligner::builder().splice_hq();
sourcepub fn asm(self) -> Self
pub fn asm(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to Asm
Aligner::builder().asm();
sourcepub fn asm5(self) -> Self
pub fn asm5(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to Asm5
Aligner::builder().asm5();
sourcepub fn asm10(self) -> Self
pub fn asm10(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to Asm10
Aligner::builder().asm10();
sourcepub fn asm20(self) -> Self
pub fn asm20(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to Asm20
Aligner::builder().asm20();
sourcepub fn sr(self) -> Self
pub fn sr(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to sr
Aligner::builder().sr();
sourcepub fn map_pb(self) -> Self
pub fn map_pb(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to MapPb
Aligner::builder().map_pb();
sourcepub fn map_hifi(self) -> Self
pub fn map_hifi(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to MapHifi
Aligner::builder().map_hifi();
sourcepub fn map_ont(self) -> Self
pub fn map_ont(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to MapOnt.
Aligner::builder().map_ont();
sourcepub fn ava_pb(self) -> Self
pub fn ava_pb(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to AvaPb
Aligner::builder().ava_pb();
sourcepub fn ava_ont(self) -> Self
pub fn ava_ont(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to AvaOnt.
Aligner::builder().ava_ont();
sourcepub fn short(self) -> Self
pub fn short(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to Short
Aligner::builder().short();
sourcepub fn map10k(self) -> Self
pub fn map10k(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to Map10k
Aligner::builder().map10k();
sourcepub fn cdna(self) -> Self
pub fn cdna(self) -> Self
Ergonomic function for Aligner. Sets the minimap2 preset to cdna
Aligner::builder().cdna();
sourcepub fn with_cigar(self) -> Self
pub fn with_cigar(self) -> Self
Set Alignment mode / cigar mode in minimap2
Aligner::builder().map_ont().with_cigar();
pub fn with_cigar_clipping(self) -> Self
pub fn with_sam_out(self) -> Self
pub fn with_sam_hit_only(self) -> Self
sourcepub fn with_index_threads(self, threads: usize) -> Self
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)
pub fn with_threads(self, threads: usize) -> Self
with_index_threads
insteadsourcepub fn with_index<P>(
self,
path: P,
output: Option<&str>
) -> Result<Self, &'static str>
pub fn with_index<P>( self, path: P, output: Option<&str> ) -> Result<Self, &'static str>
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);
sourcepub fn set_index<P>(
&mut self,
path: P,
output: Option<&str>
) -> Result<(), &'static str>
pub fn set_index<P>( &mut self, path: P, output: Option<&str> ) -> Result<(), &'static str>
Set the index (in-place, without builder pattern)
sourcepub fn with_seq(self, seq: &[u8]) -> Result<Self, &'static str>
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);
sourcepub fn with_seq_and_id(
self,
seq: &[u8],
id: &[u8]
) -> Result<Self, &'static str>
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);
sourcepub fn with_seqs(self, seqs: &[Vec<u8>]) -> Result<Self, &'static str>
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.
sourcepub fn with_seqs_and_ids(
self,
seqs: &[Vec<u8>],
ids: &[Vec<u8>]
) -> Result<Self, &'static str>
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.
sourcepub fn map(
&self,
seq: &[u8],
cs: bool,
md: bool,
max_frag_len: Option<usize>,
extra_flags: Option<&[u64]>
) -> Result<Vec<Mapping>, &'static str>
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>
sourcepub fn map_file(
&self,
file: &str,
cs: bool,
md: bool
) -> Result<Vec<Mapping>, &'static str>
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