]> git.donarmstrong.com Git - biopieces.git/commitdiff
fixed rename bug
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 25 Sep 2008 01:34:06 +0000 (01:34 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 25 Sep 2008 01:34:06 +0000 (01:34 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@269 74ccb610-7750-0410-82ae-013aeee3265d

code_c/Maasha/src/bipartite_scan.c
code_c/Maasha/src/inc/list.h
code_c/Maasha/src/inc/mem.h
code_c/Maasha/src/lib/list.c
code_c/Maasha/src/lib/mem.c
code_c/Maasha/src/lib/seq.c
code_c/Maasha/src/test/test_list.c
code_perl/Maasha/Biopieces.pm
code_perl/Maasha/UCSC.pm

index ee01f07064119af4d3f74c5c5fa608c8f7ab9372..3646676d8abeac181ba5c41742d1f27ccbe08518 100644 (file)
@@ -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 );
             }
         }
index 27886d8e07188f97544b06f51110fbf2bfc6f1cf..1101c5ec15a20ed2b1f93128525747a178ac6884 100644 (file)
@@ -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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
 
index cc0dde6d97bf909aeaa6e4ead5e286a36ee7413a..a85a36b93bdc7dd78a898c12bcf28852bf626d9f 100644 (file)
@@ -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 );
index cbd61c6838814188edf5c33da19e813ed9e7d084..1bf44322886fb9887d0706fc73055cac3c7a426a 100644 (file)
@@ -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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
 
 
index d7bea0a70af266f22d3c2e550e32fd82fda735cb..f7acb098281f91a92f33f7b6ba26fefe02cae2a1 100644 (file)
@@ -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;
 }
 
-
index 09b88d01dfcffc2728b0827ed15c2d425f73f764..37180e7bd1d3fcc55057f7d3d1aa84b17cb3a6b3 100644 (file)
@@ -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 );
 }
 
 
index f7660e1f6f682ffc8e7c29e13da11a2d3f55bd75..66fb3b089d47d30f6e400dab3a132a58fb18fffe 100644 (file)
@@ -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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
 
 
index b910f9af63fe54cb26ce0bcf9181a4a7a0463665..6c38e430698324319052305b5c1c3afcf5fd84dc 100644 (file)
@@ -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" };
index 0e489e1f2785123b43054f58a0e127c8436ae2df..01cb884c7903a3ea62ee8222a5349d97be1101c4 100644 (file)
@@ -1112,7 +1112,7 @@ sub fixedstep_index_retrieve
 }
 
 
-sub fixedStep_index_lookup
+sub fixedstep_index_lookup
 {
     # Martin A. Hansen, January 2008.