@@ -564,25 +564,20 @@ PyObject *pyfastx_sequence_gc_content(pyfastx_Sequence *self, void* closure) {
564564 int ret ;
565565 char * seq ;
566566
567- sqlite3_stmt * stmt ;
568-
569567 Py_ssize_t i , n ;
570568 Py_ssize_t a = 0 , c = 0 , g = 0 , t = 0 ;
571-
572- const char * sql = "SELECT * FROM comp WHERE seqid=?" ;
573569
574570 PYFASTX_SQLITE_CALL (
575- sqlite3_prepare_v2 (self -> index -> index_db , sql , -1 , & stmt , NULL );
576- sqlite3_bind_int64 (stmt , 1 , self -> id );
577- ret = sqlite3_step (stmt );
571+ sqlite3_bind_int64 (self -> index -> comp_stmt , 1 , self -> id );
572+ ret = sqlite3_step (self -> index -> comp_stmt );
578573 );
579574
580575 if (ret == SQLITE_ROW && self -> start == 1 && self -> end == self -> seq_len ) {
581576 while (ret == SQLITE_ROW ) {
582577 PYFASTX_SQLITE_CALL (
583- l = sqlite3_column_int (stmt , 2 );
584- n = sqlite3_column_int64 (stmt , 3 );
585- ret = sqlite3_step (stmt );
578+ l = sqlite3_column_int (self -> index -> comp_stmt , 2 );
579+ n = sqlite3_column_int64 (self -> index -> comp_stmt , 3 );
580+ ret = sqlite3_step (self -> index -> comp_stmt );
586581 );
587582
588583 switch (l ) {
@@ -635,7 +630,7 @@ PyObject *pyfastx_sequence_gc_content(pyfastx_Sequence *self, void* closure) {
635630 }
636631 }
637632
638- PYFASTX_SQLITE_CALL (sqlite3_finalize ( stmt ));
633+ PYFASTX_SQLITE_CALL (sqlite3_reset ( self -> index -> comp_stmt ));
639634
640635 return Py_BuildValue ("f" , (float )(g + c )/(a + c + g + t )* 100 );
641636}
@@ -644,25 +639,21 @@ PyObject *pyfastx_sequence_gc_skew(pyfastx_Sequence *self, void* closure) {
644639 int l ;
645640 int ret ;
646641 char * seq ;
647- sqlite3_stmt * stmt ;
648642
649643 Py_ssize_t i , n ;
650644 Py_ssize_t c = 0 , g = 0 ;
651-
652- const char * sql = "SELECT * FROM comp WHERE seqid=?" ;
653645
654646 PYFASTX_SQLITE_CALL (
655- sqlite3_prepare_v2 (self -> index -> index_db , sql , -1 , & stmt , NULL );
656- sqlite3_bind_int64 (stmt , 1 , self -> id );
657- ret = sqlite3_step (stmt );
647+ sqlite3_bind_int64 (self -> index -> comp_stmt , 1 , self -> id );
648+ ret = sqlite3_step (self -> index -> comp_stmt );
658649 );
659650
660651 if (ret == SQLITE_ROW && self -> start == 1 && self -> end == self -> seq_len ) {
661652 while (ret == SQLITE_ROW ) {
662653 PYFASTX_SQLITE_CALL (
663- l = sqlite3_column_int (stmt , 2 );
664- n = sqlite3_column_int64 (stmt , 3 );
665- ret = sqlite3_step (stmt );
654+ l = sqlite3_column_int (self -> index -> comp_stmt , 2 );
655+ n = sqlite3_column_int64 (self -> index -> comp_stmt , 3 );
656+ ret = sqlite3_step (self -> index -> comp_stmt );
666657 );
667658
668659 switch (l ) {
@@ -695,7 +686,7 @@ PyObject *pyfastx_sequence_gc_skew(pyfastx_Sequence *self, void* closure) {
695686 }
696687 }
697688
698- PYFASTX_SQLITE_CALL (sqlite3_finalize ( stmt ));
689+ PYFASTX_SQLITE_CALL (sqlite3_reset ( self -> index -> comp_stmt ));
699690
700691 return Py_BuildValue ("f" , (float )(g - c )/(g + c ));
701692}
@@ -705,8 +696,6 @@ PyObject *pyfastx_sequence_composition(pyfastx_Sequence *self, void* closure) {
705696 int l ;
706697 int ret ;
707698 char * seq ;
708-
709- sqlite3_stmt * stmt ;
710699
711700 Py_ssize_t n ;
712701 Py_ssize_t seq_comp [128 ] = {0 };
@@ -715,22 +704,19 @@ PyObject *pyfastx_sequence_composition(pyfastx_Sequence *self, void* closure) {
715704 PyObject * b ;
716705 PyObject * c ;
717706
718- const char * sql = "SELECT * FROM comp WHERE ID=?" ;
719-
720707 PYFASTX_SQLITE_CALL (
721- sqlite3_prepare_v2 (self -> index -> index_db , sql , -1 , & stmt , NULL );
722- sqlite3_bind_int64 (stmt , 1 , self -> id );
723- ret = sqlite3_step (stmt );
708+ sqlite3_bind_int64 (self -> index -> stmt , 1 , self -> id );
709+ ret = sqlite3_step (self -> index -> stmt );
724710 );
725711
726712 d = PyDict_New ();
727713
728714 if (ret == SQLITE_ROW && self -> start == 1 && self -> end == self -> seq_len ) {
729715 while (ret == SQLITE_ROW ) {
730716 PYFASTX_SQLITE_CALL (
731- l = sqlite3_column_int (stmt , 2 );
732- n = sqlite3_column_int64 (stmt , 3 );
733- ret = sqlite3_step (stmt );
717+ l = sqlite3_column_int (self -> index -> stmt , 2 );
718+ n = sqlite3_column_int64 (self -> index -> stmt , 3 );
719+ ret = sqlite3_step (self -> index -> stmt );
734720 );
735721
736722 if (n > 0 && l >= 32 && l < 127 ) {
@@ -761,8 +747,7 @@ PyObject *pyfastx_sequence_composition(pyfastx_Sequence *self, void* closure) {
761747 }
762748 }
763749
764- PYFASTX_SQLITE_CALL (sqlite3_finalize (stmt ));
765-
750+ PYFASTX_SQLITE_CALL (sqlite3_reset (self -> index -> stmt ));
766751 return d ;
767752}
768753
0 commit comments