Add a new script to assemble amplicon from solexa pair-end run
This commit is contained in:
@@ -3,4 +3,7 @@
|
||||
from _nws import NWS
|
||||
from _lcs import LCS
|
||||
from _assemble import DirectAssemble, ReverseAssemble
|
||||
|
||||
from _qsassemble import QSolexaDirectAssemble,QSolexaReverseAssemble
|
||||
from _rassemble import RightDirectAssemble as RightReverseAssemble
|
||||
from _qsrassemble import QSolexaRightDirectAssemble,QSolexaRightReverseAssemble
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
10
src/obitools/align/_assemble.pxd
Normal file
10
src/obitools/align/_assemble.pxd
Normal file
@@ -0,0 +1,10 @@
|
||||
from _nws cimport *
|
||||
|
||||
cdef class DirectAssemble(NWS):
|
||||
cdef double ysmax
|
||||
cdef int ymax
|
||||
|
||||
cdef double doAlignment(self) except? 0
|
||||
|
||||
cdef class ReverseAssemble(DirectAssemble):
|
||||
pass
|
@@ -5,25 +5,22 @@ Created on 6 Nov. 2009
|
||||
'''
|
||||
#@PydevCodeAnalysisIgnore
|
||||
|
||||
from _nws cimport *
|
||||
from _assemble cimport *
|
||||
|
||||
|
||||
cdef class DirectAssemble(NWS):
|
||||
|
||||
cdef double ysmax
|
||||
cdef int ymax
|
||||
def __init__(self,match=4,mismatch=-6,opengap=-8,extgap=-2):
|
||||
NWS.__init__(self,match,mismatch,opengap,extgap)
|
||||
self.ysmax=0
|
||||
self.ymax=0
|
||||
|
||||
cdef double matchScore(self,int h, int v):
|
||||
return iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
|
||||
|
||||
|
||||
cdef double doAlignment(self) except? 0:
|
||||
cdef int i # vertical index
|
||||
cdef int j # horizontal index
|
||||
cdef int idx
|
||||
cdef int idx0
|
||||
cdef int idx1
|
||||
cdef int jump
|
||||
cdef int delta
|
||||
cdef double score
|
||||
@@ -34,6 +31,8 @@ cdef class DirectAssemble(NWS):
|
||||
if self.needToCompute:
|
||||
self.allocate()
|
||||
self.reset()
|
||||
self.ysmax=0
|
||||
self.ymax=0
|
||||
|
||||
for j in range(1,self.hSeq.length+1):
|
||||
idx = self.index(j,0)
|
||||
@@ -45,11 +44,16 @@ cdef class DirectAssemble(NWS):
|
||||
self.matrix.matrix[idx].score = self._opengap + (self._extgap * (i-1))
|
||||
self.matrix.matrix[idx].path = -i
|
||||
|
||||
idx0=self.index(-1,0)
|
||||
idx1=self.index(0,1)
|
||||
for i in range(1,self.vSeq.length+1):
|
||||
idx0+=1
|
||||
idx1+=1
|
||||
for j in range(1,self.hSeq.length+1):
|
||||
|
||||
# 1 - came from diagonal
|
||||
idx = self.index(j-1,i-1)
|
||||
#idx = self.index(j-1,i-1)
|
||||
idx = idx0
|
||||
# print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
|
||||
scoremax = self.matrix.matrix[idx].score + \
|
||||
self.matchScore(j,i)
|
||||
@@ -58,7 +62,8 @@ cdef class DirectAssemble(NWS):
|
||||
# print "so=%f sd=%f sm=%f" % (self.matrix.matrix[idx].score,self.matchScore(j,i),scoremax),
|
||||
|
||||
# 2 - open horizontal gap
|
||||
idx = self.index(j-1,i)
|
||||
# idx = self.index(j-1,i)
|
||||
idx = idx1 - 1
|
||||
score = self.matrix.matrix[idx].score+ \
|
||||
self._opengap
|
||||
if score > scoremax :
|
||||
@@ -66,7 +71,8 @@ cdef class DirectAssemble(NWS):
|
||||
path = +1
|
||||
|
||||
# 3 - open vertical gap
|
||||
idx = self.index(j,i-1)
|
||||
# idx = self.index(j,i-1)
|
||||
idx = idx0 + 1
|
||||
score = self.matrix.matrix[idx].score + \
|
||||
self._opengap
|
||||
if score > scoremax :
|
||||
@@ -95,7 +101,8 @@ cdef class DirectAssemble(NWS):
|
||||
scoremax = score
|
||||
path = -delta-1
|
||||
|
||||
idx = self.index(j,i)
|
||||
# idx = self.index(j,i)
|
||||
idx = idx1
|
||||
self.matrix.matrix[idx].score = scoremax
|
||||
self.matrix.matrix[idx].path = path
|
||||
|
||||
@@ -107,14 +114,16 @@ cdef class DirectAssemble(NWS):
|
||||
if j==self.hSeq.length and scoremax > self.ysmax:
|
||||
self.ysmax=scoremax
|
||||
self.ymax=i
|
||||
idx0+=1
|
||||
idx1+=1
|
||||
|
||||
self.sequenceChanged=False
|
||||
self.scoreChanged=False
|
||||
|
||||
return self.ysmax
|
||||
|
||||
def backtrack(self):
|
||||
cdef list path=[]
|
||||
cdef void backtrack(self):
|
||||
#cdef list path=[]
|
||||
cdef int i
|
||||
cdef int j
|
||||
cdef int p
|
||||
@@ -122,13 +131,17 @@ cdef class DirectAssemble(NWS):
|
||||
self.doAlignment()
|
||||
i=self.ymax
|
||||
j=self.hSeq.length
|
||||
self.path=allocatePath(i,j+1,self.path)
|
||||
|
||||
if self.ymax<self.vSeq.length:
|
||||
path.append(self.ymax-self.vSeq.length)
|
||||
|
||||
self.path.path[self.path.length]=self.ymax-self.vSeq.length
|
||||
self.path.length+=1
|
||||
|
||||
while (i or j):
|
||||
p=self.matrix.matrix[self.index(j,i)].path
|
||||
path.append(p)
|
||||
self.path.path[self.path.length]=p
|
||||
self.path.length+=1
|
||||
#path.append(p)
|
||||
if p==0:
|
||||
i-=1
|
||||
j-=1
|
||||
@@ -137,8 +150,11 @@ cdef class DirectAssemble(NWS):
|
||||
else:
|
||||
j-=p
|
||||
|
||||
path.reverse()
|
||||
return 0,0,path
|
||||
#path.reverse()
|
||||
#reversePath(self.path)
|
||||
self.path.hStart=0
|
||||
self.path.vStart=0
|
||||
#return 0,0,path
|
||||
|
||||
|
||||
cdef class ReverseAssemble(DirectAssemble):
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -39,6 +39,20 @@ cdef alignSequence* allocateSequence(object bioseq, alignSequence* seq=?)
|
||||
|
||||
cdef void freeSequence(alignSequence* seq)
|
||||
|
||||
cdef struct alignPath:
|
||||
long length
|
||||
long buffsize
|
||||
long vStart
|
||||
long hStart
|
||||
long *path
|
||||
|
||||
cdef alignPath* allocatePath(long l1,long l2,alignPath* path=?)
|
||||
|
||||
cdef void reversePath(alignPath* path)
|
||||
|
||||
|
||||
cdef void freePath(alignPath* path)
|
||||
|
||||
|
||||
cdef int bitCount(int x)
|
||||
cpdef bint iupacMatch(unsigned char a, unsigned char b)
|
||||
@@ -52,6 +66,7 @@ cdef class DynamicProgramming:
|
||||
|
||||
cdef alignSequence* hSeq
|
||||
cdef alignSequence* vSeq
|
||||
cdef alignPath* path
|
||||
|
||||
cdef double _opengap
|
||||
cdef double _extgap
|
||||
@@ -65,5 +80,7 @@ cdef class DynamicProgramming:
|
||||
cdef double matchScore(self,int h, int v)
|
||||
cdef double doAlignment(self) except? 0
|
||||
cdef void reset(self)
|
||||
cdef inline int index(self,x,y)
|
||||
|
||||
cdef inline int index(self, int x, int y)
|
||||
cdef inline bint _needToCompute(self)
|
||||
cdef void backtrack(self)
|
||||
|
||||
|
@@ -18,6 +18,7 @@ from obitools.alignment import Alignment
|
||||
#
|
||||
|
||||
from _dynamic cimport *
|
||||
from Cython.Shadow import NULL
|
||||
|
||||
cdef AlignMatrix* allocateMatrix(int hsize, int vsize,AlignMatrix *matrix=NULL):
|
||||
|
||||
@@ -104,7 +105,40 @@ cdef void freeSequence(alignSequence* seq):
|
||||
free(<void*>seq.quality)
|
||||
free(seq)
|
||||
|
||||
cdef alignPath* allocatePath(long l1,long l2,alignPath* path=NULL):
|
||||
cdef long length=l1+l2
|
||||
|
||||
if path is NULL:
|
||||
path = <alignPath*>malloc(sizeof(alignPath))
|
||||
path.length=0
|
||||
path.buffsize=0
|
||||
path.path=NULL
|
||||
|
||||
if length > path.buffsize:
|
||||
path.buffsize=length
|
||||
path.path=<long*>realloc(path.path,sizeof(long)*length)
|
||||
|
||||
path.length=0
|
||||
path.vStart=0
|
||||
path.hStart=0
|
||||
|
||||
return path
|
||||
|
||||
cdef void reversePath(alignPath* path):
|
||||
cdef long i
|
||||
cdef long j
|
||||
|
||||
j=path.length
|
||||
for i in range(path.length/2):
|
||||
j-=1
|
||||
path.path[i],path.path[j]=path.path[j],path.path[i]
|
||||
|
||||
cdef void freePath(alignPath* path):
|
||||
if path is not NULL:
|
||||
if path.path is not NULL:
|
||||
free(<void*>path.path)
|
||||
free(<void*>path)
|
||||
|
||||
|
||||
cdef int aascii = ord(b'a')
|
||||
cdef int _basecode[26]
|
||||
@@ -139,6 +173,7 @@ cdef class DynamicProgramming:
|
||||
self.matrix=NULL
|
||||
self.hSeq=NULL
|
||||
self.vSeq=NULL
|
||||
self.path=NULL
|
||||
|
||||
self.horizontalSeq=None
|
||||
self.verticalSeq=None
|
||||
@@ -164,6 +199,12 @@ cdef class DynamicProgramming:
|
||||
cdef double doAlignment(self) except? 0:
|
||||
pass
|
||||
|
||||
cdef bint _needToCompute(self):
|
||||
return self.scoreChanged or self.sequenceChanged
|
||||
|
||||
cdef void backtrack(self):
|
||||
pass
|
||||
|
||||
property seqA:
|
||||
def __get__(self):
|
||||
return self.horizontalSeq
|
||||
@@ -210,7 +251,7 @@ cdef class DynamicProgramming:
|
||||
self.scoreChanged=True
|
||||
resetMatrix(self.matrix)
|
||||
|
||||
cdef inline int index(self,x,y):
|
||||
cdef inline int index(self, int x, int y):
|
||||
return (self.hSeq.length+1) * y + x
|
||||
|
||||
|
||||
@@ -219,6 +260,7 @@ cdef class DynamicProgramming:
|
||||
freeMatrix(self.matrix)
|
||||
freeSequence(self.hSeq)
|
||||
freeSequence(self.vSeq)
|
||||
freePath(self.path)
|
||||
|
||||
def __call__(self):
|
||||
cdef list hgaps=[]
|
||||
@@ -229,13 +271,15 @@ cdef class DynamicProgramming:
|
||||
cdef int lenh=0
|
||||
cdef int lenv=0
|
||||
cdef int h,v,p
|
||||
cdef int i
|
||||
cdef object ali
|
||||
cdef double score
|
||||
|
||||
if self.needToCompute:
|
||||
if self._needToCompute():
|
||||
score = self.doAlignment()
|
||||
h,v,b=self.backtrack()
|
||||
for p in b:
|
||||
self.backtrack()
|
||||
for i in range(self.path.length-1,-1,-1):
|
||||
p=self.path.path[i]
|
||||
if p==0:
|
||||
hp+=1
|
||||
vp+=1
|
||||
@@ -258,7 +302,7 @@ cdef class DynamicProgramming:
|
||||
vgaps.append([vp,0])
|
||||
|
||||
if lenh < self.hSeq.length:
|
||||
hseq=self.horizontalSeq[h:h+lenh]
|
||||
hseq=self.horizontalSeq[self.path.hStart:self.path.hStart+lenh]
|
||||
else:
|
||||
hseq=self.horizontalSeq
|
||||
|
||||
@@ -266,7 +310,7 @@ cdef class DynamicProgramming:
|
||||
hseq.gaps=hgaps
|
||||
|
||||
if lenv < self.vSeq.length:
|
||||
vseq=self.verticalSeq[v:v+lenv]
|
||||
vseq=self.verticalSeq[self.path.vStart:self.path.vStart+lenv]
|
||||
else:
|
||||
vseq=self.verticalSeq
|
||||
|
||||
@@ -276,10 +320,12 @@ cdef class DynamicProgramming:
|
||||
ali=Alignment()
|
||||
ali.append(hseq)
|
||||
ali.append(vseq)
|
||||
|
||||
ali.score=score
|
||||
self.alignment=ali
|
||||
|
||||
return self.alignment.clone()
|
||||
ali=self.alignment.clone()
|
||||
ali.score=self.alignment.score
|
||||
return ali
|
||||
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Generated by Cython 0.11.3 on Sun Nov 8 08:26:04 2009 */
|
||||
/* Generated by Cython 0.11.3 on Mon Jan 4 22:18:11 2010 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
@@ -335,6 +335,11 @@ static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
|
||||
|
||||
static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
|
||||
|
||||
static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
|
||||
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
||||
|
||||
static void __Pyx_WriteUnraisable(const char *name); /*proto*/
|
||||
|
||||
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size); /*proto*/
|
||||
|
||||
static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
|
||||
@@ -423,7 +428,36 @@ struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence {
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *seq;
|
||||
};
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":47
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":42
|
||||
* cdef void freeSequence(alignSequence* seq)
|
||||
*
|
||||
* cdef struct alignPath: # <<<<<<<<<<<<<<
|
||||
* long length
|
||||
* long buffsize
|
||||
*/
|
||||
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath {
|
||||
long length;
|
||||
long buffsize;
|
||||
long vStart;
|
||||
long hStart;
|
||||
long *path;
|
||||
};
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":49
|
||||
* long *path
|
||||
*
|
||||
* cdef alignPath* allocatePath(long l1,long l2,alignPath* path=?) # <<<<<<<<<<<<<<
|
||||
*
|
||||
* cdef void reversePath(alignPath* path)
|
||||
*/
|
||||
|
||||
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath {
|
||||
int __pyx_n;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath *path;
|
||||
};
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":61
|
||||
* cpdef double iupacPartialMatch(unsigned char a, unsigned char b)
|
||||
*
|
||||
* cdef class DynamicProgramming: # <<<<<<<<<<<<<<
|
||||
@@ -439,6 +473,7 @@ struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming {
|
||||
PyObject *verticalSeq;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *hSeq;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *vSeq;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath *path;
|
||||
double _opengap;
|
||||
double _extgap;
|
||||
PyObject *alignment;
|
||||
@@ -459,7 +494,7 @@ struct __pyx_obj_8obitools_5align_4_lcs_LCS {
|
||||
};
|
||||
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":47
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":61
|
||||
* cpdef double iupacPartialMatch(unsigned char a, unsigned char b)
|
||||
*
|
||||
* cdef class DynamicProgramming: # <<<<<<<<<<<<<<
|
||||
@@ -472,7 +507,9 @@ struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming {
|
||||
double (*matchScore)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, int, int);
|
||||
double (*doAlignment)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
void (*reset)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
int (*index)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, PyObject *, PyObject *);
|
||||
int (*index)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, int, int);
|
||||
int (*_needToCompute)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
void (*backtrack)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
};
|
||||
static struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming;
|
||||
|
||||
@@ -497,6 +534,9 @@ static void (*__pyx_f_8obitools_5align_8_dynamic_freeMatrix)(struct __pyx_t_8obi
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_resetMatrix)(struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *); /*proto*/
|
||||
static struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *(*__pyx_f_8obitools_5align_8_dynamic_allocateSequence)(PyObject *, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence *__pyx_optional_args); /*proto*/
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_freeSequence)(struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *); /*proto*/
|
||||
static struct __pyx_t_8obitools_5align_8_dynamic_alignPath *(*__pyx_f_8obitools_5align_8_dynamic_allocatePath)(long, long, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath *__pyx_optional_args); /*proto*/
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_reversePath)(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *); /*proto*/
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_freePath)(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *); /*proto*/
|
||||
static int (*__pyx_f_8obitools_5align_8_dynamic_bitCount)(int); /*proto*/
|
||||
static int (*__pyx_f_8obitools_5align_8_dynamic_iupacMatch)(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/
|
||||
static double (*__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch)(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/
|
||||
@@ -513,8 +553,6 @@ static char __pyx_k___main__[] = "__main__";
|
||||
static PyObject *__pyx_kp___main__;
|
||||
static char __pyx_k___init__[] = "__init__";
|
||||
static PyObject *__pyx_kp___init__;
|
||||
static char __pyx_k_backtrack[] = "backtrack";
|
||||
static PyObject *__pyx_kp_backtrack;
|
||||
static char __pyx_k_opengap[] = "opengap";
|
||||
static PyObject *__pyx_kp_opengap;
|
||||
static char __pyx_k_extgap[] = "extgap";
|
||||
@@ -632,7 +670,6 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
int __pyx_t_2;
|
||||
int __pyx_t_3;
|
||||
int __pyx_t_4;
|
||||
PyObject *__pyx_t_5 = NULL;
|
||||
__Pyx_SetupRefcountContext("doAlignment");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":31
|
||||
@@ -683,10 +720,7 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
* self.matrix.matrix[idx].score = 0
|
||||
* self.matrix.matrix[idx].path = j
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_int_0);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, 0);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":37
|
||||
* for j in range(1,self.hSeq.length+1):
|
||||
@@ -724,10 +758,7 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
* self.matrix.matrix[idx].score = 0
|
||||
* self.matrix.matrix[idx].path = -i
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_int_0, __pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), 0, __pyx_v_i);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":42
|
||||
* for i in range(1,self.vSeq.length+1):
|
||||
@@ -775,13 +806,7 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
* # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
|
||||
* scoremax = self.matrix.matrix[idx].score + \
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong((__pyx_v_j - 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyInt_FromLong((__pyx_v_i - 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), (__pyx_v_j - 1), (__pyx_v_i - 1));
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":52
|
||||
* # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
|
||||
@@ -808,13 +833,7 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
* score = self.matrix.matrix[idx].score
|
||||
* if score > scoremax :
|
||||
*/
|
||||
__pyx_t_5 = PyInt_FromLong((__pyx_v_j - 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_5, __pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), (__pyx_v_j - 1), __pyx_v_i);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":59
|
||||
* # 2 - open horizontal gap
|
||||
@@ -896,13 +915,7 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
* score = self.matrix.matrix[idx].score
|
||||
* if score > scoremax :
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyInt_FromLong((__pyx_v_i - 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, (__pyx_v_i - 1));
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":70
|
||||
* # 3 - open vertical gap
|
||||
@@ -984,13 +997,7 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
* self.matrix.matrix[idx].score = scoremax
|
||||
* self.matrix.matrix[idx].path = path
|
||||
*/
|
||||
__pyx_t_5 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_5, __pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, __pyx_v_i);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":80
|
||||
*
|
||||
@@ -1040,20 +1047,14 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
* return self.matrix.matrix[idx].score
|
||||
*
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_self->__pyx_base.hSeq->length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyInt_FromLong(__pyx_v_self->__pyx_base.vSeq->length); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_self->__pyx_base.hSeq->length, __pyx_v_self->__pyx_base.vSeq->length);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":87
|
||||
*
|
||||
* idx = self.index(self.hSeq.length,self.vSeq.length)
|
||||
* return self.matrix.matrix[idx].score # <<<<<<<<<<<<<<
|
||||
*
|
||||
* def backtrack(self):
|
||||
* cdef void backtrack(self):
|
||||
*/
|
||||
__pyx_r = (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score;
|
||||
goto __pyx_L0;
|
||||
@@ -1062,7 +1063,6 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
goto __pyx_L0;
|
||||
__pyx_L1_error:;
|
||||
__Pyx_XDECREF(__pyx_t_1);
|
||||
__Pyx_XDECREF(__pyx_t_5);
|
||||
__Pyx_AddTraceback("obitools.align._lcs.LCS.doAlignment");
|
||||
__pyx_r = 0;
|
||||
__pyx_L0:;
|
||||
@@ -1073,37 +1073,21 @@ static double __pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment(struct __pyx_obj_
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":89
|
||||
* return self.matrix.matrix[idx].score
|
||||
*
|
||||
* def backtrack(self): # <<<<<<<<<<<<<<
|
||||
* cdef list path=[]
|
||||
* cdef void backtrack(self): # <<<<<<<<<<<<<<
|
||||
* #cdef list path=[]
|
||||
* cdef int i
|
||||
*/
|
||||
|
||||
static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
|
||||
static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_v_self, PyObject *unused) {
|
||||
PyObject *__pyx_v_path = 0;
|
||||
static void __pyx_f_8obitools_5align_4_lcs_3LCS_backtrack(struct __pyx_obj_8obitools_5align_4_lcs_LCS *__pyx_v_self) {
|
||||
int __pyx_v_i;
|
||||
int __pyx_v_j;
|
||||
int __pyx_v_p;
|
||||
PyObject *__pyx_r = NULL;
|
||||
PyObject *__pyx_t_1 = NULL;
|
||||
double __pyx_t_2;
|
||||
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath __pyx_1;
|
||||
double __pyx_t_1;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_t_2;
|
||||
int __pyx_t_3;
|
||||
PyObject *__pyx_t_4 = NULL;
|
||||
int __pyx_t_5;
|
||||
__Pyx_SetupRefcountContext("backtrack");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":90
|
||||
*
|
||||
* def backtrack(self):
|
||||
* cdef list path=[] # <<<<<<<<<<<<<<
|
||||
* cdef int i
|
||||
* cdef int j
|
||||
*/
|
||||
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
|
||||
__pyx_v_path = __pyx_t_1;
|
||||
__pyx_t_1 = 0;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":95
|
||||
* cdef int p
|
||||
*
|
||||
@@ -1111,32 +1095,44 @@ static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_
|
||||
* i=self.vSeq.length
|
||||
* j=self.hSeq.length
|
||||
*/
|
||||
__pyx_t_2 = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.doAlignment(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self)); if (unlikely(__pyx_t_2 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = ((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.doAlignment(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self)); if (unlikely(__pyx_t_1 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":96
|
||||
*
|
||||
* self.doAlignment()
|
||||
* i=self.vSeq.length # <<<<<<<<<<<<<<
|
||||
* j=self.hSeq.length
|
||||
*
|
||||
* self.path=allocatePath(i,j,self.path)
|
||||
*/
|
||||
__pyx_v_i = ((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)__pyx_v_self)->__pyx_base.vSeq->length;
|
||||
__pyx_v_i = __pyx_v_self->__pyx_base.vSeq->length;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":97
|
||||
* self.doAlignment()
|
||||
* i=self.vSeq.length
|
||||
* j=self.hSeq.length # <<<<<<<<<<<<<<
|
||||
* self.path=allocatePath(i,j,self.path)
|
||||
*
|
||||
*/
|
||||
__pyx_v_j = __pyx_v_self->__pyx_base.hSeq->length;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":98
|
||||
* i=self.vSeq.length
|
||||
* j=self.hSeq.length
|
||||
* self.path=allocatePath(i,j,self.path) # <<<<<<<<<<<<<<
|
||||
*
|
||||
* while (i or j):
|
||||
*/
|
||||
__pyx_v_j = ((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)__pyx_v_self)->__pyx_base.hSeq->length;
|
||||
__pyx_1.__pyx_n = 1;
|
||||
__pyx_1.path = __pyx_v_self->__pyx_base.path;
|
||||
__pyx_t_2 = __pyx_f_8obitools_5align_8_dynamic_allocatePath(__pyx_v_i, __pyx_v_j, &__pyx_1);
|
||||
__pyx_v_self->__pyx_base.path = __pyx_t_2;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":99
|
||||
* j=self.hSeq.length
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":100
|
||||
* self.path=allocatePath(i,j,self.path)
|
||||
*
|
||||
* while (i or j): # <<<<<<<<<<<<<<
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* path.append(p)
|
||||
* self.path.path[self.path.length]=p
|
||||
*/
|
||||
while (1) {
|
||||
if (!__pyx_v_i) {
|
||||
@@ -1146,36 +1142,36 @@ static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_
|
||||
}
|
||||
if (!__pyx_t_3) break;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":100
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":101
|
||||
*
|
||||
* while (i or j):
|
||||
* p=self.matrix.matrix[self.index(j,i)].path # <<<<<<<<<<<<<<
|
||||
* path.append(p)
|
||||
* if p==0:
|
||||
* self.path.path[self.path.length]=p
|
||||
* self.path.length+=1
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_4);
|
||||
__pyx_v_p = (((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)__pyx_v_self)->__pyx_base.matrix->matrix[((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)((struct __pyx_obj_8obitools_5align_4_lcs_LCS *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_4)]).path;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":101
|
||||
* while (i or j):
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* path.append(p) # <<<<<<<<<<<<<<
|
||||
* if p==0:
|
||||
* i-=1
|
||||
*/
|
||||
__pyx_t_4 = PyInt_FromLong(__pyx_v_p); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_4);
|
||||
__pyx_t_5 = PyList_Append(((PyObject *)__pyx_v_path), __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
__pyx_v_p = (__pyx_v_self->__pyx_base.matrix->matrix[((struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, __pyx_v_i)]).path;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":102
|
||||
* while (i or j):
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* path.append(p)
|
||||
* self.path.path[self.path.length]=p # <<<<<<<<<<<<<<
|
||||
* self.path.length+=1
|
||||
* # path.append(p)
|
||||
*/
|
||||
(__pyx_v_self->__pyx_base.path->path[__pyx_v_self->__pyx_base.path->length]) = __pyx_v_p;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":103
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* self.path.path[self.path.length]=p
|
||||
* self.path.length+=1 # <<<<<<<<<<<<<<
|
||||
* # path.append(p)
|
||||
* if p==0:
|
||||
*/
|
||||
__pyx_v_self->__pyx_base.path->length += 1;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":105
|
||||
* self.path.length+=1
|
||||
* # path.append(p)
|
||||
* if p==0: # <<<<<<<<<<<<<<
|
||||
* i-=1
|
||||
* j-=1
|
||||
@@ -1183,8 +1179,8 @@ static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_
|
||||
__pyx_t_3 = (__pyx_v_p == 0);
|
||||
if (__pyx_t_3) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":103
|
||||
* path.append(p)
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":106
|
||||
* # path.append(p)
|
||||
* if p==0:
|
||||
* i-=1 # <<<<<<<<<<<<<<
|
||||
* j-=1
|
||||
@@ -1192,7 +1188,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_
|
||||
*/
|
||||
__pyx_v_i -= 1;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":104
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":107
|
||||
* if p==0:
|
||||
* i-=1
|
||||
* j-=1 # <<<<<<<<<<<<<<
|
||||
@@ -1200,10 +1196,10 @@ static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_
|
||||
* i+=p
|
||||
*/
|
||||
__pyx_v_j -= 1;
|
||||
goto __pyx_L7;
|
||||
goto __pyx_L5;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":105
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":108
|
||||
* i-=1
|
||||
* j-=1
|
||||
* elif p < 0: # <<<<<<<<<<<<<<
|
||||
@@ -1213,7 +1209,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_
|
||||
__pyx_t_3 = (__pyx_v_p < 0);
|
||||
if (__pyx_t_3) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":106
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":109
|
||||
* j-=1
|
||||
* elif p < 0:
|
||||
* i+=p # <<<<<<<<<<<<<<
|
||||
@@ -1221,66 +1217,45 @@ static PyObject *__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack(PyObject *__pyx_
|
||||
* j-=p
|
||||
*/
|
||||
__pyx_v_i += __pyx_v_p;
|
||||
goto __pyx_L7;
|
||||
goto __pyx_L5;
|
||||
}
|
||||
/*else*/ {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":108
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":111
|
||||
* i+=p
|
||||
* else:
|
||||
* j-=p # <<<<<<<<<<<<<<
|
||||
*
|
||||
* path.reverse()
|
||||
* #path.reverse()
|
||||
*/
|
||||
__pyx_v_j -= __pyx_v_p;
|
||||
}
|
||||
__pyx_L7:;
|
||||
__pyx_L5:;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":110
|
||||
* j-=p
|
||||
*
|
||||
* path.reverse() # <<<<<<<<<<<<<<
|
||||
* return 0,0,path
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":115
|
||||
* #path.reverse()
|
||||
* #reversePath(self.path)
|
||||
* self.path.hStart=0 # <<<<<<<<<<<<<<
|
||||
* self.path.vStart=0
|
||||
* #return 0,0,path
|
||||
*/
|
||||
__pyx_v_self->__pyx_base.path->hStart = 0;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":116
|
||||
* #reversePath(self.path)
|
||||
* self.path.hStart=0
|
||||
* self.path.vStart=0 # <<<<<<<<<<<<<<
|
||||
* #return 0,0,path
|
||||
*
|
||||
*/
|
||||
__pyx_t_5 = PyList_Reverse(((PyObject *)__pyx_v_path)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_self->__pyx_base.path->vStart = 0;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_lcs.pyx":111
|
||||
*
|
||||
* path.reverse()
|
||||
* return 0,0,path # <<<<<<<<<<<<<<
|
||||
*
|
||||
*
|
||||
*/
|
||||
__Pyx_XDECREF(__pyx_r);
|
||||
__pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
|
||||
__Pyx_INCREF(__pyx_int_0);
|
||||
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
|
||||
__Pyx_GIVEREF(__pyx_int_0);
|
||||
__Pyx_INCREF(__pyx_int_0);
|
||||
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_0);
|
||||
__Pyx_GIVEREF(__pyx_int_0);
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_path));
|
||||
PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_path));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_path));
|
||||
__pyx_r = ((PyObject *)__pyx_t_4);
|
||||
__pyx_t_4 = 0;
|
||||
goto __pyx_L0;
|
||||
|
||||
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
|
||||
goto __pyx_L0;
|
||||
__pyx_L1_error:;
|
||||
__Pyx_XDECREF(__pyx_t_1);
|
||||
__Pyx_XDECREF(__pyx_t_4);
|
||||
__Pyx_AddTraceback("obitools.align._lcs.LCS.backtrack");
|
||||
__pyx_r = NULL;
|
||||
__Pyx_WriteUnraisable("obitools.align._lcs.LCS.backtrack");
|
||||
__pyx_L0:;
|
||||
__Pyx_XDECREF(__pyx_v_path);
|
||||
__Pyx_XGIVEREF(__pyx_r);
|
||||
__Pyx_FinishRefcountContext();
|
||||
return __pyx_r;
|
||||
}
|
||||
static struct __pyx_vtabstruct_8obitools_5align_4_lcs_LCS __pyx_vtable_8obitools_5align_4_lcs_LCS;
|
||||
|
||||
@@ -1313,7 +1288,6 @@ static int __pyx_tp_clear_8obitools_5align_4_lcs_LCS(PyObject *o) {
|
||||
}
|
||||
|
||||
static struct PyMethodDef __pyx_methods_8obitools_5align_4_lcs_LCS[] = {
|
||||
{__Pyx_NAMESTR("backtrack"), (PyCFunction)__pyx_pf_8obitools_5align_4_lcs_3LCS_backtrack, METH_NOARGS, __Pyx_DOCSTR(0)},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -1486,7 +1460,6 @@ static struct PyModuleDef __pyx_moduledef = {
|
||||
static __Pyx_StringTabEntry __pyx_string_tab[] = {
|
||||
{&__pyx_kp___main__, __pyx_k___main__, sizeof(__pyx_k___main__), 1, 1, 1},
|
||||
{&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1},
|
||||
{&__pyx_kp_backtrack, __pyx_k_backtrack, sizeof(__pyx_k_backtrack), 1, 1, 1},
|
||||
{&__pyx_kp_opengap, __pyx_k_opengap, sizeof(__pyx_k_opengap), 1, 1, 1},
|
||||
{&__pyx_kp_extgap, __pyx_k_extgap, sizeof(__pyx_k_extgap), 1, 1, 1},
|
||||
{&__pyx_kp_needToCompute, __pyx_k_needToCompute, sizeof(__pyx_k_needToCompute), 1, 1, 1},
|
||||
@@ -1574,9 +1547,11 @@ PyMODINIT_FUNC PyInit__lcs(void)
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
__pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.matchScore = (double (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, int, int))__pyx_f_8obitools_5align_4_lcs_3LCS_matchScore;
|
||||
__pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.doAlignment = (double (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment;
|
||||
__pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.backtrack = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_4_lcs_3LCS_backtrack;
|
||||
#else
|
||||
*(void(**)(void))&__pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.matchScore = (void(*)(void))__pyx_f_8obitools_5align_4_lcs_3LCS_matchScore;
|
||||
*(void(**)(void))&__pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.doAlignment = (void(*)(void))__pyx_f_8obitools_5align_4_lcs_3LCS_doAlignment;
|
||||
*(void(**)(void))&__pyx_vtable_8obitools_5align_4_lcs_LCS.__pyx_base.backtrack = (void(*)(void))__pyx_f_8obitools_5align_4_lcs_3LCS_backtrack;
|
||||
#endif
|
||||
__pyx_type_8obitools_5align_4_lcs_LCS.tp_base = __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming;
|
||||
if (PyType_Ready(&__pyx_type_8obitools_5align_4_lcs_LCS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
@@ -1591,6 +1566,9 @@ PyMODINIT_FUNC PyInit__lcs(void)
|
||||
if (__Pyx_ImportFunction(__pyx_1, "resetMatrix", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_resetMatrix, "void (struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "allocateSequence", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_allocateSequence, "struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *(PyObject *, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "freeSequence", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_freeSequence, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "allocatePath", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_allocatePath, "struct __pyx_t_8obitools_5align_8_dynamic_alignPath *(long, long, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "reversePath", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_reversePath, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "freePath", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_freePath, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "bitCount", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_bitCount, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "iupacMatch", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_iupacMatch, "int (unsigned char, unsigned char, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "iupacPartialMatch", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch, "double (unsigned char, unsigned char, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
@@ -2041,6 +2019,68 @@ static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
|
||||
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
||||
PyThreadState *tstate = PyThreadState_GET();
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
/* Note: this is a temporary work-around to prevent crashes in Python 3.0 */
|
||||
if ((tstate->exc_type != NULL) & (tstate->exc_type != Py_None)) {
|
||||
tmp_type = tstate->exc_type;
|
||||
tmp_value = tstate->exc_value;
|
||||
tmp_tb = tstate->exc_traceback;
|
||||
PyErr_NormalizeException(&type, &value, &tb);
|
||||
PyErr_NormalizeException(&tmp_type, &tmp_value, &tmp_tb);
|
||||
tstate->exc_type = 0;
|
||||
tstate->exc_value = 0;
|
||||
tstate->exc_traceback = 0;
|
||||
PyException_SetContext(value, tmp_value);
|
||||
Py_DECREF(tmp_type);
|
||||
Py_XDECREF(tmp_tb);
|
||||
}
|
||||
#endif
|
||||
|
||||
tmp_type = tstate->curexc_type;
|
||||
tmp_value = tstate->curexc_value;
|
||||
tmp_tb = tstate->curexc_traceback;
|
||||
tstate->curexc_type = type;
|
||||
tstate->curexc_value = value;
|
||||
tstate->curexc_traceback = tb;
|
||||
Py_XDECREF(tmp_type);
|
||||
Py_XDECREF(tmp_value);
|
||||
Py_XDECREF(tmp_tb);
|
||||
}
|
||||
|
||||
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
|
||||
PyThreadState *tstate = PyThreadState_GET();
|
||||
*type = tstate->curexc_type;
|
||||
*value = tstate->curexc_value;
|
||||
*tb = tstate->curexc_traceback;
|
||||
|
||||
tstate->curexc_type = 0;
|
||||
tstate->curexc_value = 0;
|
||||
tstate->curexc_traceback = 0;
|
||||
}
|
||||
|
||||
|
||||
static void __Pyx_WriteUnraisable(const char *name) {
|
||||
PyObject *old_exc, *old_val, *old_tb;
|
||||
PyObject *ctx;
|
||||
__Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
ctx = PyString_FromString(name);
|
||||
#else
|
||||
ctx = PyUnicode_FromString(name);
|
||||
#endif
|
||||
__Pyx_ErrRestore(old_exc, old_val, old_tb);
|
||||
if (!ctx) {
|
||||
PyErr_WriteUnraisable(Py_None);
|
||||
} else {
|
||||
PyErr_WriteUnraisable(ctx);
|
||||
Py_DECREF(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __PYX_HAVE_RT_ImportType
|
||||
#define __PYX_HAVE_RT_ImportType
|
||||
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
|
||||
|
@@ -86,8 +86,8 @@ cdef class LCS(DynamicProgramming):
|
||||
idx = self.index(self.hSeq.length,self.vSeq.length)
|
||||
return self.matrix.matrix[idx].score
|
||||
|
||||
def backtrack(self):
|
||||
cdef list path=[]
|
||||
cdef void backtrack(self):
|
||||
#cdef list path=[]
|
||||
cdef int i
|
||||
cdef int j
|
||||
cdef int p
|
||||
@@ -95,10 +95,13 @@ cdef class LCS(DynamicProgramming):
|
||||
self.doAlignment()
|
||||
i=self.vSeq.length
|
||||
j=self.hSeq.length
|
||||
self.path=allocatePath(i,j,self.path)
|
||||
|
||||
while (i or j):
|
||||
p=self.matrix.matrix[self.index(j,i)].path
|
||||
path.append(p)
|
||||
self.path.path[self.path.length]=p
|
||||
self.path.length+=1
|
||||
# path.append(p)
|
||||
if p==0:
|
||||
i-=1
|
||||
j-=1
|
||||
@@ -107,8 +110,11 @@ cdef class LCS(DynamicProgramming):
|
||||
else:
|
||||
j-=p
|
||||
|
||||
path.reverse()
|
||||
return 0,0,path
|
||||
#path.reverse()
|
||||
#reversePath(self.path)
|
||||
self.path.hStart=0
|
||||
self.path.vStart=0
|
||||
#return 0,0,path
|
||||
|
||||
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Generated by Cython 0.11.3 on Sun Nov 8 08:26:04 2009 */
|
||||
/* Generated by Cython 0.11.3 on Mon Jan 4 22:18:11 2010 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
@@ -337,6 +337,11 @@ static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
|
||||
|
||||
static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
|
||||
|
||||
static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
|
||||
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
|
||||
|
||||
static void __Pyx_WriteUnraisable(const char *name); /*proto*/
|
||||
|
||||
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size); /*proto*/
|
||||
|
||||
static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
|
||||
@@ -425,7 +430,36 @@ struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence {
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *seq;
|
||||
};
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":47
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":42
|
||||
* cdef void freeSequence(alignSequence* seq)
|
||||
*
|
||||
* cdef struct alignPath: # <<<<<<<<<<<<<<
|
||||
* long length
|
||||
* long buffsize
|
||||
*/
|
||||
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath {
|
||||
long length;
|
||||
long buffsize;
|
||||
long vStart;
|
||||
long hStart;
|
||||
long *path;
|
||||
};
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":49
|
||||
* long *path
|
||||
*
|
||||
* cdef alignPath* allocatePath(long l1,long l2,alignPath* path=?) # <<<<<<<<<<<<<<
|
||||
*
|
||||
* cdef void reversePath(alignPath* path)
|
||||
*/
|
||||
|
||||
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath {
|
||||
int __pyx_n;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath *path;
|
||||
};
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":61
|
||||
* cpdef double iupacPartialMatch(unsigned char a, unsigned char b)
|
||||
*
|
||||
* cdef class DynamicProgramming: # <<<<<<<<<<<<<<
|
||||
@@ -441,6 +475,7 @@ struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming {
|
||||
PyObject *verticalSeq;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *hSeq;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *vSeq;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath *path;
|
||||
double _opengap;
|
||||
double _extgap;
|
||||
PyObject *alignment;
|
||||
@@ -463,7 +498,7 @@ struct __pyx_obj_8obitools_5align_4_nws_NWS {
|
||||
};
|
||||
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":47
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_dynamic.pxd":61
|
||||
* cpdef double iupacPartialMatch(unsigned char a, unsigned char b)
|
||||
*
|
||||
* cdef class DynamicProgramming: # <<<<<<<<<<<<<<
|
||||
@@ -476,7 +511,9 @@ struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming {
|
||||
double (*matchScore)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, int, int);
|
||||
double (*doAlignment)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
void (*reset)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
int (*index)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, PyObject *, PyObject *);
|
||||
int (*index)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, int, int);
|
||||
int (*_needToCompute)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
void (*backtrack)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *);
|
||||
};
|
||||
static struct __pyx_vtabstruct_8obitools_5align_8_dynamic_DynamicProgramming *__pyx_vtabptr_8obitools_5align_8_dynamic_DynamicProgramming;
|
||||
|
||||
@@ -501,6 +538,9 @@ static void (*__pyx_f_8obitools_5align_8_dynamic_freeMatrix)(struct __pyx_t_8obi
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_resetMatrix)(struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *); /*proto*/
|
||||
static struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *(*__pyx_f_8obitools_5align_8_dynamic_allocateSequence)(PyObject *, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence *__pyx_optional_args); /*proto*/
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_freeSequence)(struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *); /*proto*/
|
||||
static struct __pyx_t_8obitools_5align_8_dynamic_alignPath *(*__pyx_f_8obitools_5align_8_dynamic_allocatePath)(long, long, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath *__pyx_optional_args); /*proto*/
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_reversePath)(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *); /*proto*/
|
||||
static void (*__pyx_f_8obitools_5align_8_dynamic_freePath)(struct __pyx_t_8obitools_5align_8_dynamic_alignPath *); /*proto*/
|
||||
static int (*__pyx_f_8obitools_5align_8_dynamic_bitCount)(int); /*proto*/
|
||||
static int (*__pyx_f_8obitools_5align_8_dynamic_iupacMatch)(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/
|
||||
static double (*__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch)(unsigned char, unsigned char, int __pyx_skip_dispatch); /*proto*/
|
||||
@@ -516,13 +556,10 @@ static PyObject *__pyx_int_neg_6;
|
||||
static PyObject *__pyx_int_neg_8;
|
||||
static PyObject *__pyx_int_neg_2;
|
||||
static PyObject *__pyx_int_1;
|
||||
static PyObject *__pyx_int_0;
|
||||
static char __pyx_k___main__[] = "__main__";
|
||||
static PyObject *__pyx_kp___main__;
|
||||
static char __pyx_k___init__[] = "__init__";
|
||||
static PyObject *__pyx_kp___init__;
|
||||
static char __pyx_k_backtrack[] = "backtrack";
|
||||
static PyObject *__pyx_kp_backtrack;
|
||||
static char __pyx_k_match[] = "match";
|
||||
static PyObject *__pyx_kp_match;
|
||||
static char __pyx_k_mismatch[] = "mismatch";
|
||||
@@ -743,7 +780,6 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
int __pyx_t_2;
|
||||
int __pyx_t_3;
|
||||
int __pyx_t_4;
|
||||
PyObject *__pyx_t_5 = NULL;
|
||||
__Pyx_SetupRefcountContext("doAlignment");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":34
|
||||
@@ -794,10 +830,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* self.matrix.matrix[idx].score = self._opengap + (self._extgap * (j-1))
|
||||
* self.matrix.matrix[idx].path = j
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_int_0);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, 0);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":40
|
||||
* for j in range(1,self.hSeq.length+1):
|
||||
@@ -835,10 +868,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* self.matrix.matrix[idx].score = self._opengap + (self._extgap * (i-1))
|
||||
* self.matrix.matrix[idx].path = -i
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_int_0, __pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), 0, __pyx_v_i);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":45
|
||||
* for i in range(1,self.vSeq.length+1):
|
||||
@@ -886,13 +916,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
|
||||
* scoremax = self.matrix.matrix[idx].score + \
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong((__pyx_v_j - 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyInt_FromLong((__pyx_v_i - 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), (__pyx_v_j - 1), (__pyx_v_i - 1));
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":55
|
||||
* # print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
|
||||
@@ -919,13 +943,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* score = self.matrix.matrix[idx].score + \
|
||||
* self._opengap
|
||||
*/
|
||||
__pyx_t_5 = PyInt_FromLong((__pyx_v_j - 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_5, __pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), (__pyx_v_j - 1), __pyx_v_i);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":63
|
||||
* idx = self.index(j-1,i)
|
||||
@@ -974,13 +992,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* score = self.matrix.matrix[idx].score + \
|
||||
* self._opengap
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyInt_FromLong((__pyx_v_i - 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, (__pyx_v_i - 1));
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":71
|
||||
* idx = self.index(j,i-1)
|
||||
@@ -1048,13 +1060,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* delta = j-jump
|
||||
* score = self.matrix.matrix[idx].score + \
|
||||
*/
|
||||
__pyx_t_5 = PyInt_FromLong(__pyx_v_jump); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_5, __pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_jump, __pyx_v_i);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":80
|
||||
* if jump >= 0:
|
||||
@@ -1134,13 +1140,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* delta = i-jump
|
||||
* score = self.matrix.matrix[idx].score + \
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyInt_FromLong(__pyx_v_jump); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, __pyx_v_jump);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":91
|
||||
* if jump >= 0:
|
||||
@@ -1201,13 +1201,7 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* self.matrix.matrix[idx].score = scoremax
|
||||
* self.matrix.matrix[idx].path = path
|
||||
*/
|
||||
__pyx_t_5 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_5, __pyx_t_1);
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, __pyx_v_i);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":99
|
||||
*
|
||||
@@ -1300,20 +1294,14 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
* return self.matrix.matrix[idx].score
|
||||
*
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_self->__pyx_base.hSeq->length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_5 = PyInt_FromLong(__pyx_v_self->__pyx_base.vSeq->length); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_5);
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_5);
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
|
||||
__pyx_v_idx = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_self->__pyx_base.hSeq->length, __pyx_v_self->__pyx_base.vSeq->length);
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":111
|
||||
*
|
||||
* idx = self.index(self.hSeq.length,self.vSeq.length)
|
||||
* return self.matrix.matrix[idx].score # <<<<<<<<<<<<<<
|
||||
*
|
||||
* def backtrack(self):
|
||||
* cdef void backtrack(self):
|
||||
*/
|
||||
__pyx_r = (__pyx_v_self->__pyx_base.matrix->matrix[__pyx_v_idx]).score;
|
||||
goto __pyx_L0;
|
||||
@@ -1322,7 +1310,6 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
goto __pyx_L0;
|
||||
__pyx_L1_error:;
|
||||
__Pyx_XDECREF(__pyx_t_1);
|
||||
__Pyx_XDECREF(__pyx_t_5);
|
||||
__Pyx_AddTraceback("obitools.align._nws.NWS.doAlignment");
|
||||
__pyx_r = 0;
|
||||
__pyx_L0:;
|
||||
@@ -1333,37 +1320,21 @@ static double __pyx_f_8obitools_5align_4_nws_3NWS_doAlignment(struct __pyx_obj_
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":113
|
||||
* return self.matrix.matrix[idx].score
|
||||
*
|
||||
* def backtrack(self): # <<<<<<<<<<<<<<
|
||||
* cdef list path=[]
|
||||
* cdef void backtrack(self): # <<<<<<<<<<<<<<
|
||||
* #cdef list path=[]
|
||||
* cdef int i
|
||||
*/
|
||||
|
||||
static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
|
||||
static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_v_self, PyObject *unused) {
|
||||
PyObject *__pyx_v_path = 0;
|
||||
static void __pyx_f_8obitools_5align_4_nws_3NWS_backtrack(struct __pyx_obj_8obitools_5align_4_nws_NWS *__pyx_v_self) {
|
||||
int __pyx_v_i;
|
||||
int __pyx_v_j;
|
||||
int __pyx_v_p;
|
||||
PyObject *__pyx_r = NULL;
|
||||
PyObject *__pyx_t_1 = NULL;
|
||||
double __pyx_t_2;
|
||||
struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath __pyx_1;
|
||||
double __pyx_t_1;
|
||||
struct __pyx_t_8obitools_5align_8_dynamic_alignPath *__pyx_t_2;
|
||||
int __pyx_t_3;
|
||||
PyObject *__pyx_t_4 = NULL;
|
||||
int __pyx_t_5;
|
||||
__Pyx_SetupRefcountContext("backtrack");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":114
|
||||
*
|
||||
* def backtrack(self):
|
||||
* cdef list path=[] # <<<<<<<<<<<<<<
|
||||
* cdef int i
|
||||
* cdef int j
|
||||
*/
|
||||
__pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
|
||||
__pyx_v_path = __pyx_t_1;
|
||||
__pyx_t_1 = 0;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":119
|
||||
* cdef int p
|
||||
*
|
||||
@@ -1371,32 +1342,44 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_
|
||||
* i=self.vSeq.length
|
||||
* j=self.hSeq.length
|
||||
*/
|
||||
__pyx_t_2 = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.doAlignment(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self)); if (unlikely(__pyx_t_2 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = ((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.doAlignment(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self)); if (unlikely(__pyx_t_1 == 0 && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":120
|
||||
*
|
||||
* self.doAlignment()
|
||||
* i=self.vSeq.length # <<<<<<<<<<<<<<
|
||||
* j=self.hSeq.length
|
||||
*
|
||||
* self.path=allocatePath(i,j,self.path)
|
||||
*/
|
||||
__pyx_v_i = ((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->__pyx_base.vSeq->length;
|
||||
__pyx_v_i = __pyx_v_self->__pyx_base.vSeq->length;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":121
|
||||
* self.doAlignment()
|
||||
* i=self.vSeq.length
|
||||
* j=self.hSeq.length # <<<<<<<<<<<<<<
|
||||
* self.path=allocatePath(i,j,self.path)
|
||||
*
|
||||
*/
|
||||
__pyx_v_j = __pyx_v_self->__pyx_base.hSeq->length;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":122
|
||||
* i=self.vSeq.length
|
||||
* j=self.hSeq.length
|
||||
* self.path=allocatePath(i,j,self.path) # <<<<<<<<<<<<<<
|
||||
*
|
||||
* while (i or j):
|
||||
*/
|
||||
__pyx_v_j = ((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->__pyx_base.hSeq->length;
|
||||
__pyx_1.__pyx_n = 1;
|
||||
__pyx_1.path = __pyx_v_self->__pyx_base.path;
|
||||
__pyx_t_2 = __pyx_f_8obitools_5align_8_dynamic_allocatePath(__pyx_v_i, __pyx_v_j, &__pyx_1);
|
||||
__pyx_v_self->__pyx_base.path = __pyx_t_2;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":123
|
||||
* j=self.hSeq.length
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":124
|
||||
* self.path=allocatePath(i,j,self.path)
|
||||
*
|
||||
* while (i or j): # <<<<<<<<<<<<<<
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* path.append(p)
|
||||
* self.path.path[self.path.length]=p
|
||||
*/
|
||||
while (1) {
|
||||
if (!__pyx_v_i) {
|
||||
@@ -1406,36 +1389,36 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_
|
||||
}
|
||||
if (!__pyx_t_3) break;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":124
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":125
|
||||
*
|
||||
* while (i or j):
|
||||
* p=self.matrix.matrix[self.index(j,i)].path # <<<<<<<<<<<<<<
|
||||
* path.append(p)
|
||||
* if p==0:
|
||||
* self.path.path[self.path.length]=p
|
||||
* self.path.length+=1
|
||||
*/
|
||||
__pyx_t_1 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_4);
|
||||
__pyx_v_p = (((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->__pyx_base.matrix->matrix[((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_t_1, __pyx_t_4)]).path;
|
||||
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":125
|
||||
* while (i or j):
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* path.append(p) # <<<<<<<<<<<<<<
|
||||
* if p==0:
|
||||
* i-=1
|
||||
*/
|
||||
__pyx_t_4 = PyInt_FromLong(__pyx_v_p); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_4);
|
||||
__pyx_t_5 = PyList_Append(((PyObject *)__pyx_v_path), __pyx_t_4); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
__pyx_v_p = (__pyx_v_self->__pyx_base.matrix->matrix[((struct __pyx_vtabstruct_8obitools_5align_4_nws_NWS *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.index(((struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *)__pyx_v_self), __pyx_v_j, __pyx_v_i)]).path;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":126
|
||||
* while (i or j):
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* path.append(p)
|
||||
* self.path.path[self.path.length]=p # <<<<<<<<<<<<<<
|
||||
* self.path.length+=1
|
||||
* #path.append(p)
|
||||
*/
|
||||
(__pyx_v_self->__pyx_base.path->path[__pyx_v_self->__pyx_base.path->length]) = __pyx_v_p;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":127
|
||||
* p=self.matrix.matrix[self.index(j,i)].path
|
||||
* self.path.path[self.path.length]=p
|
||||
* self.path.length+=1 # <<<<<<<<<<<<<<
|
||||
* #path.append(p)
|
||||
* if p==0:
|
||||
*/
|
||||
__pyx_v_self->__pyx_base.path->length += 1;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":129
|
||||
* self.path.length+=1
|
||||
* #path.append(p)
|
||||
* if p==0: # <<<<<<<<<<<<<<
|
||||
* i-=1
|
||||
* j-=1
|
||||
@@ -1443,8 +1426,8 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_
|
||||
__pyx_t_3 = (__pyx_v_p == 0);
|
||||
if (__pyx_t_3) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":127
|
||||
* path.append(p)
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":130
|
||||
* #path.append(p)
|
||||
* if p==0:
|
||||
* i-=1 # <<<<<<<<<<<<<<
|
||||
* j-=1
|
||||
@@ -1452,7 +1435,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_
|
||||
*/
|
||||
__pyx_v_i -= 1;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":128
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":131
|
||||
* if p==0:
|
||||
* i-=1
|
||||
* j-=1 # <<<<<<<<<<<<<<
|
||||
@@ -1460,10 +1443,10 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_
|
||||
* i+=p
|
||||
*/
|
||||
__pyx_v_j -= 1;
|
||||
goto __pyx_L7;
|
||||
goto __pyx_L5;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":129
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":132
|
||||
* i-=1
|
||||
* j-=1
|
||||
* elif p < 0: # <<<<<<<<<<<<<<
|
||||
@@ -1473,7 +1456,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_
|
||||
__pyx_t_3 = (__pyx_v_p < 0);
|
||||
if (__pyx_t_3) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":130
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":133
|
||||
* j-=1
|
||||
* elif p < 0:
|
||||
* i+=p # <<<<<<<<<<<<<<
|
||||
@@ -1481,69 +1464,48 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack(PyObject *__pyx_
|
||||
* j-=p
|
||||
*/
|
||||
__pyx_v_i += __pyx_v_p;
|
||||
goto __pyx_L7;
|
||||
goto __pyx_L5;
|
||||
}
|
||||
/*else*/ {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":132
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":135
|
||||
* i+=p
|
||||
* else:
|
||||
* j-=p # <<<<<<<<<<<<<<
|
||||
*
|
||||
* path.reverse()
|
||||
* #path.reverse()
|
||||
*/
|
||||
__pyx_v_j -= __pyx_v_p;
|
||||
}
|
||||
__pyx_L7:;
|
||||
__pyx_L5:;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":134
|
||||
* j-=p
|
||||
*
|
||||
* path.reverse() # <<<<<<<<<<<<<<
|
||||
* return 0,0,path
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":139
|
||||
* #path.reverse()
|
||||
* #reversePath(self.path)
|
||||
* self.path.hStart=0 # <<<<<<<<<<<<<<
|
||||
* self.path.vStart=0
|
||||
*
|
||||
*/
|
||||
__pyx_t_5 = PyList_Reverse(((PyObject *)__pyx_v_path)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_v_self->__pyx_base.path->hStart = 0;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":135
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":140
|
||||
* #reversePath(self.path)
|
||||
* self.path.hStart=0
|
||||
* self.path.vStart=0 # <<<<<<<<<<<<<<
|
||||
*
|
||||
* path.reverse()
|
||||
* return 0,0,path # <<<<<<<<<<<<<<
|
||||
*
|
||||
* property match:
|
||||
* #return 0,0,path
|
||||
*/
|
||||
__Pyx_XDECREF(__pyx_r);
|
||||
__pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
|
||||
__Pyx_INCREF(__pyx_int_0);
|
||||
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_int_0);
|
||||
__Pyx_GIVEREF(__pyx_int_0);
|
||||
__Pyx_INCREF(__pyx_int_0);
|
||||
PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_int_0);
|
||||
__Pyx_GIVEREF(__pyx_int_0);
|
||||
__Pyx_INCREF(((PyObject *)__pyx_v_path));
|
||||
PyTuple_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_v_path));
|
||||
__Pyx_GIVEREF(((PyObject *)__pyx_v_path));
|
||||
__pyx_r = ((PyObject *)__pyx_t_4);
|
||||
__pyx_t_4 = 0;
|
||||
goto __pyx_L0;
|
||||
__pyx_v_self->__pyx_base.path->vStart = 0;
|
||||
|
||||
__pyx_r = Py_None; __Pyx_INCREF(Py_None);
|
||||
goto __pyx_L0;
|
||||
__pyx_L1_error:;
|
||||
__Pyx_XDECREF(__pyx_t_1);
|
||||
__Pyx_XDECREF(__pyx_t_4);
|
||||
__Pyx_AddTraceback("obitools.align._nws.NWS.backtrack");
|
||||
__pyx_r = NULL;
|
||||
__Pyx_WriteUnraisable("obitools.align._nws.NWS.backtrack");
|
||||
__pyx_L0:;
|
||||
__Pyx_XDECREF(__pyx_v_path);
|
||||
__Pyx_XGIVEREF(__pyx_r);
|
||||
__Pyx_FinishRefcountContext();
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":138
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":145
|
||||
*
|
||||
* property match:
|
||||
* def __get__(self): # <<<<<<<<<<<<<<
|
||||
@@ -1557,7 +1519,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_5match___get__(PyObject *_
|
||||
PyObject *__pyx_t_1 = NULL;
|
||||
__Pyx_SetupRefcountContext("__get__");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":139
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":146
|
||||
* property match:
|
||||
* def __get__(self):
|
||||
* return self._match # <<<<<<<<<<<<<<
|
||||
@@ -1565,7 +1527,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_5match___get__(PyObject *_
|
||||
* def __set__(self,match):
|
||||
*/
|
||||
__Pyx_XDECREF(__pyx_r);
|
||||
__pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->_match); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->_match); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_r = __pyx_t_1;
|
||||
__pyx_t_1 = 0;
|
||||
@@ -1583,7 +1545,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_5match___get__(PyObject *_
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":141
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":148
|
||||
* return self._match
|
||||
*
|
||||
* def __set__(self,match): # <<<<<<<<<<<<<<
|
||||
@@ -1597,17 +1559,17 @@ static int __pyx_pf_8obitools_5align_4_nws_3NWS_5match___set__(PyObject *__pyx_v
|
||||
double __pyx_t_1;
|
||||
__Pyx_SetupRefcountContext("__set__");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":142
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":149
|
||||
*
|
||||
* def __set__(self,match):
|
||||
* self._match=match # <<<<<<<<<<<<<<
|
||||
* self.scoreChanged=True
|
||||
*
|
||||
*/
|
||||
__pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_match); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_match); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->_match = __pyx_t_1;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":143
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":150
|
||||
* def __set__(self,match):
|
||||
* self._match=match
|
||||
* self.scoreChanged=True # <<<<<<<<<<<<<<
|
||||
@@ -1626,7 +1588,7 @@ static int __pyx_pf_8obitools_5align_4_nws_3NWS_5match___set__(PyObject *__pyx_v
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":146
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":153
|
||||
*
|
||||
* property mismatch:
|
||||
* def __get__(self): # <<<<<<<<<<<<<<
|
||||
@@ -1640,7 +1602,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_8mismatch___get__(PyObject
|
||||
PyObject *__pyx_t_1 = NULL;
|
||||
__Pyx_SetupRefcountContext("__get__");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":147
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":154
|
||||
* property mismatch:
|
||||
* def __get__(self):
|
||||
* return self._mismatch # <<<<<<<<<<<<<<
|
||||
@@ -1648,7 +1610,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_8mismatch___get__(PyObject
|
||||
* def __set__(self,mismatch):
|
||||
*/
|
||||
__Pyx_XDECREF(__pyx_r);
|
||||
__pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->_mismatch); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = PyFloat_FromDouble(((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->_mismatch); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_r = __pyx_t_1;
|
||||
__pyx_t_1 = 0;
|
||||
@@ -1666,7 +1628,7 @@ static PyObject *__pyx_pf_8obitools_5align_4_nws_3NWS_8mismatch___get__(PyObject
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":149
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":156
|
||||
* return self._mismatch
|
||||
*
|
||||
* def __set__(self,mismatch): # <<<<<<<<<<<<<<
|
||||
@@ -1680,17 +1642,17 @@ static int __pyx_pf_8obitools_5align_4_nws_3NWS_8mismatch___set__(PyObject *__py
|
||||
double __pyx_t_1;
|
||||
__Pyx_SetupRefcountContext("__set__");
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":150
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":157
|
||||
*
|
||||
* def __set__(self,mismatch):
|
||||
* self._mismatch=mismatch # <<<<<<<<<<<<<<
|
||||
* self.scoreChanged=True
|
||||
*
|
||||
*/
|
||||
__pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_mismatch); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_mismatch); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
((struct __pyx_obj_8obitools_5align_4_nws_NWS *)__pyx_v_self)->_mismatch = __pyx_t_1;
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":151
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/align/_nws.pyx":158
|
||||
* def __set__(self,mismatch):
|
||||
* self._mismatch=mismatch
|
||||
* self.scoreChanged=True # <<<<<<<<<<<<<<
|
||||
@@ -1767,7 +1729,6 @@ static int __pyx_setprop_8obitools_5align_4_nws_3NWS_mismatch(PyObject *o, PyObj
|
||||
}
|
||||
|
||||
static struct PyMethodDef __pyx_methods_8obitools_5align_4_nws_NWS[] = {
|
||||
{__Pyx_NAMESTR("backtrack"), (PyCFunction)__pyx_pf_8obitools_5align_4_nws_3NWS_backtrack, METH_NOARGS, __Pyx_DOCSTR(0)},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@@ -1946,7 +1907,6 @@ static struct PyModuleDef __pyx_moduledef = {
|
||||
static __Pyx_StringTabEntry __pyx_string_tab[] = {
|
||||
{&__pyx_kp___main__, __pyx_k___main__, sizeof(__pyx_k___main__), 1, 1, 1},
|
||||
{&__pyx_kp___init__, __pyx_k___init__, sizeof(__pyx_k___init__), 1, 1, 1},
|
||||
{&__pyx_kp_backtrack, __pyx_k_backtrack, sizeof(__pyx_k_backtrack), 1, 1, 1},
|
||||
{&__pyx_kp_match, __pyx_k_match, sizeof(__pyx_k_match), 1, 1, 1},
|
||||
{&__pyx_kp_mismatch, __pyx_k_mismatch, sizeof(__pyx_k_mismatch), 1, 1, 1},
|
||||
{&__pyx_kp_opengap, __pyx_k_opengap, sizeof(__pyx_k_opengap), 1, 1, 1},
|
||||
@@ -1968,7 +1928,6 @@ static int __Pyx_InitGlobals(void) {
|
||||
__pyx_int_neg_8 = PyInt_FromLong(-8); if (unlikely(!__pyx_int_neg_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
__pyx_int_neg_2 = PyInt_FromLong(-2); if (unlikely(!__pyx_int_neg_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
__pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
__pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
|
||||
return 0;
|
||||
__pyx_L1_error:;
|
||||
@@ -2040,9 +1999,11 @@ PyMODINIT_FUNC PyInit__nws(void)
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
__pyx_vtable_8obitools_5align_4_nws_NWS.__pyx_base.matchScore = (double (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *, int, int))__pyx_f_8obitools_5align_4_nws_3NWS_matchScore;
|
||||
__pyx_vtable_8obitools_5align_4_nws_NWS.__pyx_base.doAlignment = (double (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_4_nws_3NWS_doAlignment;
|
||||
__pyx_vtable_8obitools_5align_4_nws_NWS.__pyx_base.backtrack = (void (*)(struct __pyx_obj_8obitools_5align_8_dynamic_DynamicProgramming *))__pyx_f_8obitools_5align_4_nws_3NWS_backtrack;
|
||||
#else
|
||||
*(void(**)(void))&__pyx_vtable_8obitools_5align_4_nws_NWS.__pyx_base.matchScore = (void(*)(void))__pyx_f_8obitools_5align_4_nws_3NWS_matchScore;
|
||||
*(void(**)(void))&__pyx_vtable_8obitools_5align_4_nws_NWS.__pyx_base.doAlignment = (void(*)(void))__pyx_f_8obitools_5align_4_nws_3NWS_doAlignment;
|
||||
*(void(**)(void))&__pyx_vtable_8obitools_5align_4_nws_NWS.__pyx_base.backtrack = (void(*)(void))__pyx_f_8obitools_5align_4_nws_3NWS_backtrack;
|
||||
#endif
|
||||
__pyx_type_8obitools_5align_4_nws_NWS.tp_base = __pyx_ptype_8obitools_5align_8_dynamic_DynamicProgramming;
|
||||
if (PyType_Ready(&__pyx_type_8obitools_5align_4_nws_NWS) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
@@ -2057,6 +2018,9 @@ PyMODINIT_FUNC PyInit__nws(void)
|
||||
if (__Pyx_ImportFunction(__pyx_1, "resetMatrix", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_resetMatrix, "void (struct __pyx_t_8obitools_5align_8_dynamic_AlignMatrix *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "allocateSequence", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_allocateSequence, "struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *(PyObject *, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocateSequence *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "freeSequence", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_freeSequence, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignSequence *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "allocatePath", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_allocatePath, "struct __pyx_t_8obitools_5align_8_dynamic_alignPath *(long, long, struct __pyx_opt_args_8obitools_5align_8_dynamic_allocatePath *__pyx_optional_args)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "reversePath", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_reversePath, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "freePath", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_freePath, "void (struct __pyx_t_8obitools_5align_8_dynamic_alignPath *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "bitCount", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_bitCount, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "iupacMatch", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_iupacMatch, "int (unsigned char, unsigned char, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ImportFunction(__pyx_1, "iupacPartialMatch", (void (**)(void))&__pyx_f_8obitools_5align_8_dynamic_iupacPartialMatch, "double (unsigned char, unsigned char, int __pyx_skip_dispatch)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
@@ -2565,6 +2529,68 @@ static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
|
||||
PyObject *tmp_type, *tmp_value, *tmp_tb;
|
||||
PyThreadState *tstate = PyThreadState_GET();
|
||||
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
/* Note: this is a temporary work-around to prevent crashes in Python 3.0 */
|
||||
if ((tstate->exc_type != NULL) & (tstate->exc_type != Py_None)) {
|
||||
tmp_type = tstate->exc_type;
|
||||
tmp_value = tstate->exc_value;
|
||||
tmp_tb = tstate->exc_traceback;
|
||||
PyErr_NormalizeException(&type, &value, &tb);
|
||||
PyErr_NormalizeException(&tmp_type, &tmp_value, &tmp_tb);
|
||||
tstate->exc_type = 0;
|
||||
tstate->exc_value = 0;
|
||||
tstate->exc_traceback = 0;
|
||||
PyException_SetContext(value, tmp_value);
|
||||
Py_DECREF(tmp_type);
|
||||
Py_XDECREF(tmp_tb);
|
||||
}
|
||||
#endif
|
||||
|
||||
tmp_type = tstate->curexc_type;
|
||||
tmp_value = tstate->curexc_value;
|
||||
tmp_tb = tstate->curexc_traceback;
|
||||
tstate->curexc_type = type;
|
||||
tstate->curexc_value = value;
|
||||
tstate->curexc_traceback = tb;
|
||||
Py_XDECREF(tmp_type);
|
||||
Py_XDECREF(tmp_value);
|
||||
Py_XDECREF(tmp_tb);
|
||||
}
|
||||
|
||||
static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
|
||||
PyThreadState *tstate = PyThreadState_GET();
|
||||
*type = tstate->curexc_type;
|
||||
*value = tstate->curexc_value;
|
||||
*tb = tstate->curexc_traceback;
|
||||
|
||||
tstate->curexc_type = 0;
|
||||
tstate->curexc_value = 0;
|
||||
tstate->curexc_traceback = 0;
|
||||
}
|
||||
|
||||
|
||||
static void __Pyx_WriteUnraisable(const char *name) {
|
||||
PyObject *old_exc, *old_val, *old_tb;
|
||||
PyObject *ctx;
|
||||
__Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
|
||||
#if PY_MAJOR_VERSION < 3
|
||||
ctx = PyString_FromString(name);
|
||||
#else
|
||||
ctx = PyUnicode_FromString(name);
|
||||
#endif
|
||||
__Pyx_ErrRestore(old_exc, old_val, old_tb);
|
||||
if (!ctx) {
|
||||
PyErr_WriteUnraisable(Py_None);
|
||||
} else {
|
||||
PyErr_WriteUnraisable(ctx);
|
||||
Py_DECREF(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __PYX_HAVE_RT_ImportType
|
||||
#define __PYX_HAVE_RT_ImportType
|
||||
static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
|
||||
|
@@ -4,4 +4,7 @@ cdef class NWS(DynamicProgramming):
|
||||
cdef double _match
|
||||
cdef double _mismatch
|
||||
|
||||
cdef double matchScore(self,int h, int v)
|
||||
cdef double doAlignment(self) except? 0
|
||||
|
||||
|
||||
|
@@ -110,8 +110,8 @@ cdef class NWS(DynamicProgramming):
|
||||
idx = self.index(self.hSeq.length,self.vSeq.length)
|
||||
return self.matrix.matrix[idx].score
|
||||
|
||||
def backtrack(self):
|
||||
cdef list path=[]
|
||||
cdef void backtrack(self):
|
||||
#cdef list path=[]
|
||||
cdef int i
|
||||
cdef int j
|
||||
cdef int p
|
||||
@@ -119,10 +119,13 @@ cdef class NWS(DynamicProgramming):
|
||||
self.doAlignment()
|
||||
i=self.vSeq.length
|
||||
j=self.hSeq.length
|
||||
self.path=allocatePath(i,j,self.path)
|
||||
|
||||
while (i or j):
|
||||
p=self.matrix.matrix[self.index(j,i)].path
|
||||
path.append(p)
|
||||
self.path.path[self.path.length]=p
|
||||
self.path.length+=1
|
||||
#path.append(p)
|
||||
if p==0:
|
||||
i-=1
|
||||
j-=1
|
||||
@@ -131,8 +134,12 @@ cdef class NWS(DynamicProgramming):
|
||||
else:
|
||||
j-=p
|
||||
|
||||
path.reverse()
|
||||
return 0,0,path
|
||||
#path.reverse()
|
||||
#reversePath(self.path)
|
||||
self.path.hStart=0
|
||||
self.path.vStart=0
|
||||
|
||||
#return 0,0,path
|
||||
|
||||
property match:
|
||||
def __get__(self):
|
||||
|
2969
src/obitools/align/_qsassemble.c
Normal file
2969
src/obitools/align/_qsassemble.c
Normal file
File diff suppressed because it is too large
Load Diff
83
src/obitools/align/_qsassemble.pyx
Normal file
83
src/obitools/align/_qsassemble.pyx
Normal file
@@ -0,0 +1,83 @@
|
||||
#@PydevCodeAnalysisIgnore
|
||||
'''
|
||||
Created on 6 Nov. 2009
|
||||
|
||||
@author: coissac
|
||||
'''
|
||||
|
||||
from _dynamic cimport *
|
||||
from _assemble cimport DirectAssemble
|
||||
|
||||
|
||||
cdef class QSolexaDirectAssemble(DirectAssemble):
|
||||
|
||||
cdef double* hError
|
||||
cdef double* vError
|
||||
|
||||
def __init__(self,match=4,opengap=-8,extgap=-2):
|
||||
mismatch=-float(match)/3.0
|
||||
DirectAssemble.__init__(self,match,mismatch,opengap,extgap)
|
||||
|
||||
cdef double matchScore(self,int h, int v):
|
||||
cdef double score
|
||||
cdef double smatch
|
||||
cdef double smismatch
|
||||
cdef double hok=1-self.hError[h-1]
|
||||
cdef double vok=1-self.vError[v-1]
|
||||
score=iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
|
||||
smatch=((4*hok*vok-hok-vok)*(self._match-self._mismatch)+self._match+2*self._mismatch)/3
|
||||
smismatch=((hok+vok-4*hok*vok)*(self._match-self._mismatch)+2*self._match+7*self._mismatch)/9
|
||||
return smatch * score + smismatch * (1. - score)
|
||||
|
||||
property seqA:
|
||||
def __get__(self):
|
||||
return self.horizontalSeq
|
||||
|
||||
def __set__(self, seq):
|
||||
cdef object oaddresse,olength
|
||||
assert hasattr(seq, "quality"),"You must use sequence with quality indices"
|
||||
self.sequenceChanged=True
|
||||
self.horizontalSeq=seq
|
||||
self.hSeq=allocateSequence(self.horizontalSeq,self.hSeq)
|
||||
(oaddress,olength)=seq.quality.buffer_info()
|
||||
self.hError=<double*><unsigned long int>oaddress
|
||||
|
||||
property seqB:
|
||||
def __get__(self):
|
||||
return self.verticalSeq
|
||||
|
||||
def __set__(self, seq):
|
||||
cdef object oaddresse,olength
|
||||
assert hasattr(seq, "quality"),"You must use sequence with quality indices"
|
||||
self.sequenceChanged=True
|
||||
self.verticalSeq=seq
|
||||
self.vSeq=allocateSequence(self.verticalSeq,self.vSeq)
|
||||
(oaddress,olength)=seq.quality.buffer_info()
|
||||
self.vError=<double*><unsigned long int>oaddress
|
||||
|
||||
|
||||
cdef class QSolexaReverseAssemble(QSolexaDirectAssemble):
|
||||
|
||||
cdef double matchScore(self,int h, int v):
|
||||
cdef double score
|
||||
cdef double smatch
|
||||
cdef double smismatch
|
||||
cdef double hok=1-self.hError[h-1]
|
||||
cdef double vok=1-self.vError[self.vSeq.length - v]
|
||||
score=iupacPartialMatch(self.hSeq.sequence[h-1],self.vSeq.sequence[v-1])
|
||||
smatch=((4*hok*vok-hok-vok)*(self._match-self._mismatch)+self._match+2*self._mismatch)/3
|
||||
smismatch=((hok+vok-4*hok*vok)*(self._match-self._mismatch)+2*self._match+7*self._mismatch)/9
|
||||
return smatch * score + smismatch * (1. - score)
|
||||
|
||||
property seqB:
|
||||
def __get__(self):
|
||||
return self.verticalSeq.wrapped
|
||||
|
||||
def __set__(self, seq):
|
||||
cdef object oaddresse,olength
|
||||
assert hasattr(seq, "quality"),"You must use sequence with quality indices"
|
||||
self.sequenceChanged=True
|
||||
self.verticalSeq=seq.complement()
|
||||
self.vSeq=allocateSequence(self.verticalSeq,self.vSeq)
|
||||
(oaddress,olength)=seq.quality.buffer_info()
|
||||
self.vError=<double*><unsigned long int>oaddress
|
2969
src/obitools/align/_qsrassemble.c
Normal file
2969
src/obitools/align/_qsrassemble.c
Normal file
File diff suppressed because it is too large
Load Diff
3141
src/obitools/align/_rassemble.c
Normal file
3141
src/obitools/align/_rassemble.c
Normal file
File diff suppressed because it is too large
Load Diff
10
src/obitools/align/_rassemble.pxd
Normal file
10
src/obitools/align/_rassemble.pxd
Normal file
@@ -0,0 +1,10 @@
|
||||
from _nws cimport *
|
||||
|
||||
cdef class RightDirectAssemble(NWS):
|
||||
cdef double xsmax
|
||||
cdef int xmax
|
||||
|
||||
cdef double doAlignment(self) except? 0
|
||||
|
||||
cdef class RightReverseAssemble(RightDirectAssemble):
|
||||
pass
|
157
src/obitools/align/_rassemble.pyx
Normal file
157
src/obitools/align/_rassemble.pyx
Normal file
@@ -0,0 +1,157 @@
|
||||
#...@PydevCodeAnalysisIgnore
|
||||
'''
|
||||
Created on 6 Nov. 2009
|
||||
|
||||
@author: coissac
|
||||
'''
|
||||
|
||||
from _rassemble cimport *
|
||||
|
||||
|
||||
cdef class RightDirectAssemble(NWS):
|
||||
|
||||
def __init__(self,match=4,mismatch=-6,opengap=-8,extgap=-2):
|
||||
NWS.__init__(self,match,mismatch,opengap,extgap)
|
||||
self.xsmax=0
|
||||
self.xmax=0
|
||||
|
||||
cdef double doAlignment(self) except? 0:
|
||||
cdef int i # vertical index
|
||||
cdef int j # horizontal index
|
||||
cdef int idx
|
||||
cdef int jump
|
||||
cdef int delta
|
||||
cdef double score
|
||||
cdef double scoremax
|
||||
cdef int path
|
||||
|
||||
|
||||
if self.needToCompute:
|
||||
self.allocate()
|
||||
self.reset()
|
||||
self.xsmax=0
|
||||
self.xmax=0
|
||||
|
||||
for j in range(1,self.hSeq.length+1):
|
||||
idx = self.index(j,0)
|
||||
self.matrix.matrix[idx].score = self._opengap + (self._extgap * (j-1))
|
||||
self.matrix.matrix[idx].path = j
|
||||
|
||||
for i in range(1,self.vSeq.length+1):
|
||||
idx = self.index(0,i)
|
||||
self.matrix.matrix[idx].score = 0
|
||||
self.matrix.matrix[idx].path = -i
|
||||
|
||||
for i in range(1,self.vSeq.length+1):
|
||||
for j in range(1,self.hSeq.length+1):
|
||||
|
||||
# 1 - came from diagonal
|
||||
idx = self.index(j-1,i-1)
|
||||
# print "computing cell : %d,%d --> %d/%d" % (j,i,self.index(j,i),self.matrix.msize),
|
||||
scoremax = self.matrix.matrix[idx].score + \
|
||||
self.matchScore(j,i)
|
||||
path = 0
|
||||
|
||||
# print "so=%f sd=%f sm=%f" % (self.matrix.matrix[idx].score,self.matchScore(j,i),scoremax),
|
||||
|
||||
# 2 - open horizontal gap
|
||||
idx = self.index(j-1,i)
|
||||
score = self.matrix.matrix[idx].score+ \
|
||||
self._opengap
|
||||
if score > scoremax :
|
||||
scoremax = score
|
||||
path = +1
|
||||
|
||||
# 3 - open vertical gap
|
||||
idx = self.index(j,i-1)
|
||||
score = self.matrix.matrix[idx].score + \
|
||||
self._opengap
|
||||
if score > scoremax :
|
||||
scoremax = score
|
||||
path = -1
|
||||
|
||||
# 4 - extend horizontal gap
|
||||
jump = self.matrix.bestHJump[i]
|
||||
if jump >= 0:
|
||||
idx = self.index(jump,i)
|
||||
delta = j-jump
|
||||
score = self.matrix.matrix[idx].score + \
|
||||
self._extgap * delta
|
||||
if score > scoremax :
|
||||
scoremax = score
|
||||
path = delta+1
|
||||
|
||||
# 5 - extend vertical gap
|
||||
jump = self.matrix.bestVJump[j]
|
||||
if jump >= 0:
|
||||
idx = self.index(j,jump)
|
||||
delta = i-jump
|
||||
score = self.matrix.matrix[idx].score + \
|
||||
self._extgap * delta
|
||||
if score > scoremax :
|
||||
scoremax = score
|
||||
path = -delta-1
|
||||
|
||||
idx = self.index(j,i)
|
||||
self.matrix.matrix[idx].score = scoremax
|
||||
self.matrix.matrix[idx].path = path
|
||||
|
||||
if path == -1:
|
||||
self.matrix.bestVJump[j]=i
|
||||
elif path == +1 :
|
||||
self.matrix.bestHJump[i]=j
|
||||
|
||||
if i==self.vSeq.length and scoremax > self.xsmax:
|
||||
self.xsmax=scoremax
|
||||
self.xmax=j
|
||||
|
||||
self.sequenceChanged=False
|
||||
self.scoreChanged=False
|
||||
|
||||
return self.xsmax
|
||||
|
||||
cdef void backtrack(self):
|
||||
cdef list path=[]
|
||||
cdef int i
|
||||
cdef int j
|
||||
cdef int p
|
||||
|
||||
self.doAlignment()
|
||||
j=self.xmax
|
||||
i=self.vSeq.length
|
||||
self.path=allocatePath(i,j+1,self.path)
|
||||
|
||||
if self.xmax<self.hSeq.length:
|
||||
self.path.path[self.path.length]=self.vSeq.length-self.xmax
|
||||
self.path.length+=1
|
||||
|
||||
while (i or j):
|
||||
p=self.matrix.matrix[self.index(j,i)].path
|
||||
self.path.path[self.path.length]=p
|
||||
self.path.length+=1
|
||||
#path.append(p)
|
||||
if p==0:
|
||||
i-=1
|
||||
j-=1
|
||||
elif p < 0:
|
||||
i+=p
|
||||
else:
|
||||
j-=p
|
||||
|
||||
#path.reverse()
|
||||
self.path.hStart=0
|
||||
self.path.vStart=0
|
||||
#reversePath(self.path)
|
||||
#return 0,0,path
|
||||
|
||||
|
||||
cdef class RightReverseAssemble(RightDirectAssemble):
|
||||
|
||||
property seqB:
|
||||
def __get__(self):
|
||||
return self.verticalSeq.wrapped
|
||||
|
||||
def __set__(self, seq):
|
||||
self.sequenceChanged=True
|
||||
self.verticalSeq=seq.complement()
|
||||
self.vSeq=allocateSequence(self.verticalSeq,self.vSeq)
|
209
src/obitools/fastq/__init__.py
Normal file
209
src/obitools/fastq/__init__.py
Normal file
@@ -0,0 +1,209 @@
|
||||
'''
|
||||
Created on 29 ao<61>t 2009
|
||||
|
||||
@author: coissac
|
||||
'''
|
||||
|
||||
from obitools import BioSequence
|
||||
from obitools.format.genericparser import genericEntryIteratorGenerator
|
||||
from obitools import bioSeqGenerator,AASequence,NucSequence
|
||||
from obitools.fasta import _parseFastaTag,parseFastaDescription
|
||||
from _fastq import fastqQualitySangerDecoder,fastqQualitySolexaDecoder
|
||||
from _fastq import qualityToSangerError,qualityToSolexaError
|
||||
from _fastq import errorToSangerFastQStr
|
||||
from obitools.utils import universalOpen
|
||||
|
||||
fastqEntryIterator=genericEntryIteratorGenerator(startEntry='^@',endEntry="^\+",strip=True,join=False)
|
||||
|
||||
def fastqParserGenetator(fastqvariant='sanger',bioseqfactory=NucSequence,tagparser=_parseFastaTag):
|
||||
|
||||
qualityDecoder,errorDecoder = {'sanger' : (fastqQualitySangerDecoder,qualityToSangerError),
|
||||
'solexa' : (fastqQualitySolexaDecoder,qualityToSolexaError),
|
||||
'illumina' : (fastqQualitySolexaDecoder,qualityToSangerError)}[fastqvariant]
|
||||
|
||||
def fastqParser(seq):
|
||||
'''
|
||||
Parse a fasta record.
|
||||
|
||||
@attention: internal purpose function
|
||||
|
||||
@param seq: a sequence object containing all lines corresponding
|
||||
to one fasta sequence
|
||||
@type seq: C{list} or C{tuple} of C{str}
|
||||
|
||||
@param bioseqfactory: a callable object return a BioSequence
|
||||
instance.
|
||||
@type bioseqfactory: a callable object
|
||||
|
||||
@param tagparser: a compiled regular expression usable
|
||||
to identify key, value couples from
|
||||
title line.
|
||||
@type tagparser: regex instance
|
||||
|
||||
@return: a C{BioSequence} instance
|
||||
'''
|
||||
|
||||
title = seq[0][1:].split(None,1)
|
||||
id=title[0]
|
||||
if len(title) == 2:
|
||||
definition,info=parseFastaDescription(title[1], tagparser)
|
||||
else:
|
||||
info= {}
|
||||
definition=None
|
||||
|
||||
quality=errorDecoder(qualityDecoder(seq[3]))
|
||||
|
||||
seq=seq[1]
|
||||
|
||||
seq = bioseqfactory(id, seq, definition,False,**info)
|
||||
seq.quality = quality
|
||||
|
||||
return seq
|
||||
|
||||
return fastqParser
|
||||
|
||||
|
||||
def fastqIterator(file,fastqvariant='sanger',bioseqfactory=NucSequence,tagparser=_parseFastaTag):
|
||||
'''
|
||||
iterate through a fasta file sequence by sequence.
|
||||
Returned sequences by this iterator will be BioSequence
|
||||
instances
|
||||
|
||||
@param file: a line iterator containing fasta data or a filename
|
||||
@type file: an iterable object or str
|
||||
@param bioseqfactory: a callable object return a BioSequence
|
||||
instance.
|
||||
@type bioseqfactory: a callable object
|
||||
|
||||
@param tagparser: a compiled regular expression usable
|
||||
to identify key, value couples from
|
||||
title line.
|
||||
@type tagparser: regex instance
|
||||
|
||||
@return: an iterator on C{BioSequence} instance
|
||||
|
||||
@see: L{fastaNucIterator}
|
||||
@see: L{fastaAAIterator}
|
||||
|
||||
'''
|
||||
fastqParser=fastqParserGenetator(fastqvariant, bioseqfactory, tagparser)
|
||||
file = universalOpen(file)
|
||||
for entry in fastqEntryIterator(file):
|
||||
title=entry[0]
|
||||
seq="".join(entry[1:-1])
|
||||
quality=''
|
||||
while (len(quality) < len(seq)):
|
||||
quality+=file.next().strip()
|
||||
yield fastqParser([title,seq,'+',quality])
|
||||
|
||||
def fastqSangerIterator(file,tagparser=_parseFastaTag):
|
||||
'''
|
||||
iterate through a fastq file sequence by sequence.
|
||||
Returned sequences by this iterator will be NucSequence
|
||||
instances
|
||||
|
||||
@param file: a line iterator containint fasta data
|
||||
@type file: an iterable object
|
||||
|
||||
@param tagparser: a compiled regular expression usable
|
||||
to identify key, value couples from
|
||||
title line.
|
||||
@type tagparser: regex instance
|
||||
|
||||
@return: an iterator on C{NucBioSequence} instance
|
||||
|
||||
@see: L{fastqIterator}
|
||||
@see: L{fastqAAIterator}
|
||||
'''
|
||||
return fastqIterator(file,'sanger',NucSequence,tagparser)
|
||||
|
||||
def fastqSolexaIterator(file,tagparser=_parseFastaTag):
|
||||
'''
|
||||
iterate through a fastq file sequence by sequence.
|
||||
Returned sequences by this iterator will be NucSequence
|
||||
instances
|
||||
|
||||
@param file: a line iterator containint fasta data
|
||||
@type file: an iterable object
|
||||
|
||||
@param tagparser: a compiled regular expression usable
|
||||
to identify key, value couples from
|
||||
title line.
|
||||
@type tagparser: regex instance
|
||||
|
||||
@return: an iterator on C{NucBioSequence} instance
|
||||
|
||||
@see: L{fastqIterator}
|
||||
@see: L{fastqAAIterator}
|
||||
'''
|
||||
return fastqIterator(file,'solexa',NucSequence,tagparser)
|
||||
|
||||
def fastqIlluminaIterator(file,tagparser=_parseFastaTag):
|
||||
'''
|
||||
iterate through a fastq file sequence by sequence.
|
||||
Returned sequences by this iterator will be NucSequence
|
||||
instances
|
||||
|
||||
@param file: a line iterator containint fasta data
|
||||
@type file: an iterable object
|
||||
|
||||
@param tagparser: a compiled regular expression usable
|
||||
to identify key, value couples from
|
||||
title line.
|
||||
@type tagparser: regex instance
|
||||
|
||||
@return: an iterator on C{NucBioSequence} instance
|
||||
|
||||
@see: L{fastqIterator}
|
||||
@see: L{fastqAAIterator}
|
||||
'''
|
||||
return fastqIterator(file,'illumina',NucSequence,tagparser)
|
||||
|
||||
def fastqAAIterator(file,tagparser=_parseFastaTag):
|
||||
'''
|
||||
iterate through a fastq file sequence by sequence.
|
||||
Returned sequences by this iterator will be AASequence
|
||||
instances
|
||||
|
||||
@param file: a line iterator containing fasta data
|
||||
@type file: an iterable object
|
||||
|
||||
@param tagparser: a compiled regular expression usable
|
||||
to identify key, value couples from
|
||||
title line.
|
||||
@type tagparser: regex instance
|
||||
|
||||
@return: an iterator on C{AABioSequence} instance
|
||||
|
||||
@see: L{fastqIterator}
|
||||
@see: L{fastqNucIterator}
|
||||
'''
|
||||
return fastqIterator(file,'sanger',AASequence,tagparser)
|
||||
|
||||
def formatFastq(data,gbmode=False):
|
||||
if isinstance(data, BioSequence):
|
||||
data = [data]
|
||||
rep = []
|
||||
for sequence in data:
|
||||
seq = str(sequence)
|
||||
if sequence.definition is None:
|
||||
definition=''
|
||||
else:
|
||||
definition=sequence.definition
|
||||
info='; '.join(['%s=%s' % x for x in sequence.rawiteritems()])
|
||||
if info:
|
||||
info=info+';'
|
||||
id = sequence.id
|
||||
if gbmode:
|
||||
if 'gi' in sequence:
|
||||
id = "gi|%s|%s" % (sequence['gi'],id)
|
||||
else:
|
||||
id = "lcl|%s|" % (id)
|
||||
if hasattr(sequence, "quality"):
|
||||
quality=errorToSangerFastQStr(sequence.quality)
|
||||
else:
|
||||
quality="I"*len(sequence)
|
||||
title='@%s %s %s' %(id,info,definition)
|
||||
rep.append("%s\n%s\n+\n%s" % (title,seq,quality))
|
||||
return '\n'.join(rep)
|
||||
|
2915
src/obitools/fastq/_fastq.c
Normal file
2915
src/obitools/fastq/_fastq.c
Normal file
File diff suppressed because it is too large
Load Diff
156
src/obitools/fastq/_fastq.pyx
Normal file
156
src/obitools/fastq/_fastq.pyx
Normal file
@@ -0,0 +1,156 @@
|
||||
'''
|
||||
Created on 16 sept. 2009
|
||||
|
||||
@author: coissac
|
||||
'''
|
||||
|
||||
from array import array
|
||||
|
||||
cdef import from "math.h" :
|
||||
double log10(double x)
|
||||
double rint(double x)
|
||||
|
||||
cdef import from "string.h":
|
||||
int strlen(char* s)
|
||||
|
||||
cdef import from "stdlib.h":
|
||||
void* malloc(int size) except NULL
|
||||
void* realloc(void* chunk,int size) except NULL
|
||||
void free(void* chunk)
|
||||
|
||||
cdef import from "string.h":
|
||||
void bzero(void *s, size_t n)
|
||||
|
||||
|
||||
|
||||
cpdef object fastqQualityDecoder(char* qualstring, int base=0):
|
||||
cdef int i=0
|
||||
cdef int mq=255
|
||||
cdef object quality
|
||||
cdef object oaddresse,olength
|
||||
cdef int length
|
||||
cdef double* bdouble
|
||||
|
||||
quality = array('d',[0] * strlen(qualstring))
|
||||
(oaddress,olength)=quality.buffer_info()
|
||||
bdouble=<double*><unsigned long int>oaddress
|
||||
|
||||
if base==0:
|
||||
mq = 255
|
||||
while (qualstring[i]!=0):
|
||||
if qualstring[i]<mq:
|
||||
mq=qualstring[i]
|
||||
i+=1
|
||||
if mq < 59:
|
||||
base=33
|
||||
else:
|
||||
base=64
|
||||
|
||||
i=0
|
||||
while (qualstring[i]!=0):
|
||||
bdouble[i]=qualstring[i]-base
|
||||
i+=1
|
||||
return quality
|
||||
|
||||
cpdef object fastqQualitySangerDecoder(char* qualstring):
|
||||
return fastqQualityDecoder(qualstring,33)
|
||||
|
||||
cpdef object fastqQualitySolexaDecoder(char* qualstring):
|
||||
return fastqQualityDecoder(qualstring,64)
|
||||
|
||||
cpdef object qualityToSolexaError(object quality):
|
||||
cdef int i=0
|
||||
cdef int lq
|
||||
cdef double proba
|
||||
cdef object oaddresse,olength
|
||||
cdef int length
|
||||
cdef double* bdouble
|
||||
|
||||
(oaddress,olength)=quality.buffer_info()
|
||||
bdouble=<double*><unsigned long int>oaddress
|
||||
lq=olength
|
||||
|
||||
for i in range(lq):
|
||||
proba=1/(1+10.**(bdouble[i]/10.))
|
||||
bdouble[i]=proba
|
||||
|
||||
return quality
|
||||
|
||||
cpdef object qualityToSangerError(object quality):
|
||||
cdef int i=0
|
||||
cdef int lq
|
||||
cdef double proba
|
||||
cdef object oaddresse,olength
|
||||
cdef int length
|
||||
cdef double* bdouble
|
||||
|
||||
(oaddress,olength)=quality.buffer_info()
|
||||
bdouble=<double*><unsigned long int>oaddress
|
||||
lq=olength
|
||||
|
||||
for i in range(lq):
|
||||
proba=10.**(-bdouble[i]/10.)
|
||||
bdouble[i]=proba
|
||||
|
||||
return quality
|
||||
|
||||
cpdef object errorToSangerQuality(object quality):
|
||||
cdef int i=0
|
||||
cdef int lq
|
||||
cdef double proba
|
||||
cdef object oaddresse,olength
|
||||
cdef int length
|
||||
cdef double* bdouble
|
||||
|
||||
(oaddress,olength)=quality.buffer_info()
|
||||
bdouble=<double*><unsigned long int>oaddress
|
||||
lq=olength
|
||||
|
||||
for i in range(lq):
|
||||
proba=-rint(log10(bdouble[i])*10)
|
||||
bdouble[i]=proba
|
||||
|
||||
return quality
|
||||
|
||||
cpdef object solexaToSangerQuality(object quality):
|
||||
cdef int i=0
|
||||
cdef int lq
|
||||
cdef double proba
|
||||
cdef object oaddresse,olength
|
||||
cdef int length
|
||||
cdef double* bdouble
|
||||
|
||||
(oaddress,olength)=quality.buffer_info()
|
||||
bdouble=<double*><unsigned long int>oaddress
|
||||
lq=olength
|
||||
|
||||
for i in range(lq):
|
||||
proba=-rint(log10(1/(1+10.**(bdouble[i]/10.)))*10)
|
||||
bdouble[i]=proba
|
||||
|
||||
return quality
|
||||
|
||||
cpdef object errorToSangerFastQStr(object quality):
|
||||
cdef int i=0
|
||||
cdef int lq
|
||||
cdef double proba
|
||||
cdef object oaddresse,olength
|
||||
cdef int length
|
||||
cdef double* bdouble
|
||||
cdef char* result
|
||||
cdef str code
|
||||
|
||||
(oaddress,olength)=quality.buffer_info()
|
||||
bdouble=<double*><unsigned long int>oaddress
|
||||
lq=olength
|
||||
result=<char *>malloc(olength+1)
|
||||
result[olength]=0
|
||||
|
||||
for i in range(lq):
|
||||
proba=-rint(log10(bdouble[i])*10)
|
||||
if proba > 93.:
|
||||
proba=93.
|
||||
result[i]=33 + <int>proba
|
||||
code=result
|
||||
free(<void *>result)
|
||||
return code
|
@@ -5,7 +5,7 @@ import re
|
||||
|
||||
from obitools.utils import universalOpen
|
||||
|
||||
def genericEntryIteratorGenerator(startEntry=None,endEntry=None,head=False,tail=False,strip=False):
|
||||
def genericEntryIteratorGenerator(startEntry=None,endEntry=None,head=False,tail=False,strip=False,join=True):
|
||||
'''
|
||||
Transfome a text line iterator to an entry oriented iterator.
|
||||
|
||||
@@ -62,10 +62,15 @@ def genericEntryIteratorGenerator(startEntry=None,endEntry=None,head=False,tail=
|
||||
if end:
|
||||
if endEntry is not None:
|
||||
entry.append(line)
|
||||
e = ''.join(entry)
|
||||
if join:
|
||||
e = ''.join(entry)
|
||||
if strip:
|
||||
e=e.strip()
|
||||
else:
|
||||
e=entry
|
||||
if strip:
|
||||
e=[x.strip() for x in e]
|
||||
entry=[]
|
||||
if strip:
|
||||
e=e.strip()
|
||||
yield e
|
||||
started=False
|
||||
if endEntry is not None:
|
||||
@@ -78,9 +83,14 @@ def genericEntryIteratorGenerator(startEntry=None,endEntry=None,head=False,tail=
|
||||
|
||||
except StopIteration:
|
||||
if entry and (endEntry is None or tail):
|
||||
e = ''.join(entry)
|
||||
if strip:
|
||||
e=e.strip()
|
||||
if join:
|
||||
e = ''.join(entry)
|
||||
if strip:
|
||||
e=e.strip()
|
||||
else:
|
||||
e=entry
|
||||
if strip:
|
||||
e=[x.strip() for x in e]
|
||||
yield e
|
||||
|
||||
|
||||
|
@@ -135,6 +135,8 @@ class SimpleLocation(Location):
|
||||
|
||||
self._begin = begin
|
||||
self._end = end
|
||||
self._before=False
|
||||
self._after=False
|
||||
|
||||
def _extractSequence(self,sequence):
|
||||
|
||||
@@ -191,6 +193,26 @@ class SimpleLocation(Location):
|
||||
begin = property(getBegin,None,None,"beginning position of the location")
|
||||
end = property(getEnd,None,None,"ending position of the location")
|
||||
|
||||
def getBefore(self):
|
||||
return self._before
|
||||
|
||||
def getAfter(self):
|
||||
return self._after
|
||||
|
||||
def setBefore(self,value):
|
||||
assert isinstance(value, bool)
|
||||
self._before=value
|
||||
|
||||
def setAfter(self,value):
|
||||
assert isinstance(value, bool)
|
||||
self._after=value
|
||||
|
||||
before=property(getBefore,setBefore,None)
|
||||
after=property(getAfter,setAfter,None)
|
||||
|
||||
|
||||
|
||||
|
||||
class PointLocation(Location):
|
||||
"""
|
||||
A point location describes a location on a sequence
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Generated by Cython 0.11.3 on Fri Dec 18 14:54:07 2009 */
|
||||
/* Generated by Cython 0.11.3 on Mon Jan 4 22:18:11 2010 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
@@ -427,10 +427,10 @@ static char __pyx_k_t[] = "t";
|
||||
static PyObject *__pyx_kp_t;
|
||||
static char __pyx_k_size[] = "size";
|
||||
static PyObject *__pyx_kp_size;
|
||||
static char __pyx_k_1[] = "w1";
|
||||
static PyObject *__pyx_kp_1;
|
||||
static char __pyx_k_2[] = "w2";
|
||||
static PyObject *__pyx_kp_2;
|
||||
static char __pyx_k_28[] = "w1";
|
||||
static PyObject *__pyx_kp_28;
|
||||
static char __pyx_k_29[] = "w2";
|
||||
static PyObject *__pyx_kp_29;
|
||||
static char __pyx_k_word[] = "word";
|
||||
static PyObject *__pyx_kp_word;
|
||||
static char __pyx_k_pattern[] = "pattern";
|
||||
@@ -441,39 +441,39 @@ static char __pyx_k_xrange[] = "xrange";
|
||||
static PyObject *__pyx_kp_xrange;
|
||||
static char __pyx_k_join[] = "join";
|
||||
static PyObject *__pyx_kp_join;
|
||||
static char __pyx_k_5[] = "acgt";
|
||||
static PyObject *__pyx_kp_5;
|
||||
static char __pyx_k_32[] = "acgt";
|
||||
static PyObject *__pyx_kp_32;
|
||||
static char __pyx_k_lower[] = "lower";
|
||||
static PyObject *__pyx_kp_lower;
|
||||
static char __pyx_k_7[] = "c";
|
||||
static PyObject *__pyx_kp_7;
|
||||
static char __pyx_k_8[] = "g";
|
||||
static PyObject *__pyx_kp_8;
|
||||
static char __pyx_k_9[] = "t";
|
||||
static PyObject *__pyx_kp_9;
|
||||
static char __pyx_k_10[] = "a";
|
||||
static PyObject *__pyx_kp_10;
|
||||
static char __pyx_k_34[] = "c";
|
||||
static PyObject *__pyx_kp_34;
|
||||
static char __pyx_k_35[] = "g";
|
||||
static PyObject *__pyx_kp_35;
|
||||
static char __pyx_k_36[] = "t";
|
||||
static PyObject *__pyx_kp_36;
|
||||
static char __pyx_k_37[] = "a";
|
||||
static PyObject *__pyx_kp_37;
|
||||
static char __pyx_k_RuntimeError[] = "RuntimeError";
|
||||
static PyObject *__pyx_kp_RuntimeError;
|
||||
static char __pyx_k_12[] = "armwdhvn";
|
||||
static PyObject *__pyx_kp_12;
|
||||
static char __pyx_k_13[] = "cymsbhvn";
|
||||
static PyObject *__pyx_kp_13;
|
||||
static char __pyx_k_14[] = "grksbdvn";
|
||||
static PyObject *__pyx_kp_14;
|
||||
static char __pyx_k_15[] = "tykwbdhn";
|
||||
static PyObject *__pyx_kp_15;
|
||||
static char __pyx_k_39[] = "armwdhvn";
|
||||
static PyObject *__pyx_kp_39;
|
||||
static char __pyx_k_40[] = "cymsbhvn";
|
||||
static PyObject *__pyx_kp_40;
|
||||
static char __pyx_k_41[] = "grksbdvn";
|
||||
static PyObject *__pyx_kp_41;
|
||||
static char __pyx_k_42[] = "tykwbdhn";
|
||||
static PyObject *__pyx_kp_42;
|
||||
static PyObject *__pyx_builtin_bin;
|
||||
static PyObject *__pyx_builtin_xrange;
|
||||
static PyObject *__pyx_builtin_RuntimeError;
|
||||
static PyObject *__pyx_kp_3;
|
||||
static char __pyx_k_3[] = "(a:%s,c:%s,g:%s,t:%s)";
|
||||
static PyObject *__pyx_kp_4;
|
||||
static char __pyx_k_4[] = "";
|
||||
static PyObject *__pyx_kp_6;
|
||||
static PyObject *__pyx_kp_11;
|
||||
static char __pyx_k_6[] = "Word length should be less or equal to 32";
|
||||
static char __pyx_k_11[] = "word should only contain a, c, g or t (%s)";
|
||||
static PyObject *__pyx_kp_30;
|
||||
static char __pyx_k_30[] = "(a:%s,c:%s,g:%s,t:%s)";
|
||||
static PyObject *__pyx_kp_31;
|
||||
static char __pyx_k_31[] = "";
|
||||
static PyObject *__pyx_kp_33;
|
||||
static PyObject *__pyx_kp_38;
|
||||
static char __pyx_k_33[] = "Word length should be less or equal to 32";
|
||||
static char __pyx_k_38[] = "word should only contain a, c, g or t (%s)";
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/word/_binary.pyx":15
|
||||
*
|
||||
@@ -695,7 +695,7 @@ static PyObject *__pyx_pf_8obitools_4word_7_binary_11WordPattern___str__(PyObjec
|
||||
__pyx_t_2 = 0;
|
||||
__pyx_t_3 = 0;
|
||||
__pyx_t_4 = 0;
|
||||
__pyx_t_4 = PyNumber_Remainder(__pyx_kp_3, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_4 = PyNumber_Remainder(__pyx_kp_30, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_4);
|
||||
__Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
|
||||
__pyx_r = __pyx_t_4;
|
||||
@@ -926,7 +926,7 @@ static PyObject *__pyx_pf_8obitools_4word_7_binary_wordDist(PyObject *__pyx_self
|
||||
unsigned PY_LONG_LONG __pyx_v_w2;
|
||||
PyObject *__pyx_r = NULL;
|
||||
PyObject *__pyx_t_1 = NULL;
|
||||
static PyObject **__pyx_pyargnames[] = {&__pyx_kp_1,&__pyx_kp_2,0};
|
||||
static PyObject **__pyx_pyargnames[] = {&__pyx_kp_28,&__pyx_kp_29,0};
|
||||
__Pyx_SetupRefcountContext("wordDist");
|
||||
__pyx_self = __pyx_self;
|
||||
if (unlikely(__pyx_kwds)) {
|
||||
@@ -940,11 +940,11 @@ static PyObject *__pyx_pf_8obitools_4word_7_binary_wordDist(PyObject *__pyx_self
|
||||
}
|
||||
switch (PyTuple_GET_SIZE(__pyx_args)) {
|
||||
case 0:
|
||||
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_1);
|
||||
values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_28);
|
||||
if (likely(values[0])) kw_args--;
|
||||
else goto __pyx_L5_argtuple_error;
|
||||
case 1:
|
||||
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_2);
|
||||
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_29);
|
||||
if (likely(values[1])) kw_args--;
|
||||
else {
|
||||
__Pyx_RaiseArgtupleInvalid("wordDist", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
|
||||
@@ -2032,7 +2032,7 @@ static PyObject *__pyx_f_8obitools_4word_7_binary_decodeWord(unsigned PY_LONG_L
|
||||
* cpdef int encodeWord(word) except -1:
|
||||
*/
|
||||
__Pyx_XDECREF(((PyObject *)__pyx_r));
|
||||
__pyx_t_1 = PyObject_GetAttr(__pyx_kp_4, __pyx_kp_join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_1 = PyObject_GetAttr(__pyx_kp_31, __pyx_kp_join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_1);
|
||||
__pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(((PyObject *)__pyx_t_2));
|
||||
@@ -2085,7 +2085,7 @@ static PyObject *__pyx_f_8obitools_4word_7_binary_decodeWord(unsigned PY_LONG_L
|
||||
__pyx_t_4 = PyNumber_And(__pyx_t_6, __pyx_int_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_4);
|
||||
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
|
||||
__pyx_1 = PyObject_GetItem(__pyx_kp_5, __pyx_t_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_1 = PyObject_GetItem(__pyx_kp_32, __pyx_t_4); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_1);
|
||||
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
|
||||
__pyx_t_7 = PyList_Append(__pyx_t_2, (PyObject*)__pyx_1); if (unlikely(__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
@@ -2234,7 +2234,7 @@ static int __pyx_f_8obitools_4word_7_binary_encodeWord(PyObject *__pyx_v_word,
|
||||
#ifndef PYREX_WITHOUT_ASSERTIONS
|
||||
__pyx_t_1 = PyObject_Length(__pyx_v_word); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (unlikely(!(__pyx_t_1 <= 32))) {
|
||||
PyErr_SetObject(PyExc_AssertionError, __pyx_kp_6);
|
||||
PyErr_SetObject(PyExc_AssertionError, __pyx_kp_33);
|
||||
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
}
|
||||
#endif
|
||||
@@ -2318,7 +2318,7 @@ static int __pyx_f_8obitools_4word_7_binary_encodeWord(PyObject *__pyx_v_word,
|
||||
* w|=1
|
||||
* elif l=='g':
|
||||
*/
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_7, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_34, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
@@ -2346,7 +2346,7 @@ static int __pyx_f_8obitools_4word_7_binary_encodeWord(PyObject *__pyx_v_word,
|
||||
* w|=2
|
||||
* elif l=='t':
|
||||
*/
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_8, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_35, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
@@ -2374,7 +2374,7 @@ static int __pyx_f_8obitools_4word_7_binary_encodeWord(PyObject *__pyx_v_word,
|
||||
* w|=3
|
||||
* elif l!='a':
|
||||
*/
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_9, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_36, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
@@ -2402,7 +2402,7 @@ static int __pyx_f_8obitools_4word_7_binary_encodeWord(PyObject *__pyx_v_word,
|
||||
* raise RuntimeError,"word should only contain a, c, g or t (%s)" % word
|
||||
* return w
|
||||
*/
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_10, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = PyObject_RichCompare(__pyx_v_l, __pyx_kp_37, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
@@ -2415,7 +2415,7 @@ static int __pyx_f_8obitools_4word_7_binary_encodeWord(PyObject *__pyx_v_word,
|
||||
* return w
|
||||
*
|
||||
*/
|
||||
__pyx_t_2 = PyNumber_Remainder(__pyx_kp_11, __pyx_v_word); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_2 = PyNumber_Remainder(__pyx_kp_38, __pyx_v_word); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__Pyx_GOTREF(__pyx_t_2);
|
||||
__Pyx_Raise(__pyx_builtin_RuntimeError, __pyx_t_2, 0);
|
||||
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
|
||||
@@ -2669,7 +2669,7 @@ static PyObject *__pyx_pf_8obitools_4word_7_binary_encodePattern(PyObject *__pyx
|
||||
* a|=1
|
||||
* if l in 'cymsbhvn':
|
||||
*/
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_12, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_39, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/word/_binary.pyx":177
|
||||
@@ -2695,7 +2695,7 @@ static PyObject *__pyx_pf_8obitools_4word_7_binary_encodePattern(PyObject *__pyx
|
||||
* c|=1
|
||||
* if l in 'grksbdvn':
|
||||
*/
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_13, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_40, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/word/_binary.pyx":179
|
||||
@@ -2721,7 +2721,7 @@ static PyObject *__pyx_pf_8obitools_4word_7_binary_encodePattern(PyObject *__pyx
|
||||
* g|=1
|
||||
* if l in 'tykwbdhn':
|
||||
*/
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_14, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_41, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/word/_binary.pyx":181
|
||||
@@ -2747,7 +2747,7 @@ static PyObject *__pyx_pf_8obitools_4word_7_binary_encodePattern(PyObject *__pyx
|
||||
* t|=1
|
||||
*
|
||||
*/
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_15, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
__pyx_t_4 = (PySequence_Contains(__pyx_kp_42, __pyx_v_l)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__pyx_t_4) {
|
||||
|
||||
/* "/Users/coissac/encours/OBITools/src/obitools/word/_binary.pyx":183
|
||||
@@ -3349,28 +3349,28 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
|
||||
{&__pyx_kp_g, __pyx_k_g, sizeof(__pyx_k_g), 1, 1, 1},
|
||||
{&__pyx_kp_t, __pyx_k_t, sizeof(__pyx_k_t), 1, 1, 1},
|
||||
{&__pyx_kp_size, __pyx_k_size, sizeof(__pyx_k_size), 1, 1, 1},
|
||||
{&__pyx_kp_1, __pyx_k_1, sizeof(__pyx_k_1), 1, 1, 1},
|
||||
{&__pyx_kp_2, __pyx_k_2, sizeof(__pyx_k_2), 1, 1, 1},
|
||||
{&__pyx_kp_28, __pyx_k_28, sizeof(__pyx_k_28), 1, 1, 1},
|
||||
{&__pyx_kp_29, __pyx_k_29, sizeof(__pyx_k_29), 1, 1, 1},
|
||||
{&__pyx_kp_word, __pyx_k_word, sizeof(__pyx_k_word), 1, 1, 1},
|
||||
{&__pyx_kp_pattern, __pyx_k_pattern, sizeof(__pyx_k_pattern), 1, 1, 1},
|
||||
{&__pyx_kp_bin, __pyx_k_bin, sizeof(__pyx_k_bin), 1, 1, 1},
|
||||
{&__pyx_kp_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 1, 1, 1},
|
||||
{&__pyx_kp_join, __pyx_k_join, sizeof(__pyx_k_join), 1, 1, 1},
|
||||
{&__pyx_kp_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 1, 0},
|
||||
{&__pyx_kp_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 1, 0},
|
||||
{&__pyx_kp_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 1, 1, 1},
|
||||
{&__pyx_kp_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 1, 0},
|
||||
{&__pyx_kp_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 1, 0},
|
||||
{&__pyx_kp_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 1, 0},
|
||||
{&__pyx_kp_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 1, 0},
|
||||
{&__pyx_kp_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 1, 0},
|
||||
{&__pyx_kp_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 1, 0},
|
||||
{&__pyx_kp_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 1, 0},
|
||||
{&__pyx_kp_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 1, 0},
|
||||
{&__pyx_kp_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 1, 1, 1},
|
||||
{&__pyx_kp_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 1, 0},
|
||||
{&__pyx_kp_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 1, 0},
|
||||
{&__pyx_kp_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 1, 0},
|
||||
{&__pyx_kp_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 1, 0},
|
||||
{&__pyx_kp_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 0},
|
||||
{&__pyx_kp_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 0},
|
||||
{&__pyx_kp_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 0},
|
||||
{&__pyx_kp_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 0},
|
||||
{&__pyx_kp_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 1, 0},
|
||||
{&__pyx_kp_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 1, 0},
|
||||
{&__pyx_kp_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 1, 0},
|
||||
{&__pyx_kp_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 1, 0},
|
||||
{&__pyx_kp_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 0},
|
||||
{&__pyx_kp_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 0},
|
||||
{&__pyx_kp_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 0},
|
||||
{&__pyx_kp_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 0},
|
||||
{0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
static int __Pyx_InitCachedBuiltins(void) {
|
||||
|
264
src/solexaPairEnd.py
Normal file
264
src/solexaPairEnd.py
Normal file
@@ -0,0 +1,264 @@
|
||||
#!/usr/local/bin/python
|
||||
'''
|
||||
Created on 30 dec. 2009
|
||||
|
||||
@author: coissac
|
||||
'''
|
||||
|
||||
from obitools.options import getOptionManager
|
||||
from obitools.fastq import fastqSolexaIterator, formatFastq
|
||||
from obitools.alignment import columnIterator
|
||||
from obitools.align import QSolexaReverseAssemble
|
||||
from obitools.align import QSolexaRightReverseAssemble
|
||||
from array import array
|
||||
from obitools import NucSequence
|
||||
import sys
|
||||
|
||||
def addSolexaPairEndOptions(optionManager):
|
||||
optionManager.add_option('-r','--reverse-reads',
|
||||
action="store", dest="reverse",
|
||||
metavar="<FILENAME>",
|
||||
type="string",
|
||||
default=None,
|
||||
help="Filename containing reverse solexa reads "
|
||||
)
|
||||
|
||||
|
||||
|
||||
def checkAlignOk(ali):
|
||||
#print not (ali[0][0]=='-' or ali[1][len(ali[1])-1]=='-')
|
||||
return not (ali[0][0]=='-' or ali[1][len(ali[1])-1]=='-')
|
||||
|
||||
|
||||
def iterOnAligment(ali):
|
||||
pos0=0
|
||||
pos1=len(ali[1].wrapped)-1
|
||||
begin0=False
|
||||
end0=False
|
||||
begin1=False
|
||||
end1=False
|
||||
for nuc0,nuc1 in columnIterator(ali):
|
||||
if nuc0=='-':
|
||||
if begin0:
|
||||
if not end0:
|
||||
score0 = ( ali[0].wrapped.quality[pos0-1]
|
||||
+ali[0].wrapped.quality[pos0]
|
||||
)/2
|
||||
else:
|
||||
score0 = 1.
|
||||
else:
|
||||
score0 = 0.
|
||||
else:
|
||||
begin0=True
|
||||
score0 = ali[0].wrapped.quality[pos0]
|
||||
pos0+=1
|
||||
end0= pos0==len(ali[0].wrapped)
|
||||
|
||||
if nuc1=='-':
|
||||
if begin1:
|
||||
if not end1:
|
||||
score1 = ( ali[1].wrapped.wrapped.quality[pos1]
|
||||
+ali[1].wrapped.wrapped.quality[pos1+1]
|
||||
)/2
|
||||
else:
|
||||
score1 = 0.
|
||||
else:
|
||||
score1 = 1.
|
||||
else:
|
||||
begin1=True
|
||||
score1 = ali[1].wrapped.wrapped.quality[pos1]
|
||||
pos1-=1
|
||||
end1=pos1<0
|
||||
|
||||
result = (nuc0,score0,nuc1,score1)
|
||||
yield result
|
||||
|
||||
|
||||
class IterOnConsensus:
|
||||
def __init__(self,ali):
|
||||
self._ali=ali
|
||||
self.__seqASingle=0
|
||||
self.__seqBSingle=0
|
||||
self.__seqABMatch=0
|
||||
self.__seqAMismatch=0
|
||||
self.__seqBMismatch=0
|
||||
self.__seqAInsertion=0
|
||||
self.__seqBInsertion=0
|
||||
self.__seqADeletion=0
|
||||
self.__seqBDeletion=0
|
||||
|
||||
def get_seqASingle(self):
|
||||
return self.__seqASingle
|
||||
|
||||
|
||||
def get_seqBSingle(self):
|
||||
return self.__seqBSingle
|
||||
|
||||
|
||||
def get_seqABMatch(self):
|
||||
return self.__seqABMatch
|
||||
|
||||
|
||||
def get_seqAMismatch(self):
|
||||
return self.__seqAMismatch
|
||||
|
||||
|
||||
def get_seqBMismatch(self):
|
||||
return self.__seqBMismatch
|
||||
|
||||
|
||||
def get_seqAInsertion(self):
|
||||
return self.__seqAInsertion
|
||||
|
||||
|
||||
def get_seqBInsertion(self):
|
||||
return self.__seqBInsertion
|
||||
|
||||
|
||||
def get_seqADeletion(self):
|
||||
return self.__seqADeletion
|
||||
|
||||
|
||||
def get_seqBDeletion(self):
|
||||
return self.__seqBDeletion
|
||||
|
||||
|
||||
def __iter__(self):
|
||||
firstSeqB=False
|
||||
|
||||
for nuc0,score0,nuc1,score1 in iterOnAligment(ali):
|
||||
if nuc0==nuc1:
|
||||
if nuc1!='-':
|
||||
firstSeqB=True
|
||||
self.__seqABMatch+=1
|
||||
self.__seqBSingle=0
|
||||
yield (nuc0,score0*score1)
|
||||
else:
|
||||
h0 = score0 * (1-score1/3)
|
||||
h1 = score1 * (1-score0/3)
|
||||
if h0 < h1:
|
||||
|
||||
if nuc0!='-':
|
||||
self.__seqBSingle=0
|
||||
if nuc1=='-':
|
||||
if firstSeqB:
|
||||
self.__seqAInsertion+=1
|
||||
else:
|
||||
self.__seqASingle+=1
|
||||
else:
|
||||
firstSeqB=True
|
||||
self.__seqAMismatch+=1
|
||||
yield (nuc0,h0)
|
||||
else:
|
||||
self.__seqADeletion+=1
|
||||
else:
|
||||
if nuc1!='-':
|
||||
firstSeqB=True
|
||||
if nuc0=='-':
|
||||
self.__seqBInsertion+=1
|
||||
self.__seqBSingle+=1
|
||||
else:
|
||||
self.__seqBMismatch+=1
|
||||
self.__seqBSingle=0
|
||||
yield (nuc1,h1)
|
||||
else:
|
||||
self.__seqBSingle=0
|
||||
self.__seqBDeletion+=1
|
||||
|
||||
seqASingle = property(get_seqASingle, None, None, "direct's docstring")
|
||||
seqBSingle = property(get_seqBSingle, None, None, "reverse's docstring")
|
||||
seqABMatch = property(get_seqABMatch, None, None, "idem's docstring")
|
||||
seqAMismatch = property(get_seqAMismatch, None, None, "mismatchdirect's docstring")
|
||||
seqBMismatch = property(get_seqBMismatch, None, None, "mismatchreverse's docstring")
|
||||
seqAInsertion = property(get_seqAInsertion, None, None, "insertdirect's docstring")
|
||||
seqBInsertion = property(get_seqBInsertion, None, None, "insertreverse's docstring")
|
||||
seqADeletion = property(get_seqADeletion, None, None, "deletedirect's docstring")
|
||||
seqBDeletion = property(get_seqBDeletion, None, None, "deletereverse's docstring")
|
||||
|
||||
def iterOnConsensus(ali):
|
||||
for nuc0,score0,nuc1,score1 in iterOnAligment(ali):
|
||||
if nuc0==nuc1:
|
||||
if nuc1!='-':
|
||||
op='m'
|
||||
yield (nuc0,score0*score1)
|
||||
else:
|
||||
h0 = score0 * (1-score1/3)
|
||||
h1 = score1 * (1-score0/3)
|
||||
if h0 < h1:
|
||||
|
||||
if nuc0!='-':
|
||||
if nuc1=='-':
|
||||
op="d"
|
||||
else:
|
||||
op='s'
|
||||
yield (nuc0,h0)
|
||||
else:
|
||||
if nuc1!='-':
|
||||
if nuc0=='-':
|
||||
op="i"
|
||||
else:
|
||||
op='s'
|
||||
yield (nuc1,h1)
|
||||
|
||||
def buildConsensus(ali):
|
||||
seq=[]
|
||||
quality=array('d')
|
||||
ic=IterOnConsensus(ali)
|
||||
for nuc,score in ic:
|
||||
seq.append(nuc)
|
||||
quality.append(score)
|
||||
seq=''.join(seq)
|
||||
seq=NucSequence(ali[0].wrapped.id+'_CONS',seq,**ali[0].wrapped.getTags())
|
||||
seq.quality=quality
|
||||
if hasattr(ali, "direction"):
|
||||
seq['alignment']=ali.direction
|
||||
seq['seqASingle']=ic.seqASingle
|
||||
seq['seqBSingle']=ic.seqBSingle
|
||||
seq['seqABMatch']=ic.seqABMatch
|
||||
seq['seqAMismatch']=ic.seqAMismatch
|
||||
seq['seqBMismatch']=ic.seqBMismatch
|
||||
seq['seqAInsertion']=ic.seqAInsertion
|
||||
seq['seqBInsertion']=ic.seqBInsertion-ic.seqBSingle
|
||||
seq['seqADeletion']=ic.seqADeletion
|
||||
seq['seqBDeletion']=ic.seqBDeletion
|
||||
return seq
|
||||
|
||||
def buildAlignment(direct,reverse):
|
||||
la = QSolexaReverseAssemble()
|
||||
ra = QSolexaRightReverseAssemble()
|
||||
for d in direct:
|
||||
r = reverse.next()
|
||||
la.seqA=d
|
||||
la.seqB=r
|
||||
ali=la()
|
||||
ali.direction='left'
|
||||
if not checkAlignOk(ali):
|
||||
# print >>sys.stderr,"-> bad : -------------------------"
|
||||
# print >>sys.stderr,ali
|
||||
# print >>sys.stderr,"----------------------------------"
|
||||
ra.seqA=d
|
||||
ra.seqB=r
|
||||
ali=ra()
|
||||
ali.direction='right'
|
||||
# print >>sys.stderr,ali
|
||||
# print >>sys.stderr,"----------------------------------"
|
||||
yield ali
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
optionParser = getOptionManager([addSolexaPairEndOptions],
|
||||
entryIterator=fastqSolexaIterator
|
||||
)
|
||||
|
||||
(options, direct) = optionParser()
|
||||
|
||||
reverse = fastqSolexaIterator(options.reverse)
|
||||
|
||||
for ali in buildAlignment(direct, reverse):
|
||||
consensus = buildConsensus(ali)
|
||||
print formatFastq(consensus)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user