{
fprintf( stderr, " Testing mem_get_zero ... " );
- size_t i = 0;
- size_t len = 5555;
- char *pt = mem_get_zero( len );
+ size_t i = 0;
+ size_t len = 5555;
+ char *pt1 = mem_get_zero( sizeof( char ) * len );
+ uint *pt2 = mem_get_zero( sizeof( uint ) * len );
- for ( i = 0; i <= len; i++ ) {
- assert( pt[ i ] == '\0' );
+ for ( i = 0; i <= ( sizeof( char ) * len ); i++ ) {
+ assert( pt1[ i ] == '\0' );
}
- mem_free( ( void * ) &pt );
+ for ( i = 0; i <= ( sizeof( char ) * len ); i++ ) {
+ assert( pt2[ i ] == '\0' );
+ }
+
+ mem_free( ( void * ) &pt1 );
+ mem_free( ( void * ) &pt2 );
fprintf( stderr, "OK\n" );
}
+++ /dev/null
-#include "common.h"
-#include "filesys.h"
-#include "mem.h"
-#include "seq.h"
-#include "fasta.h"
-
-/*
- * bipartite_scan locates motivs consisting of two blocks of tetra nucleotides seperated by
- * a distance between 0 and 256 bases. This is done by converting the tetra nucleotide blocks
- * into 2-bits per base thus using the first 16 bits of a unsigned int (which is 32 bits). The
- * remaning 16 bits exactly holds the distance (binary) between the blocks (using 9 bits for 256).
- * For example in the following sequence the two tetra nucletotide blocks (in capital letters)
- * are sepetarated by 13 bases:
- *
- * tatagtacgttATCGatgagctagctgtTGCAgtgtgatac
- *
- * Thus the resulting parts of the count block will look like this:
- *
- * ATCG=00110110 TGCA=11100100 and 13=000001101 (using A=00 T=11 C=01 and G=10).
- *
- * And the resulting bipartite block is then: 00110110111001000000011010000000
- * The remainin 7 bits are unused.
- *
- * The biparite block can then be used as an index in an unsigned int array that holds the count
- * of all different bipartite blocks found in a sequence or list of sequnces (all genomes!).
- *
- * Rescanning the sequences locating the bipartite blocks of interest allows location of the
- * exact motif positions.
- *
- * */
-
-#define BLOCK_SIZE 4
-#define MAX_SPACE 256
-//#define ARRAY_SIZE ( 1 << 30 )
-#define ARRAY_SIZE 30
-#define WINDOW_SIZE ( ( 2 * BLOCK_SIZE ) + MAX_SPACE )
-
-#define add_A( c ) /* add 00 on the rightmost two bits of c (i. e. do nothing). */
-#define add_T( c ) ( c |= 3 ) /* add 11 on the rightmost two bits of c. */
-#define add_C( c ) ( c |= 1 ) /* add 01 on the rightmost two bits of c. */
-#define add_G( c ) ( c |= 2 ) /* add 10 on the rightmost two bits of c. */
-
-void bipartite_scan_file( char *file, uint **bipartite_array_ppt, seq_entry **entry_ppt );
-void bipartite_scan_entry( uint *bipartite_array, seq_entry *entry );
-
-int main( int argc, char *argv[] )
-{
- int i = 0;
- uint *bipartite_array = NULL;
- seq_entry *entry = NULL;
-
- bipartite_array = mem_get_zero( sizeof( uint ) * ARRAY_SIZE );
-
- seq_new( &entry, MAX_SEQ_NAME, MAX_SEQ );
-
- for ( i = 1; i < argc; i++ )
- {
- bipartite_scan_file( argv[ i ], &bipartite_array, &entry );
- }
-
- seq_destroy( entry );
-
- mem_free( &bipartite_array );
-
- return EXIT_SUCCESS;
-}
-
-
-void bipartite_scan_file( char *file, uint **bipartite_array_ppt, seq_entry **entry_ppt )
-{
- /* Martin A. Hansen, September 2008. */
-
- uint *bipartite_array = *bipartite_array_ppt;
- seq_entry *entry = *entry_ppt;
- FILE *fp = NULL;
-
- fp = read_open( file );
-
- while ( ( fasta_get_entry( fp, &entry ) != FALSE ) ) {
- bipartite_scan_entry( bipartite_array, entry );
- }
-
- close_stream( fp );
-}
-
-
-void bipartite_scan_entry( uint *bipartite_array, seq_entry *entry )
-{
- /* Martin A. Hansen, September 2008. */
-
- fasta_put_entry( entry );
-}