+# Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved
+
CC = gcc
# Cflags = -Wall -Werror
Cflags = -Wall -Werror -g -pg # for gprof
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "filesys.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#define BITS_IN_BYTE 8
#define BYTE_ON 255
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
/* Including standard libraries */
#include <stdio.h>
#include <stdlib.h>
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#define FASTA_BUFFER 1024
/* Count all entries in a FASTA file given a file pointer. */
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
//#define FILE_BUFFER_SIZE 64 * 1024
#define FILE_BUFFER_SIZE 1
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
/* Structure of a generic hash element. */
struct _hash_elem
{
-
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> STRUCTURE DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
/* Get a pointer with a given size of allocated memory. */
void *mem_get( size_t size );
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
/* Macro to test if a given char is sequence (DNA, RNA, Protein, indels. brackets, etc ). */
#define isseq( x ) ( x > 32 && x < 127 ) ? 1 : 0
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
/* Remove the last char from a string. Returns the length of the chopped string.*/
size_t chop( char *string );
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#define BED_BUFFER 1024
struct bed_entry3
+# Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved
+
CC = gcc
# Cflags = -Wall -Werror
Cflags = -Wall -Werror -g -pg # gprof
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "bits.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "list.h"
#include "mem.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "filesys.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "filesys.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "hash.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "list.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "seq.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "strings.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "ucsc.h"
+
void bed_get_entry( FILE *fp, struct bed_entry3 *bed, int cols )
{
/* Martin A. Hansen, June 2008 */
}
-void bed_split( char *string, struct bed_entry12 *bed, int cols )
-{
- int i;
- int field_num;
- int offset;
- char *new_line;
- int new_line_pos;
- char *pt;
- int pos;
- int field_seps[ cols ];
- int field_len;
- char *field;
-
- if ( ( new_line = memchr( string, '\n', 1024 ) ) != NULL ) {
- new_line_pos = new_line - string;
- } else {
- abort();
- }
-
- field_num = 0;
- offset = 0;
-
- for ( i = 0; i < cols; i++ )
- {
- if ( ( pt = memchr( &string[ offset ], '\t', new_line_pos - offset ) ) != NULL )
- {
- pos = pt - string;
-
- pos = MIN( pos, new_line_pos );
-
- field_seps[ field_num ] = pos;
-
- field_num++;
- }
- else
- {
- abort();
- }
-
- offset += pos + 1;
- }
-
- offset = 0;
-
- for ( i = 0; i < cols; i++ )
- {
- field_len = field_seps[ i ] - offset;
-
- field = mem_get( field_len );
-
- field[ field_len ] = '\0';
-
- memcpy( field, &string[ offset ], field_len );
-
- if ( i == 0 ) {
- bed->chr = mem_clone( ( char * ) field, field_len );
- } else if ( i == 1 ) {
- bed->chr_beg = strtod( field, &pt );
- } else if ( i == 2 ) {
- bed->chr_end = strtod( field, &pt );
- } else if ( i == 3 ) {
- bed->q_id = mem_clone( ( char * ) field, field_len );
- } else if ( i == 4 ) {
-// bed->score = strtof( field, &pt );
- } else if ( i == 5 ) {
- bed->strand = field[ 0 ];
- } else if ( i == 6 ) {
- bed->thick_beg = strtod( field, &pt );
- } else if ( i == 7 ) {
- bed->thick_end = strtod( field, &pt );
- } else if ( i == 8 ) {
- bed->itemrgb = mem_clone( ( char * ) field, field_len );
- } else if ( i == 9 ) {
- bed->blockcount = strtod( field, &pt );
- } else if ( i == 10 ) {
- bed->blocksizes = mem_clone( ( char * ) field, field_len );
- } else if ( i == 11 ) {
- bed->q_begs = mem_clone( ( char * ) field, field_len );
- }
-
- if ( pt == NULL ) {
- abort();
- }
-
- offset = field_seps[ i ] + 1;
- }
-
- printf( "chr ->%s\n", bed->chr );
- printf( "chr_beg->%u\n", bed->chr_beg );
- printf( "chr_end->%u\n", bed->chr_end );
-}
-
-
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include <getopt.h>
#include "common.h"
#include "mem.h"
-#include "common.h"
-#include "filesys.h"
-#include "fasta.h"
+#include <stdio.h>
+#include <stdlib.h>
-int main( int argc, char *argv[] )
-{
- char *file;
- FILE *fp;
- char chr[ 10 ];
- int chr_beg;
- int chr_end;
-
- file = argv[ 1 ];
-
- fp = read_open( file );
-
- fscanf( "%s\t%d\t%d", fp, chr, chr_beg, chr_end );
-
- printf( "CHR: %s CHR_BEG: %d CHR_END: %d\n", chr, chr_beg, chr_end );
-
- close_stream( fp );
-
- return 0;
-}
-
-
-double average( int num, ... )
-{
- /* Martin A. Hansen, July 2008 */
-
- /* Example of varable length argument list usage. */
-
- /* Requires '#include <stdarg.h>' */
-
- double sum = 0;
- int x = 0;
-
- va_list arguments;
- va_start( arguments, num );
-
- for ( x = 0; x < num; x++ )
- {
- sum += va_arg( arguments, double );
- }
-
- va_end( arguments );
-
- return sum / num;
-}
-
-
-
-/*
-
-int main( int argc, char *argv[] )
+int main()
{
- char *file;
- FILE *fp;
- struct seq_entry *entry = NULL;
- int count;
-
- count = 0;
-
- file = argv[ 1 ];
+ char str[] = "ABCDEFGHIJKLMNOPQRSTUVXYZ";
+ int i = 0;
+ char *pt1 = NULL;
+ int size = 4;
+ char word[ size ];
- fp = read_open( file );
- while ( ( fasta_get_entry( fp, entry ) ) != FALSE )
+ for ( i = size, pt1 = &str[ size ]; i < 10; i++, *( pt1++ ) )
{
- printf( "seq_name: %s\n", entry->seq_name );
-
-// mem_free( entry->seq_name );
-// mem_free( entry->seq );
-// entry = NULL;
-
- count++;
+ printf( "char: %s\n", pt1 );
+// printf( "word: %s\n", &pt[ i ] );
}
- printf( "count: %d\n", count );
-
- close_stream( fp );
-
- return 0;
+ return EXIT_SUCCESS;
}
-*/
+//double average( int num, ... )
+//{
+// /* Martin A. Hansen, July 2008 */
+//
+// /* Example of varable length argument list usage. */
+//
+// /* Requires '#include <stdarg.h>' */
+//
+// double sum = 0;
+// int x = 0;
+//
+// va_list arguments;
+//
+// va_start( arguments, num );
+//
+// for ( x = 0; x < num; x++ )
+// {
+// sum += va_arg( arguments, double );
+// }
+//
+// va_end( arguments );
+//
+// return sum / num;
+//}
+
+
+//int main( int argc, char *argv[] )
+//{
+// char *file;
+// FILE *fp;
+// struct seq_entry *entry = NULL;
+// int count;
+//
+// count = 0;
+//
+// file = argv[ 1 ];
+//
+// fp = read_open( file );
+//
+// while ( ( fasta_get_entry( fp, entry ) ) != FALSE )
+// {
+// printf( "seq_name: %s\n", entry->seq_name );
+//
+//// mem_free( entry->seq_name );
+//// mem_free( entry->seq );
+//// entry = NULL;
+//
+// count++;
+// }
+//
+// printf( "count: %d\n", count );
+//
+// close_stream( fp );
+//
+// return 0;
+//}
+# Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved
+
CC = gcc
Cflags = -Wall -Werror -g -pg # for gprof
all: test
-test: test_bits test_common test_fasta test_filesys test_hash test_list test_mem test_seq test_strings
+test: test_bits test_common test_fasta test_filesys test_hash test_list test_mem test_ucsc test_seq test_strings
test_bits: test_bits.c $(LIB_DIR)bits.c
$(CC) $(Cflags) $(INC) $(LIB) test_bits.c -o test_bits
test_mem: test_mem.c $(LIB_DIR)mem.c
$(CC) $(Cflags) $(INC) $(LIB) test_mem.c -o test_mem
+test_ucsc: test_ucsc.c $(LIB_DIR)ucsc.c
+ $(CC) $(Cflags) $(INC) $(LIB) test_ucsc.c -o test_ucsc
+
test_seq: test_seq.c $(LIB_DIR)seq.c
$(CC) $(Cflags) $(INC) $(LIB) test_seq.c -o test_seq
rm test_hash
rm test_list
rm test_mem
+ rm test_ucsc
rm test_seq
rm test_strings
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "bits.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
static void test_true();
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "filesys.h"
#include "mem.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "filesys.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "hash.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
#include "list.h"
+/* Martin Asser Hansen (mail@maasha.dk) Copyright (C) 2008 - All right reserved */
+
#include "common.h"
#include "mem.h"
test_list
test_mem
test_seq
- test_sort
test_strings
);