Skip to content

mhyfritz/k-mers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k-mers

Enumerate k-mers of a given string.

Installation

npm install k-mers

Usage

var kmers = require('k-mers')

var s = 'foobar'
var k = 3

// get list of 3-mers in one shot:
kmers(k, s).all() // [ 'foo', 'oob', 'oba', 'bar' ]

// iterate over 3-mers:
iterKmers = kmers(k, s)
while (true) {
  var kmer = iterKmers.next()
  if (kmer.value === undefined) {
    break
  }
  console.log(kmer)
}
// { value: 'foo', index: 0 }
// { value: 'oob', index: 1 }
// { value: 'oba', index: 2 }
// { value: 'bar', index: 3 }

// (re)set iterator to given index
iterKmers.seek(2)
iterKmers.next() // { value: 'oba', index: 2 }

Releases

No releases published

Packages

No packages published