## syncmers

Rust library for finding syncmers

### 5 releases

 0.1.5 Dec 19, 2022 Oct 22, 2022 Oct 17, 2022 Oct 17, 2022 Oct 17, 2022

#33 in #fastq

Used in 2 crates (via libsfasta)

MIT/Apache

12KB
164 lines

# Syncmers Library in Rust

Syncmers as defined by Dutta et al. 2022, https://www.biorxiv.org/content/10.1101/2022.01.10.475696v2.full Esp Fig 1b / Algorithm 1. Planning to implement other methods soon.

## Definition

Using the parameterized syncmer scheme, a syncmer is a kmer whose smallest smer is at a given target position (t).

## Extract Syncmers from &[u8]

``````let sequence = b"CCAGTGTTTACGG";
let syncmers = find_syncmers(5, 2, &[2], None, sequence);
assert!(syncmers == vec![b"CCAGT", b"TTACG"]);
println!("{:?}", syncmers);
``````

## Extract Syncmers from &[u8], downsampling to 20%

``````let sequence = b"CCAGTGTTTACGG";
let syncmers = find_syncmers(5, 2, &[2], Some(0.2), sequence);
assert!(syncmers == vec![b"CCAGT", b"TTACG"]);
println!("{:?}", syncmers);
``````

## Extract Syncmers from &[u8], keeping 80%

``````let sequence = b"CCAGTGTTTACGG";
let syncmers = find_syncmers(5, 2, &[2], Some(0.8), sequence);
assert!(syncmers == vec![b"CCAGT", b"TTACG"]);
println!("{:?}", syncmers);
``````

## Find positions of Syncmers

``````let sequence = b"CCAGTGTTTACGG";
let syncmer_positions = find_syncmers_pos(5, 2, &[2], None, sequence);
println!("{:?}", syncmer_positions);
assert!(syncmer_positions == vec![0, 7]);
``````

# Changelog

0.1.4: Added downsampling support

~1.5MB
~36K SLoC