Package: kmerdb
README - kmerdbA Python CLI and module for k-mer profiles, similarities, and graph databasesNOTE: This project is in alpha stage. Development is ongoing. But feel free to clone the repository and play with the code for yourself.Development StatusSummaryKDB is a Python library designed for bioinformatics applications. It addresses the'k-mer' problem(substrings of length k) in a simple and performant manner. It stores the k-mer counts/abundances and total counts. You can think of the current form as a "pre-index", as it includes all the essential information for indexing on any field in the landscape of k-mer to sequence relationships. One restriction is that k-mers with unspecified sequence residues 'N' create gaps in the k-mer to sequence relationship space, and are excluded. That said, non-standard IUPAC residues are supported.Please see theQuickstart guidefor more information about the format, the library, and the project.The k-mer spectrum of the fasta or fastq sequencing data is stored in the.kdbformat spec, a bgzf file similar to.bam. For those familiar with.bam, aviewandheaderfunctions are provided to decompress a.kdbfile into a standard output stream.InstallationDependenciesDESeq2 is required as a R dependency for rpy2-mediated normalization.if(!requireNamespace("BiocManager",quietly=TRUE))install.packages("BiocManager")BiocManager::install("DESeq2")All other dependencies are managed directly by pip.OSX and Linux release:pipinstallkmerdbDevelopment installation:gitclonehttps://github.com/MatthewRalston/kmerdb.git
pipinstall-e.Usage ExampleNOTE: Usage in detail can be found on thequickstart pageCLI Usagekmerdb--help# Build a [composite] profile to a new or existing .kdb filekmerdbprofile-k8example1.fq.gzexample2.fq.gzprofile.8.kdb# View the raw datakmerdbviewprofile.8.kdb# -H for full header# View the headerkmerdbheaderprofile.8.kdb# Collate the fileskmerdbmatrix-p$corespass*.8.kdb# Calculate similarity between two (or more) profileskmerdbdistancecorrelationprofile1.kdbprofile2.kdb(...)Usage note:kmerdbprofile-k$kinput.faoutput.kdb# This may discard non-IUPAC characters, this feature lacks documentation!IUPAC residues (ATCG+RYSWKM+BDHV) are kept throughout the k-mer counting. But non-IUPAC residues (N) and characters are trimmed from the sequences prior to k-mer counting.DocumentationCheck out themain webpageand theReadthedocs documentation, with examples and descriptions of the module usage.Important features to usage that may be important may not be fully documented.For example, the IUPAC treatment is largely custom, and does the sensible thing when ambiguous bases are found in fasta files, but it could use some polishing.In addition, the 'N' residue rejection creates gaps in the k-mer profile from the real dataset by admittedly ommitting certain k-mer counts.
This is one method for counting k-mers and handling ambiguity. Fork it and play with it a bit.Also, the parallel handling may not always be smooth, if you're trying to load dozens of 12+ mer profiles into memory. This would especially matter in the matrix command, before the matrix is generated. You can use single-core if your machine can't collate that much into main memory at once, depending on how deep the fastq dataset is, and the--block-sizeparameter inkmerdb profileis likely going to facilitate your memory overhead by reading chunks of--block-sizereads into memory at once while accumulating the k-mer counts in auint64array. Even when handling small-ish k-mer profiles, you may bump into memory overheads rather quickly.Besides that, I'd suggest reading the source, the differente elements of themain pageor theRTD documentation.Developmenthttps://matthewralston.github.io/kmerdb/developingpythonsetup.pytestLicenseCreated by Matthew Ralston -Scientist, Programmer, Musician-EmailDistributed under the Apache license. SeeLICENSE.txtfor the copy distributed with this project. Open source software is not for everyone, but for those of us starting out and trying to put the ecosystem ahead of ego, we march into the information age with this ethos.Copyright 2020 Matthew Ralston

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.ContributingFork it (https://github.com/MatthewRalston/kdb/fork)Create your feature branch (git checkout -b feature/fooBar)Commit your changes (git commit -am 'Add some fooBar')Push to the branch (git push origin feature/fooBar)Create a new Pull RequestAcknowledgementsThank you to the authors of kPAL and Jellyfish for the early inspiration. And thank you to others for the encouragement along the way, who shall remain nameless. I wanted this library to be a good strategy for assessing these k-mer profiles, in a way that is both cost aware of the analytical tasks at play, capable of storing the exact profiles in sync with the current assemblies, and then updating the kmer databases only when needed to generate enough spectral signature information.The intention is that more developers would want to add functionality to the codebase or even just utilize things downstream, but to build out directly with numpy and scipy/scikit as needed to suggest the basic infrastructure for the ML problems and modeling approaches that could be applied to such datasets. This project has begun under GPL v3.0 and hopefully could gain some interest.More on the flip-side of this file. Literally. And figuratively. It's so complex with technology these days.