Git Product home page Git Product logo

uniquekmer's Introduction

UniqueKMER

Generate unique k-mers for every contig in a FASTA file.

Unique k-mer is consisted of k-mer keys (i.e. ATCGATCCTTAAGG) that are only presented in one contig, but not presented in any other contigs (for both forward and reverse strands).

This tool accepts the input of a FASTA file consisting of many contigs, and extract unique k-mers for each contig.

The output unique k-mer file and Genome file can be used for fastv: https://github.com/OpenGene/fastv, which is an ultra-fast tool to identify and visualize microbial sequences from sequencing data.

what does UniqueKMER output?

This tool outputs a folder (folder name can be specified by -o/--outdir), which contains:

  • a index.html file.
  • a kmercollection.fasta file, which is a single file lists all the genome names along with their unique k-mer. Each k-mer key is represented by an individual line.
  • a subfolder genomes_kmers, which contains a k-mer file and a Genome file for each contig, both in FASTA format.

You can open the index.html with any browser, then click on the contig names to find its k-mer file and Genome file.

get this tool

download binary

This binary is only for Linux systems: http://opengene.org/uniquekmer/uniquekmer

# this binary was compiled on CentOS, and tested on CentOS/Ubuntu
wget http://opengene.org/uniquekmer/uniquekmer
chmod a+x ./uniquekmer

or compile from source

# step 1: get the code
git clone https://github.com/OpenGene/UniqueKMER.git

# step 2: build
cd UniqueKMER
make

# step 3: install it to system if you have a sudo permission
make install

simple example:

uniquekmer -f test.fasta

You can get the test.fasta from: http://opengene.org/test.fasta

more examples

set the k-mer key length

# 16-mer (i.e. ATCGATCGATCGATCG...)
uniquekmer -f test.fasta -k 16

filter the k-mer keys that can be mapped to a reference genome (i.e. human genome)

# k-mer sequences that can be mapped to hg38 with `edit distance <=2`  will be removed
uniquekmer -f test.fasta -r hg38.fasta -e 2

set the spacing to avoid many continuous k-mer keys

# the spacing will be 2, which means if `key(pos)` is stored, then `key(pos+1)`  and `key(pos+2)` will be skipped
uniquekmer -f test.fasta -s 2

options:

  -f, --fasta            FASTA input file name (string)
  -o, --outdir           Directory for output. Default is unique_kmers in the current directory. (string [=unique_kmers])
  -k, --kmer             The length k of k-mer (3~32), default 25 (int [=25])
  -s, --spacing          If a key with POS is recorded, then skip [POS+1...POS+spacing] to avoid too compact result (0~100). default 0 means no skipping. (int [=0])
  -g, --genome_limit     Process up to genome_limit genomes in the FASTA input file. Default 0 means no limit. This option is for DEBUG. (int [=0])
  -r, --ref              Reference genome FASTA file name. Specify this only when you want to filter out the unique k-mer that can be mapped to reference genome. (string [=])
  -e, --edit_distance    k-mer mapped to reference genome with edit distance <= edit_distance will be removed (0~16). 3 for default. (int [=3])
  -?, --help             print this message

get the pre-built k-mer file, genomes file or k-mer collection file for viruses

get the pre-built k-mer file, genomes file or k-mer collection file for viruses and human microorganisms

Citation

If you use fastv, UniqueKMER or the pre-generated resources provided by this repository, please cite our work as:

Shifu Chen, Changshou He, Yingqiang Li, Zhicheng Li, Charles E Melancon III. A Computational Toolset for Rapid Identification of SARS-CoV-2, other Viruses, and Microorganisms from Sequencing Data. bioRxiv 2020.05.12.092163; doi: https://doi.org/10.1101/2020.05.12.092163

uniquekmer's People

Contributors

qins avatar sfchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uniquekmer's Issues

[Feature request] give a header to each fasta

I found myself using your tool to obtain more hindsight into kmer presence and absence in genomes, specifically for kmers unique to certain genomes. Because the output of UniqueKmer is in the following form:

>sequence1
kmer1
kmer2
kmer3

tools will count them as one continuous sequence kmer1kmer2kmer3 which is unintended and will even create kmers that do not exist in the original genome.

Could you add an option to give a header to each kmer ? it would then look like this :

>sequence1:kmer:1
kmer1
>sequence1:kmer:2
kmer2
>sequence1:kmer:3
kmer3

I wrote a command line with awk for that but it would be convenient to have it as an option:

awk -i inplace '{if (/>/) {line=$0; sum=0} else {sum+=1; KMER=$0; print line ":kmer:" sum "\n" KMER} }' unique_kmers.fasta

Threading

Hello,

Really useful tool. Is this multi-threaded or single threaded?

Thanks,

Andrew

terminate called after throwing an instance of 'std::out_of_range

I am trying to create a kmerscollection of different viruses using fasta files but I get the error below for some fasta files.

Output 40/500: HW826641.1 JP 2014023536-A/12: Non-Diffusible Plant Virus Vector. unique: 5
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr: __pos (which is 22) > this->size() (which is 21)
/usr/bin/bash: line 1: 25212 Aborted

I am using standart fasta file downloaded from NCBI. I attached one of the problematic file in this issue (I have put it in txt but it his a .fa file normally).

I tried splitting the file in 1000 line but this seemed to not be the problem

Thank you for your time,
TheBiotech

Virus_12305.txt

[Question] Clarification of uniqueness

Thank you so much for providing this wonderful tool!

If I search a region of ie. the human genome (chr1:1:50000) against the entire human reference genome, will UniqueKMER return the list of k-mers that map once and only once in the reference genome (between chr1:1:50000?)

or

does UniqueKMER keep only k-mers that map zero times against the reference genome?

I raise this issue to highlight the setting where the input FASTA and the reference genome are derived from the same species. I think this type of tool would be useful; Bloom-filters that count k-mers lack sensitivity to count unique k-mers, as far as I know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.