1414#include <string.h>
1515#include <stdio.h>
1616
17- #if PY_MAJOR_VERSION >= 3
18- #define PyInt_FromLong PyLong_FromLong
19- #define PyString_Check PyUnicode_Check
20- #define PyString_Size PyUnicode_GET_LENGTH
21- #endif
22-
2317
2418void fill_matrix (double matrix [][4 ], PyObject * matrix_o ) {
2519 // Parse a PyObject matrix into a C array
@@ -312,9 +306,7 @@ static PyObject * c_metrics_score(PyObject *self, PyObject * args)
312306
313307}
314308
315- int get_truncate_len (len1 , len2 , pos ) {
316- //
317-
309+ int get_truncate_len (int len1 , int len2 , int pos ) {
318310 if (pos < 0 ) {
319311 len2 += pos ;
320312 }
@@ -328,7 +320,6 @@ int get_truncate_len(len1, len2, pos) {
328320 else {
329321 return len1 ;
330322 }
331-
332323}
333324
334325void fill_tmp_matrices (double matrix1 [][4 ], double matrix2 [][4 ], int pos , int l , double tmp_matrix1 [][4 ], double tmp_matrix2 [][4 ]) {
@@ -560,8 +551,6 @@ static PyObject * c_metrics_pwmscan(PyObject *self, PyObject * args)
560551
561552 if (j_max < 0 ) { j_max = 0 ;}
562553 int m ;
563- int c ;
564- double pwm_min = -50 ;
565554 for (j = 0 ; j < j_max ; j ++ ) {
566555 score = 0 ;
567556 rc_score = 0 ;
@@ -622,9 +611,9 @@ static PyObject * c_metrics_pwmscan(PyObject *self, PyObject * args)
622611 PyObject * row = PyList_New (0 );
623612 x = PyFloat_FromDouble (score );
624613 PyList_Append (row , x ); Py_DECREF (x );
625- x = PyInt_FromLong ((long ) j );
614+ x = PyLong_FromLong ((long ) j );
626615 PyList_Append (row , x ); Py_DECREF (x );
627- x = PyInt_FromLong ((long ) 1 );
616+ x = PyLong_FromLong ((long ) 1 );
628617 PyList_Append (row , x ); Py_DECREF (x );
629618 PyList_Append (return_list , row );
630619 Py_DECREF (row );
@@ -658,9 +647,9 @@ static PyObject * c_metrics_pwmscan(PyObject *self, PyObject * args)
658647 PyObject * row = PyList_New (0 );
659648 x = PyFloat_FromDouble (score );
660649 PyList_Append (row , x ); Py_DECREF (x );
661- x = PyInt_FromLong ((long ) j );
650+ x = PyLong_FromLong ((long ) j );
662651 PyList_Append (row , x ); Py_DECREF (x );
663- x = PyInt_FromLong ((long ) 1 );
652+ x = PyLong_FromLong ((long ) 1 );
664653 PyList_Append (row , x ); Py_DECREF (x );
665654 PyList_Append (return_list , row );
666655 Py_DECREF (row );
@@ -674,9 +663,9 @@ static PyObject * c_metrics_pwmscan(PyObject *self, PyObject * args)
674663 PyObject * row = PyList_New (0 );
675664 x = PyFloat_FromDouble (maxScores [i ]);
676665 PyList_Append (row , x ); Py_DECREF (x );
677- x = PyInt_FromLong ((long )maxPos [i ]);
666+ x = PyLong_FromLong ((long )maxPos [i ]);
678667 PyList_Append (row , x ); Py_DECREF (x );
679- x = PyInt_FromLong ((long )maxStrand [i ]);
668+ x = PyLong_FromLong ((long )maxStrand [i ]);
680669 PyList_Append (row , x ); Py_DECREF (x );
681670 PyList_Append (return_list , row );
682671 Py_DECREF (row );
@@ -827,9 +816,9 @@ static PyObject * c_metrics_pfmscan(PyObject *self, PyObject * args)
827816 PyObject * row = PyList_New (0 );
828817 x = PyFloat_FromDouble (score );
829818 PyList_Append (row , x ); Py_DECREF (x );
830- x = PyInt_FromLong ((long ) j );
819+ x = PyLong_FromLong ((long ) j );
831820 PyList_Append (row , x ); Py_DECREF (x );
832- x = PyInt_FromLong ((long ) 1 );
821+ x = PyLong_FromLong ((long ) 1 );
833822 PyList_Append (row , x ); Py_DECREF (x );
834823 PyList_Append (return_list , row );
835824 Py_DECREF (row );
@@ -863,9 +852,9 @@ static PyObject * c_metrics_pfmscan(PyObject *self, PyObject * args)
863852 PyObject * row = PyList_New (0 );
864853 x = PyFloat_FromDouble (score );
865854 PyList_Append (row , x ); Py_DECREF (x );
866- x = PyInt_FromLong ((long ) j );
855+ x = PyLong_FromLong ((long ) j );
867856 PyList_Append (row , x ); Py_DECREF (x );
868- x = PyInt_FromLong ((long ) 1 );
857+ x = PyLong_FromLong ((long ) 1 );
869858 PyList_Append (row , x ); Py_DECREF (x );
870859 PyList_Append (return_list , row );
871860 Py_DECREF (row );
@@ -879,9 +868,9 @@ static PyObject * c_metrics_pfmscan(PyObject *self, PyObject * args)
879868 PyObject * row = PyList_New (0 );
880869 x = PyFloat_FromDouble (maxScores [i ]);
881870 PyList_Append (row , x ); Py_DECREF (x );
882- x = PyInt_FromLong ((long )maxPos [i ]);
871+ x = PyLong_FromLong ((long )maxPos [i ]);
883872 PyList_Append (row , x ); Py_DECREF (x );
884- x = PyInt_FromLong ((long )maxStrand [i ]);
873+ x = PyLong_FromLong ((long )maxStrand [i ]);
885874 PyList_Append (row , x ); Py_DECREF (x );
886875 PyList_Append (return_list , row );
887876 Py_DECREF (row );
@@ -898,43 +887,28 @@ static PyMethodDef CoreMethods[] = {
898887 {"c_max_subtotal" , c_metrics_max_subtotal , METH_VARARGS ,"Test" },
899888 {"pfmscan" , c_metrics_pfmscan , METH_VARARGS ,"Test" },
900889 {"pwmscan" , c_metrics_pwmscan , METH_VARARGS ,"Test" },
901- {NULL , NULL , NULL , 0 , NULL }
890+ {NULL , NULL , 0 , NULL }
902891};
903892
904- #if PY_MAJOR_VERSION >= 3
905- static struct PyModuleDef moduledef = {
906- PyModuleDef_HEAD_INIT ,
907- "c_metrics" , /* m_name */
908- "This is a module" , /* m_doc */
909- -1 , /* m_size */
910- CoreMethods , /* m_methods */
911- NULL , /* m_reload */
912- NULL , /* m_traverse */
913- NULL , /* m_clear */
914- NULL , /* m_free */
915- };
916- #endif
893+ static struct PyModuleDef moduledef = {
894+ PyModuleDef_HEAD_INIT ,
895+ "c_metrics" , /* m_name */
896+ "This is a module" , /* m_doc */
897+ -1 , /* m_size */
898+ CoreMethods , /* m_methods */
899+ NULL , /* m_reload */
900+ NULL , /* m_traverse */
901+ NULL , /* m_clear */
902+ NULL , /* m_free */
903+ };
917904
918905static PyObject * moduleinit (void ) {
919906 PyObject * m ;
920- #if PY_MAJOR_VERSION >= 3
921907 m = PyModule_Create (& moduledef );
922- #else
923- m = Py_InitModule3 ("c_metrics" , CoreMethods , "c_metrics_module" );
924- #endif
925908 return m ;
926909}
927910
928911PyMODINIT_FUNC
929- #if PY_MAJOR_VERSION >= 3
930- PyInit_c_metrics (void )
931- {
932- return moduleinit ();
933- };
934- #else
935- initc_metrics (void )
936- {
937- moduleinit ();
938- };
939- #endif
940-
912+ PyInit_c_metrics (void ) {
913+ return moduleinit ();
914+ };
0 commit comments