aboutsummaryrefslogtreecommitdiff
path: root/kmer.py
blob: c22ec1ed7694da6b975a3834ea916bd32e7ba2ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'''

The kmer module provides an interface between the C-library
for quikr kmer counting in Python 

'''
__author__ = "Calvin Morrison"
__copyright__ = "Copyright 2013, EESI Laboratory"
__credits__ = ["Calvin Morrison"]
__license__ = "GPL"
__version__ = "0.1.0"
__maintainer__ = "Calvin Morrison"
__email__ = "mutantturkey@gmail.com"
__status__ = "development"

import numpy as np
import ctypes as c
try:
	libkmer = c.CDLL("libkmer.so"); 
except:
	raise Exception("Error: could not load libkmer.so")

def load_kmer_counts_from_file(fh, kmer):
	'''
	'''
	ret = []
	width = (kmer ** 4) + 1
	libkmer.get_kmer_counts_from_filename.restype = c.POINTER(c.c_ulonglong * width )
	counts = libkmer.get_kmer_counts_from_filename(fh, kmer);

	if counts.contents:
		for i in counts.contents:
			ret.append(i)
	else:
		ret = 'error'

	return ret