Commit 9a9bd6c6 by abonin

switch to the new cython interface to array.array

parent 6002fbaa
......@@ -5,6 +5,8 @@ Created on 6 Nov. 2009
'''
#@PydevCodeAnalysisIgnore
from cpython cimport array
from obitools import BioSequence
from _lcs cimport *
from _upperbond cimport *
......@@ -137,8 +139,6 @@ def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALIL
cdef bytes se2=bytes(str(seq2))
cdef int l1 = len(seq1)
cdef int l2 = len(seq2)
cdef array.array[unsigned char] w1
cdef array.array[unsigned char] w2
cdef int o1
cdef int o2
cdef int wordcount
......@@ -146,11 +146,15 @@ def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALIL
cdef bint possible
cdef bint large
cdef array.array[uchar] w1
cdef array.array[uchar] w2
cdef char *s1
cdef char *s2
s1=se1
s2=se2
if min(l1,l2) < 8:
lcsali = LCS()
lcsali.seqA = seq1
......@@ -163,7 +167,7 @@ def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALIL
o1 = seq1.word4over
else:
w1 = newtable()
o1 = buildTable(s1,w1._BYTES,&wordcount)
o1 = buildTable(s1,w1.data.as_uchars,&wordcount)
if isinstance(seq1, BioSequence):
seq1.word4table=w1
seq1.word4over=o1
......@@ -172,13 +176,14 @@ def lenlcs(seq1,seq2,double minimum=0.,bint normalized=False, int reference=ALIL
o2 = seq2.word4over
else:
w2 = newtable()
o2 = buildTable(s2,w2._BYTES,&wordcount)
o2 = buildTable(s2,w2.data.as_uchars,&wordcount)
if isinstance(seq2, BioSequence) :
seq2.word4table=w2
seq2.word4over=o2
large = reference==ALILEN or reference==MAXLEN
possible = ispossible(l1, w1._BYTES, o1,
l2, w2._BYTES, o2,
possible = ispossible(l1, w1.data.as_uchars, o1,
l2, w2.data.as_uchars, o2,
minimum,normalized,large)
if possible:
lcs = fastLCSScore(s1,s2,NULL,&alilength)
......
from array import array
cimport array
from cpython cimport array
cdef extern from *:
ctypedef char* const_char_ptr "const char*"
cdef import from "_upperbond.h":
int buildTable(const_char_ptr sequence, unsigned char *table, int *count)
int compareTable(unsigned char *t1, int over1, unsigned char* t2, int over2)
......@@ -13,5 +12,5 @@ cdef import from "_upperbond.h":
bint ispossible(int len1, unsigned char *t1, int over1,
int len2, unsigned char* t2, int over2,
double minimum, bint normalized, bint large)
cdef array.array[unsigned char] newtable()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment