Craps Python Github

Posted By admin On 25/07/22

@John: No, ranges in Python are half-open, i.e. The 7 isn't included and you end up with start - stop = 6 options from start to stop - 1. – user395760 Mar 15 '11 at 18:11 1 random.randint(1, 6) might be more clear. – nmichaels Mar 15 '11 at 18:15. Python dice simulator, why it is running without stopping? Hot Network Questions Scrum and interruptions Why the pitot tube is located near the nose? GitHub Gist: instantly share code, notes, and snippets.

(This is not why most people want to use khmer – see An assembly handbook for khmer - rough draft for that.)

khmer ktables are a simple C++ library for counting k-mers in DNAsequences. There’s a complete Python wrapping and it should be prettydarned fast; it’s intended for genome-scale k-mer counting.

‘ktable’s are a table of 4**k counters. khmer then maps each k-merinto this table with a simple (and reversible) hash function.

Right now, only the Python interface is documented here. The C++interface is essentially identical; if you need to use it and wantit documented, drop me a line.

Counting Speed and Memory Usage¶

On the 5 mb Shewanella oneidensis genome, khmer takes less than a secondto count all k-mers, for any k between 6 and 12. At 13 it craps outbecause the table goes over my default stack size limit.

Craps

Approximate memory usage can be calculated by finding the size of alonglong on your machine and then multiplying that by 4**k.For a 12bp wordsize, this works out to 16384*1024; on an Intel-basedprocessor running Linux, longlong is 8 bytes, so memory usageis approximately 128 mb.

Python interface¶

Essentially everything requires a ktable.

These commands will create a new ktable of size 4**L, suitablefor counting L-mers.

Each ktable object has a few accessor functions:

  • ktable.ksize() will return L.
  • ktable.max_hash() will return the max hash value in the table, 4**L - 1.
  • ktable.n_entries() will return the number of table entries, 4**L.
Craps Python Github

The forward and reverse hashing functions are directly accessible:

  • hashval=ktable.forward_hash(kmer) will return the hash value

    of the given kmer.

  • kmer=ktable.reverse_hash(hashval) will return the kmer that hashes

    to the given hashval.

There are also some counting functions:

  • ktable.count(kmer) will increment the count associated with the given kmerby one.
  • ktable.consume(sequence) will run through the sequence and counteach kmer present.
  • n=ktable.get(kmer hashval) will return the count associated with thegiven kmer string or the given hashval, whichever is passed in.
  • ktable.set(kmer hashval,count) set the count for the given kmerstring or hashval.

In all of the cases above, ‘kmer’ is an L-length string, ‘hashval’ isa non-negative integer, and ‘sequence’ is a DNA sequence containing ONLYA/C/G/T.

Note: ‘N’ is not a legal DNA character as far as khmer is concerned!

Craps Python Github Cheat

Craps Python Github

And, finally, there are some set operations:

  • ktable.clear() empties the ktable.
  • ktable.update(other) adds all of the entries in other intoktable. The wordsize must be the same for both ktables.
  • intersection=ktable.intersect(other) returns a ktable whereonly nonzero entries in both ktables are kept. The count for achentry is the sum of the counts in ktable and other.

Craps Python Github Game

An Example¶

This short code example will count all 6-mers present in the givenDNA sequence, and then print them all out along with their prevalence.

Latest version

Released:

Encodes and decodes files in .crap format. This allows one to execute the file in any languge, immediately upon import.

Project description

Project details

Craps Python Github Games


Release historyRelease notifications RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for crap, version 1.5
Filename, sizeFile typePython versionUpload dateHashes
Filename, size crap-1.5-py3-none-any.whl (2.2 kB) File type Wheel Python version py3 Upload dateHashes
Filename, size crap-1.5.tar.gz (1.0 kB) File type Source Python version None Upload dateHashes
Close

Craps Python Github Tutorial

Hashes for crap-1.5-py3-none-any.whl

Hashes for crap-1.5-py3-none-any.whl
AlgorithmHash digest
SHA256f8b1d4d2dc7686c0434a89e27be1a3665395791dcc6da10170efc296d7daabe7
MD556d0fbaa54119feddec650332848931c
BLAKE2-25641c719717b2eef1c787608607f6a142dc79a2c705142cd4ef9407c3f9b660d8b
Close

Hashes for crap-1.5.tar.gz

Hashes for crap-1.5.tar.gz
AlgorithmHash digest
SHA256a3c38934ddf2e1a03d89091b043c6ccc95c6db16e7511e01f97818ced8719042
MD5b076e9a893eccb2cecbd96becffd27ef
BLAKE2-256b690c3f2d6e99c5d7c4ed81c3231938ac5b81a1d5d84896b7187e03ffc712821