From: martinahansen Date: Thu, 25 Sep 2008 01:34:06 +0000 (+0000) Subject: fixed rename bug X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b53a2cbe04bf29a5f3face92a9f980511200a5fb;p=biopieces.git fixed rename bug git-svn-id: http://biopieces.googlecode.com/svn/trunk@269 74ccb610-7750-0410-82ae-013aeee3265d --- diff --git a/code_c/Maasha/src/bipartite_scan.c b/code_c/Maasha/src/bipartite_scan.c index ee01f07..3646676 100644 --- a/code_c/Maasha/src/bipartite_scan.c +++ b/code_c/Maasha/src/bipartite_scan.c @@ -109,9 +109,9 @@ void run_scan( int argc, char *argv[] ) fprintf( stderr, "done.\n" ); } - fprintf( stderr, "Printing motifs: ... " ); - count_array_print( count_array, COUNT_ARRAY_NMEMB, CUTOFF ); - fprintf( stderr, "done.\n" ); +// fprintf( stderr, "Printing motifs: ... " ); +// count_array_print( count_array, COUNT_ARRAY_NMEMB, CUTOFF ); +// fprintf( stderr, "done.\n" ); file = argv[ 1 ]; @@ -174,6 +174,8 @@ void rescan_file( char *file, seq_entry *entry, uint *count_array, size_t cutoff { fprintf( stderr, " Rescanning: %s (%zu nt) ... ", entry->seq_name, entry->seq_len ); + printf( "SEQ_NAME: %s\n", entry->seq_name ); + rescan_seq( entry->seq, entry->seq_len, count_array, cutoff ); fprintf( stderr, "done.\n" ); @@ -250,6 +252,8 @@ void scan_seq( char *seq, size_t seq_len, uint *count_array ) scan_list( list, count_array ); + mem_free( &list->first->val ); + list_sl_remove_beg( &list ); } } @@ -334,6 +338,8 @@ void rescan_seq( char *seq, size_t seq_len, uint *count_array, size_t cutoff ) rescan_list( list, count_array, i, cutoff ); + mem_free( &list->first->val ); + list_sl_remove_beg( &list ); } } diff --git a/code_c/Maasha/src/inc/list.h b/code_c/Maasha/src/inc/list.h index 27886d8..1101c5e 100644 --- a/code_c/Maasha/src/inc/list.h +++ b/code_c/Maasha/src/inc/list.h @@ -76,6 +76,9 @@ void list_sl_sort( list_sl **list_ppt, int ( *compare )( const void *a, cons /* Free memory for all nodes in and including the singly linked list. */ void list_sl_destroy( list_sl **list_ppt ); +/* Free memory for singly linked list node and value. */ +void node_sl_destroy( node_sl **node_ppt ); + /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DOUBLY LINKED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ @@ -110,6 +113,8 @@ void node_dl_print( node_dl *node_pt ); /* Free memory for all nodes in and including the doubly linked list. */ void list_dl_destroy( list_dl **list_ppt ); +/* Free memory for doubly linked list node and value. */ +void node_dl_destroy( node_dl **node_ppt ); /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> GENERIC LINKED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ diff --git a/code_c/Maasha/src/inc/mem.h b/code_c/Maasha/src/inc/mem.h index cc0dde6..a85a36b 100644 --- a/code_c/Maasha/src/inc/mem.h +++ b/code_c/Maasha/src/inc/mem.h @@ -16,5 +16,5 @@ void *mem_resize_zero( void *pt, size_t old_size, size_t new_size ); void *mem_clone( void *old_pt, size_t size ); /* Free memory from a given pointer. */ -/* Usage: mem_free2( &pt ) */ +/* Usage: mem_free( &pt ) */ void mem_free( void *pt ); diff --git a/code_c/Maasha/src/lib/list.c b/code_c/Maasha/src/lib/list.c index cbd61c6..1bf4432 100644 --- a/code_c/Maasha/src/lib/list.c +++ b/code_c/Maasha/src/lib/list.c @@ -198,6 +198,21 @@ void list_sl_destroy( list_sl **list_ppt ) } +void node_sl_destroy( node_sl **node_ppt ) +{ + /* Martin A. Hansen, September 2008 */ + + /* Free memory for singly linked list node and value. */ + + node_sl *node = *node_ppt; + + mem_free( &node->val ); + mem_free( &node ); + + *node_ppt = NULL; +} + + /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DOUBLY LINKED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ @@ -397,6 +412,21 @@ void list_dl_destroy( list_dl **list_ppt ) } +void node_dl_destroy( node_dl **node_ppt ) +{ + /* Martin A. Hansen, September 2008 */ + + /* Free memory for doubly linked list node and value. */ + + node_dl *node = *node_ppt; + + mem_free( &node->val ); + mem_free( &node ); + + *node_ppt = NULL; +} + + /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> GENERIC LINKED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ diff --git a/code_c/Maasha/src/lib/mem.c b/code_c/Maasha/src/lib/mem.c index d7bea0a..f7acb09 100644 --- a/code_c/Maasha/src/lib/mem.c +++ b/code_c/Maasha/src/lib/mem.c @@ -112,8 +112,6 @@ void mem_free( void *pt ) { /* Martin A. Hansen, May 2008 */ - /* Unit test done.*/ - /* Free memory from a given pointer. */ void **ppt = ( void ** ) pt; @@ -127,6 +125,6 @@ void mem_free( void *pt ) } *ppt = NULL; + pt = NULL; } - diff --git a/code_c/Maasha/src/lib/seq.c b/code_c/Maasha/src/lib/seq.c index 09b88d0..37180e7 100644 --- a/code_c/Maasha/src/lib/seq.c +++ b/code_c/Maasha/src/lib/seq.c @@ -65,11 +65,9 @@ void seq_destroy( seq_entry *entry ) /* Destroy a sequence entry. */ - free( entry->seq_name ); - free( entry->seq ); - free( entry ); - - entry = NULL; + mem_free( &entry->seq_name ); + mem_free( &entry->seq ); + mem_free( &entry ); } diff --git a/code_c/Maasha/src/test/test_list.c b/code_c/Maasha/src/test/test_list.c index f7660e1..66fb3b0 100644 --- a/code_c/Maasha/src/test/test_list.c +++ b/code_c/Maasha/src/test/test_list.c @@ -14,6 +14,7 @@ static void test_list_sl_remove_after(); static void test_list_sl_print(); static void test_list_sl_sort(); static void test_list_sl_destroy(); +static void test_node_sl_destroy(); static void test_list_dl_new(); static void test_node_dl_new(); @@ -24,6 +25,7 @@ static void test_list_dl_add_after(); static void test_list_dl_remove(); static void test_list_dl_print(); static void test_list_dl_destroy(); +static void test_node_dl_destroy(); static void test_list_count(); @@ -41,6 +43,7 @@ int main() test_list_sl_print(); test_list_sl_sort(); test_list_sl_destroy(); + test_node_sl_destroy(); test_list_dl_new(); test_node_dl_new(); @@ -51,6 +54,7 @@ int main() test_list_dl_remove(); test_list_dl_print(); test_list_dl_destroy(); + test_node_dl_destroy(); test_list_count(); @@ -338,21 +342,18 @@ void test_list_sl_destroy() { fprintf( stderr, " Testing list_sl_destroy ... " ); - char *array[3] = { "test1", "test2", "test3" }; - list_sl *list = NULL; - node_sl *node = NULL; - int i = 0; - - list = list_sl_new(); + list_sl *list = list_sl_new(); + node_sl *node1 = node_sl_new(); + node_sl *node2 = node_sl_new(); + node_sl *node3 = node_sl_new(); - for ( i = 0; i < 3; i++ ) - { - node = node_sl_new(); - - node->val = array[ i ]; + node1->val = mem_get( 10 ); + node2->val = mem_get( 10 ); + node3->val = mem_get( 10 ); - list_sl_add_beg( &list, &node ); - } + list_sl_add_beg( &list, &node1 ); + list_sl_add_beg( &list, &node2 ); + list_sl_add_beg( &list, &node3 ); list_sl_destroy( &list ); @@ -362,6 +363,27 @@ void test_list_sl_destroy() } +void test_node_sl_destroy() +{ + fprintf( stderr, " Testing node_sl_destroy ... " ); + + node_sl *node = NULL; + char *str = NULL; + + str = mem_get( 1000000000 ); + + node = node_sl_new(); + + node->val = str; + + node_sl_destroy( &node ); + + assert( node == NULL ); + + fprintf( stderr, "OK\n" ); +} + + /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DOUBLY LINKED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ @@ -603,6 +625,27 @@ void test_list_dl_destroy() } +void test_node_dl_destroy() +{ + fprintf( stderr, " Testing node_dl_destroy ... " ); + + node_dl *node = NULL; + char *str = NULL; + + str = mem_get( 1000000000 ); + + node = node_dl_new(); + + node->val = str; + + node_dl_destroy( &node ); + + assert( node == NULL ); + + fprintf( stderr, "OK\n" ); +} + + /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> GENERIC LINKED LIST <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */ diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index b910f9a..6c38e43 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -1426,7 +1426,7 @@ sub script_read_fixedstep { # Martin A. Hansen, Juli 2008. - # Read fixedStep wiggle format from stream or file. + # Read fixedstep wiggle format from stream or file. my ( $in, # handle to in stream $out, # handle to out stream @@ -3105,7 +3105,7 @@ sub script_get_genome_phastcons $phastcons_file = Maasha::Config::genome_phastcons( $options->{ "genome" } ); $phastcons_index = Maasha::Config::genome_phastcons_index( $options->{ "genome" } ); - $index = Maasha::UCSC::phastcons_index_retrieve( $phastcons_index ); + $index = Maasha::UCSC::fixedstep_index_retrieve( $phastcons_index ); $fh_phastcons = Maasha::Common::read_open( $phastcons_file ); if ( defined $options->{ "chr" } and defined $options->{ "beg" } and ( defined $options->{ "end" } or defined $options->{ "len" } ) ) @@ -3117,7 +3117,7 @@ sub script_get_genome_phastcons $options->{ "end" } = $options->{ "beg" } + $options->{ "len" } - 1; } - $scores = Maasha::UCSC::phastcons_index_lookup( $index, $fh_phastcons, $options->{ "chr" }, $options->{ "beg" }, $options->{ "end" }, $options->{ "flank" } ); + $scores = Maasha::UCSC::fixedstep_index_lookup( $index, $fh_phastcons, $options->{ "chr" }, $options->{ "beg" }, $options->{ "end" }, $options->{ "flank" } ); $record->{ "CHR" } = $options->{ "chr" }; $record->{ "CHR_BEG" } = $options->{ "beg" } - $options->{ "flank" }; diff --git a/code_perl/Maasha/UCSC.pm b/code_perl/Maasha/UCSC.pm index 0e489e1..01cb884 100644 --- a/code_perl/Maasha/UCSC.pm +++ b/code_perl/Maasha/UCSC.pm @@ -1112,7 +1112,7 @@ sub fixedstep_index_retrieve } -sub fixedStep_index_lookup +sub fixedstep_index_lookup { # Martin A. Hansen, January 2008.