@@ -217,8 +217,58 @@ static PyObject* stria_ssrminer_as_list(stria_SSRMiner *self) {
217217 return ssrs ;
218218}
219219
220+ static PyObject * stria_ssrminer_as_test (stria_SSRMiner * self ) {
221+ PyObject * ssrs = PyList_New (0 );
222+ PyObject * tmp ;
223+ Py_ssize_t current_start ;
224+ Py_ssize_t ssr_end ;
225+ Py_ssize_t boundary ;
226+ int replen ;
227+ int repeats ;
228+ int length ;
229+ //char *motif = (char *)malloc(7);
230+ char motif [7 ];
231+
232+ for (Py_ssize_t i = 0 ; i < self -> size ; ++ i ) {
233+ if (self -> seq [i ] == 78 ) {
234+ continue ;
235+ }
236+
237+ current_start = i ;
238+ for (int j = 1 ; j < 7 ; ++ j ) {
239+ boundary = self -> size - j ;
240+
241+ while ((i < boundary ) && (self -> seq [i ] == self -> seq [i + j ])) {
242+ ++ i ;
243+ }
244+
245+ replen = i + j - current_start ;
246+
247+ if (replen >= self -> min_lens [j ]) {
248+ memcpy (motif , self -> seq + current_start , j );
249+ motif [j ] = '\0' ;
250+ repeats = replen / j ;
251+ length = repeats * j ;
252+ ssr_end = current_start + length ;
253+ tmp = Py_BuildValue ("Onnsiii" , self -> seqname , current_start + 1 , ssr_end , motif , j , repeats , length );
254+ PyList_Append (ssrs , tmp );
255+ Py_DECREF (tmp );
256+
257+ i = ssr_end ;
258+ break ;
259+ } else {
260+ i = current_start ;
261+ }
262+ }
263+ }
264+
265+ //free(motif);
266+ return ssrs ;
267+ }
268+
220269static PyMethodDef stria_ssrminer_methods [] = {
221270 {"as_list" , (PyCFunction )stria_ssrminer_as_list , METH_NOARGS , NULL },
271+ {"as_test" , (PyCFunction )stria_ssrminer_as_test , METH_NOARGS , NULL },
222272 {"reset_min_repeats" , (PyCFunction )stria_ssrminer_reset_min_repeats , METH_VARARGS |METH_KEYWORDS , NULL },
223273 {NULL , NULL , 0 , NULL }
224274};
0 commit comments