Skip to main content

filter_kmers

Function filter_kmers 

Source
pub fn filter_kmers<SD, K, DI>(
    seqs: &ReadsPaired<DI>,
    summary_config: &SummaryConfig,
    report_all_kmers: bool,
    memory_size: f32,
    time: bool,
) -> (BoomHashMap2<K, Exts, SD>, Vec<K>)
where SD: Debug + SummaryData<DI>, K: Kmer, DI: Copy + Clone + Debug + Hash + Eq,
Expand description

Process DNA sequences into kmers and determine the set of valid kmers, their extensions, and summarize associated label/‘color’ data. The input sequences are converted to kmers of type K, and like kmers are grouped together. All instances of each kmer, along with their label data are then proccessed with SummaryData::summarize, which generates an implementation of SummaryData, which is specified with the generic SD, decides if the k-mer is ‘valid’ based on the parameters given in summary_config, and summarizes the the individual label into a single label data structure for the kmer. Care is taken to keep the memory consumption small.

Be aware that the configuration in summary_config only applies if the required informaiton can be supplied by the chosen implementation of SummaryData. E.g., the k-mers will not be filtered according to p-value when the SummaryData only contains the number of observations.

§Arguments

  • seqs are the reads wrapped in a Reads<u8>. See [Reads<DI>]
  • summary_config is a SummaryConfig, which contains prameters and information necessary for the filtering
  • stranded: if true, preserve the strandedness of the input sequences, effectively assuming they are all in the positive strand. If false, the kmers will be canonicalized to the lexicographic minimum of the kmer and it’s reverse complement.
  • report_all_kmers: if true returns the vector of all the observed kmers and performs the kmer based filtering
  • memory_size: gives the size bound on the memory in GB to use and automatically determines the number of passes needed.

§Returns

BoomHashMap2 Object, check rust-boomphf for details

§Examples:

use debruijn::summarizer::{SampleInfo, SummaryConfig, TagsCountsData, StatTest, GroupFrac};
use debruijn::reads::{Reads, ReadsPaired, Strandedness};
use debruijn::filter::filter_kmers;
use debruijn::kmer::Kmer16;
use debruijn::Exts;
 
let mut seqs = Reads::new(Strandedness::Unstranded);
seqs.add_from_bytes("ACCGATCATATATTTTCGGGGCTAGGCGAAGCGATCTTATCGAGC".as_bytes(), None, 1u8);
seqs.add_from_bytes("GCGATCGAGCATGCTCAGCTGACGTGACTGACGTAGCTATCTTTTCGTAGCTAC".as_bytes(), None, 1u8);
seqs.add_from_bytes("GCGAGTTTGCGACTCGAGGCTATCTAGCTAGCTASGCTCTCGACTAGCTGACTTACGACGACTACG".as_bytes(), None, 2u8);
seqs.add_from_bytes("CGATTAGCTACGTAGCTAGCTGACGTACTGGGGGGTATTTCGGATCTGCGGAGCGATCT".as_bytes(), None, 2u8);
       
let sample_info = SampleInfo::new(
    0b000011,
    0b111100,
    vec![23423, 3463454, 2242234, 2233243, 234322434, 2323234],
);
     
let summary_config = SummaryConfig::new(sample_info)
    .with_min_kmer_obs(3)
    .with_group_frac(GroupFrac::One, 0.333)
    .with_stat_test(StatTest::StudentsTTest);

    
let (hashed_kmers, _) = filter_kmers::<TagsCountsData, Kmer16, _>(
    &ReadsPaired::Unpaired { reads: seqs },
    &summary_config,
    false,
    10.,
   false,
);