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 ];
{
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" );
scan_list( list, count_array );
+ mem_free( &list->first->val );
+
list_sl_remove_beg( &list );
}
}
rescan_list( list, count_array, i, cutoff );
+ mem_free( &list->first->val );
+
list_sl_remove_beg( &list );
}
}
/* 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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* 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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
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 );
}
+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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
}
+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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
{
/* Martin A. Hansen, May 2008 */
- /* Unit test done.*/
-
/* Free memory from a given pointer. */
void **ppt = ( void ** ) pt;
}
*ppt = NULL;
+ pt = NULL;
}
-
/* 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 );
}
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();
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();
test_list_sl_print();
test_list_sl_sort();
test_list_sl_destroy();
+ test_node_sl_destroy();
test_list_dl_new();
test_node_dl_new();
test_list_dl_remove();
test_list_dl_print();
test_list_dl_destroy();
+ test_node_dl_destroy();
test_list_count();
{
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 );
}
+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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
}
+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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
{
# 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
$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" } ) )
$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" };
}
-sub fixedStep_index_lookup
+sub fixedstep_index_lookup
{
# Martin A. Hansen, January 2008.