From 79af85ef9a4983527b6498c858b30525bbe502f1 Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Sun, 2 Feb 2014 14:56:00 -0500 Subject: somewhat working python module --- kmer.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/kmer.py b/kmer.py index 9326aab..c22ec1e 100644 --- a/kmer.py +++ b/kmer.py @@ -1,7 +1,7 @@ ''' - The kmer module provides an interface between the C-library - for quikr kmer counting in Python +The kmer module provides an interface between the C-library +for quikr kmer counting in Python ''' __author__ = "Calvin Morrison" @@ -16,17 +16,23 @@ __status__ = "development" import numpy as np import ctypes as c try: - libkmer = c.CDLL("libkmer.so"); + libkmer = c.CDLL("libkmer.so"); except: - raise Exception("Error: could not load libkmer.so") + raise Exception("Error: could not load libkmer.so") def load_kmer_counts_from_file(fh, kmer): - ''' - ''' - width = (kmer ** 4) + 1 - libkmer.get_kmer_counts_from_file.restype = c.POINTER(c.c_ulonglong * width ) + ''' + ''' + 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); - counts = libkmer.get_kmer_counts_from_filename(fh, kmer); + if counts.contents: + for i in counts.contents: + ret.append(i) + else: + ret = 'error' - return counts + return ret -- cgit v1.2.3